├── tools ├── qnatsh │ ├── install │ ├── alarm_conf │ ├── lib │ │ ├── libreadline.so │ │ ├── libreadline.so.6.2 │ │ ├── str.h │ │ ├── zassert.h │ │ ├── network.h │ │ ├── version.h │ │ ├── readline │ │ │ ├── rlstdc.h │ │ │ └── rlconf.h │ │ ├── md5.h │ │ ├── filter.h │ │ └── vector.h │ ├── logo.conf │ ├── msg.c │ ├── nsh_user.h │ ├── msg.h │ ├── Makefile │ └── nsh_serv.h ├── ipvsadm │ ├── VERSION │ ├── debian │ │ ├── ipvsadm.dirs │ │ ├── files │ │ ├── ipvsadm.substvars │ │ ├── ipvsadm.files │ │ ├── control │ │ ├── changelog │ │ ├── rules │ │ └── copyright │ ├── PERSISTENCE_ENGINES │ ├── SCHEDULERS │ ├── ipvsadm.c │ ├── config_stream.h │ ├── ipvsadm-restore.8 │ ├── ipvsadm-restore │ ├── ipvsadm-save.8 │ ├── contrib │ │ └── popt-optional.diff │ ├── ipvsadm-save │ └── MAINTAINERS ├── keepalived │ ├── bin │ │ ├── .gitignore │ │ ├── genhash │ │ └── keepalived │ ├── VERSION │ ├── genhash │ │ ├── VERSION │ │ ├── AUTHOR │ │ ├── README │ │ ├── ChangeLog │ │ ├── ssl.h │ │ ├── sock.h │ │ ├── Makefile.in │ │ ├── sock.c │ │ ├── layer4.h │ │ ├── Makefile │ │ └── hash.h │ ├── TODO │ ├── AUTHOR │ ├── doc │ │ ├── samples │ │ │ ├── dh1024.pem │ │ │ ├── sample.misccheck.smbcheck.sh │ │ │ ├── keepalived.conf.fwmark │ │ │ ├── keepalived.conf.misc_check_arg │ │ │ ├── keepalived.conf.misc_check │ │ │ ├── keepalived.conf.vrrp.static_ipaddress │ │ │ ├── keepalived.conf.HTTP_GET.port │ │ │ ├── root.pem │ │ │ ├── keepalived.conf.track_interface │ │ │ ├── keepalived.conf.inhibit │ │ │ ├── keepalived.conf.status_code │ │ │ ├── keepalived.conf.vrrp.routes │ │ │ ├── keepalived.conf.virtualhost │ │ │ ├── keepalived.conf.sample │ │ │ ├── keepalived.conf.IPv6 │ │ │ ├── keepalived.conf.virtual_server_group │ │ │ ├── keepalived.conf.vrrp.lvs_syncd │ │ │ ├── keepalived.conf.vrrp.scripts │ │ │ ├── keepalived.conf.vrrp │ │ │ ├── client.pem │ │ │ ├── keepalived.conf.SSL_GET │ │ │ └── keepalived.conf.vrrp.sync │ │ └── man │ │ │ └── man1 │ │ │ └── genhash.1 │ ├── keepalived │ │ ├── libipvs-2.4 │ │ │ ├── Makefile.in │ │ │ └── libipvs.h │ │ ├── libipvs-2.6 │ │ │ ├── Makefile.in │ │ │ ├── Makefile │ │ │ ├── dp_vs.h │ │ │ ├── sockopt.h │ │ │ └── test.c │ │ ├── etc │ │ │ └── init.d │ │ │ │ ├── keepalived.sysconfig │ │ │ │ ├── keepalived.rh.init │ │ │ │ └── keepalived.init │ │ ├── include │ │ │ ├── global_parser.h │ │ │ ├── vrrp_parser.h │ │ │ ├── check_parser.h │ │ │ ├── vrrp_notify.h │ │ │ ├── daemon.h │ │ │ ├── vrrp_daemon.h │ │ │ ├── check_daemon.h │ │ │ ├── check_tcp.h │ │ │ ├── check_ssl.h │ │ │ ├── check_misc.h │ │ │ ├── vrrp_index.h │ │ │ ├── vrrp_vmac.h │ │ │ ├── pidfile.h │ │ │ ├── layer4.h │ │ │ ├── main.h │ │ │ ├── vrrp_sync.h │ │ │ ├── vrrp_scheduler.h │ │ │ ├── global_data.h │ │ │ └── vrrp_arp.h │ │ ├── core │ │ │ ├── Makefile.in │ │ │ ├── Makefile │ │ │ └── daemon.c │ │ └── vrrp │ │ │ └── vrrp_arp.c │ ├── CONTRIBUTORS │ ├── README │ ├── lib │ │ ├── logger.h │ │ ├── notify.h │ │ ├── Makefile │ │ ├── Makefile.in │ │ ├── html.h │ │ ├── config.h │ │ ├── config.h.in │ │ ├── signals.h │ │ ├── logger.c │ │ ├── timer.h │ │ └── list.h │ ├── Makefile │ ├── Makefile.in │ └── INSTALL ├── Makefile └── dpip │ ├── Makefile │ ├── utils.h │ ├── dpip.h │ └── utils.c ├── config ├── qnat_blk.conf ├── qnatcfg.conf.sample └── logo.conf ├── pic ├── QNAT.png ├── top.png ├── QQ_group.png └── architecture.png ├── scripts └── init.sample.sh ├── include ├── ipvs │ ├── proto_icmp.h │ ├── rr.h │ ├── wlc.h │ ├── wrr.h │ ├── proto_udp.h │ ├── laddr.h │ ├── blklst.h │ ├── ipvs.h │ ├── xmit.h │ └── sched.h ├── cfgfile.h ├── icmp.h ├── global_conf.h ├── ipv4_frag.h ├── pidfile.h ├── conf │ ├── neigh.h │ ├── vlan.h │ ├── blklst.h │ ├── laddr.h │ ├── inetaddr.h │ └── route.h ├── parser │ └── utils.h ├── kni.h ├── dpdk.h └── netif_addr.h ├── src ├── config.mk ├── dpdk.mk ├── Makefile └── pidfile.c └── Makefile /tools/qnatsh/install: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tools/ipvsadm/VERSION: -------------------------------------------------------------------------------- 1 | 1.27 2 | -------------------------------------------------------------------------------- /tools/keepalived/bin/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tools/qnatsh/alarm_conf: -------------------------------------------------------------------------------- 1 | 3600 2 | -------------------------------------------------------------------------------- /tools/ipvsadm/debian/ipvsadm.dirs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tools/keepalived/VERSION: -------------------------------------------------------------------------------- 1 | 1.2.13 2 | -------------------------------------------------------------------------------- /tools/ipvsadm/PERSISTENCE_ENGINES: -------------------------------------------------------------------------------- 1 | sip 2 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/VERSION: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /config/qnat_blk.conf: -------------------------------------------------------------------------------- 1 | 255.255.255.255=10000 2 | -------------------------------------------------------------------------------- /tools/keepalived/TODO: -------------------------------------------------------------------------------- 1 | Whatever you want ! 2 | -------------------------------------------------------------------------------- /tools/ipvsadm/SCHEDULERS: -------------------------------------------------------------------------------- 1 | rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq 2 | -------------------------------------------------------------------------------- /tools/keepalived/AUTHOR: -------------------------------------------------------------------------------- 1 | Alexandre Cassen, 2 | -------------------------------------------------------------------------------- /pic/QNAT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/pic/QNAT.png -------------------------------------------------------------------------------- /pic/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/pic/top.png -------------------------------------------------------------------------------- /tools/ipvsadm/debian/files: -------------------------------------------------------------------------------- 1 | ipvsadm_1.25-ipv6-1_i386.deb net optional 2 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/AUTHOR: -------------------------------------------------------------------------------- 1 | Alexandre Cassen, 2 | -------------------------------------------------------------------------------- /pic/QQ_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/pic/QQ_group.png -------------------------------------------------------------------------------- /pic/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/pic/architecture.png -------------------------------------------------------------------------------- /tools/ipvsadm/ipvsadm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/tools/ipvsadm/ipvsadm.c -------------------------------------------------------------------------------- /tools/ipvsadm/debian/ipvsadm.substvars: -------------------------------------------------------------------------------- 1 | shlibs:Depends=libpopt0 (>= 1.10), libnl1, libc6 (>= 2.4) 2 | -------------------------------------------------------------------------------- /tools/keepalived/bin/genhash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/tools/keepalived/bin/genhash -------------------------------------------------------------------------------- /tools/keepalived/bin/keepalived: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/tools/keepalived/bin/keepalived -------------------------------------------------------------------------------- /tools/qnatsh/lib/libreadline.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/tools/qnatsh/lib/libreadline.so -------------------------------------------------------------------------------- /tools/qnatsh/lib/libreadline.so.6.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qihoo360/QNAT/HEAD/tools/qnatsh/lib/libreadline.so.6.2 -------------------------------------------------------------------------------- /tools/ipvsadm/debian/ipvsadm.files: -------------------------------------------------------------------------------- 1 | sbin/ipvsadm 2 | sbin/ipvsadm-restore 3 | sbin/ipvsadm-save 4 | usr/man/man8/ipvsadm.8 5 | etc/init.d/ipvsadm 6 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/dh1024.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIGHAoGBANmAnfkETuKHOCWaE+W+F3kM/e7z5A8hZb7OqwGMQrUOaBEAr4BWeZBn 3 | G/87hhwZgNP69/KUchm714qd/PpOspCaUJ20x6PcmKujpAgca/f19HGMBjRawQMk 4 | R9oaBwazuQT0l0rTTKmvpMEcrQQIcVWii3CZI56I56oqF8biGPD7AgEC 5 | -----END DH PARAMETERS----- 6 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.4/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile to make libipvsc. 2 | 3 | CC = @CC@ 4 | CFLAGS = @CFLAGS@ @CPPFLAGS@ -Wall -Wunused 5 | 6 | export OBJS += libipvs.a 7 | 8 | all: libipvs.a 9 | 10 | libipvs.a: libipvs.a(libipvs.o) 11 | 12 | libipvsc.o: libipvs.h 13 | 14 | clean: 15 | rm -f *.a *.o *~ 16 | 17 | distclean: clean 18 | rm -f Makefile 19 | -------------------------------------------------------------------------------- /tools/ipvsadm/debian/control: -------------------------------------------------------------------------------- 1 | Source: ipvsadm 2 | Section: net 3 | Priority: optional 4 | Maintainer: Horms 5 | Standards-Version: 3.1.1 6 | 7 | Package: ipvsadm 8 | Architecture: any 9 | Depends: ${shlibs:Depends} 10 | Description: 11 | ipvsadm is a utility to administer the IP virtual server services 12 | offered by the Linux kernel augmented with the virtual server patch. 13 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/sample.misccheck.smbcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # remove it as smbcheck.sh and put it the location you want 3 | 4 | SAMBA_BIN=`which smbclient 2> /dev/null` 5 | 6 | if [ -z "$SAMBA_BIN" ] ; then 7 | exit 2 8 | fi 9 | 10 | if [ -z "$1" ] ; then 11 | echo "Usage: $0 " 12 | exit 2 13 | fi 14 | 15 | ($SAMBA_BIN -N -L $1 -W CENTRALB -U nobody) \ 16 | | egrep '^Domain=\[[A-Za-z0-9_-]+\]' > /dev/null 2>&1 17 | 18 | -------------------------------------------------------------------------------- /config/qnatcfg.conf.sample: -------------------------------------------------------------------------------- 1 | local ip 10.10.10.2/27 2 | ip addr 10.10.10.3/27 dev dpdk0.kni 3 | ip addr 110.110.110.2/28 dev dpdk1.kni 4 | ip route 10.10.10.3/32 dev inside kni_host 5 | ip route 110.110.110.2/32 dev outside kni_host 6 | ip route 10.0.0.0/8 via 10.10.10.1 dev inside 7 | ip route 0.0.0.0/0 via 110.110.110.1 dev outside 8 | hostname nattest 9 | ip nat pool default 10 | member ip 110.110.110.5/28 11 | exit 12 | ip nat source 10.0.0.0 10.255.255.255 13 | dest pool default 14 | exit 15 | -------------------------------------------------------------------------------- /scripts/init.sample.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | echo 8192 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages 3 | echo 8192 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages 4 | modprobe uio 5 | cd ${path-of-dpdk} 6 | insmod build/kmod/igb_uio.ko 7 | insmod build/kmod/rte_kni.ko 8 | ifconfig eth0 down 9 | ifconfig eth1 down 10 | ${path-of-dpdk}/usertools/dpdk-devbind.py -b igb_uio 0000:84:00.0 11 | ${path-of-dpdk}/usertools/dpdk-devbind.py -b igb_uio 0000:84:00.1 12 | -------------------------------------------------------------------------------- /tools/ipvsadm/config_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Code to convert a stream input into a dynamic array 3 | * that can be parsed as argc and argv. 4 | * 5 | * Authors: Horms 6 | * 7 | * Released under the terms of the GNU GPL 8 | */ 9 | 10 | #ifndef CONFIG_STREAM_FLIM 11 | #define CONFIG_STREAM_FLIM 12 | 13 | #include "dynamic_array.h" 14 | 15 | #define MAX_LINE_LENGTH 4096 16 | 17 | dynamic_array_t *config_stream_read(FILE * stream, 18 | const char *first_element); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/README: -------------------------------------------------------------------------------- 1 | The main goal of the keepalived project is to add a strong & robust 2 | keepalive facility to the Linux Virtual Server project. 3 | It implements a multilayer TCP/IP stack checks. Keepalived implements 4 | a framework based on three family checks : Layer3, Layer4 & Layer5. 5 | This framework gives the daemon the ability of checking a LVS server 6 | pool states. Keepalived can be sumarize as a LVS driving daemon. 7 | 8 | To generate MD5SUM digest the this tool (genhash) is used. 9 | 10 | Keepalived is free software. See the file COPYING for copying conditions. 11 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.fwmark: -------------------------------------------------------------------------------- 1 | ! Sample configuration for use Linux FWMARK 2 | 3 | global_defs { 4 | router_id io 5 | } 6 | 7 | virtual_server fwmark 1 { 8 | delay_loop 6 9 | lb_algo rr 10 | lb_kind NAT 11 | persistence_timeout 900 12 | protocol TCP 13 | 14 | real_server 192.168.201.100 { 15 | weight 1 16 | TCP_CHECK { 17 | connect_port 80 18 | connect_timeout 3 19 | } 20 | } 21 | 22 | real_server 192.168.201.101 { 23 | weight 1 24 | TCP_CHECK { 25 | connect_port 80 26 | connect_timeout 3 27 | } 28 | } 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.6/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for libipvs 2 | 3 | CC = @CC@ 4 | CFLAGS = @CFLAGS@ @CPPFLAGS@ -D@USE_NL@ -Wall -Wunused 5 | 6 | CFLAGS += -I ../../../../include 7 | CFLAGS += -I ./libsockopt 8 | 9 | export OBJS += libipvs.a 10 | 11 | STATIC_LIB = libipvs.a 12 | 13 | all: $(STATIC_LIB) 14 | 15 | test: sockopt.o test.o 16 | $(CC) $(CFLAGS) -o $@ $^ 17 | 18 | $(STATIC_LIB): sockopt.o libipvs.o ip_vs_nl_policy.o 19 | ar rv $@ $^ 20 | rm $^ 21 | 22 | %.o: %.c 23 | $(CC) $(CFLAGS) -c -o $@ $< 24 | 25 | clean: 26 | rm -f *.[ao] *~ *.orig *.rej core 27 | 28 | distclean: clean 29 | -------------------------------------------------------------------------------- /tools/ipvsadm/ipvsadm-restore.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" ipvsadm-restore(8) manual page 3 | .\" Inspired by ipchains-restore 4 | .\" 5 | .\" $Id$ 6 | .\" 7 | .\" Authors: Wensong Zhang 8 | .\" 9 | .\" Changes: 10 | .\" 11 | .\" 12 | .TH IPVSADM-RESTORE 8 "22nd March 2001" "LVS Administration" "Linux Administrator's Guide" 13 | .SH NAME 14 | ipvsadm\-restore \- restore the IPVS table from stdin 15 | .SH SYNOPSIS 16 | .BR "ipvsadm\-restore " 17 | .SH DESCRIPTION 18 | ipvsadm\-restore prints the IPVS table from stdin. 19 | .SH OPTIONS 20 | No options now. 21 | .SH SEE ALSO 22 | ipvsadm(8), the LVS\-HOWTO. 23 | -------------------------------------------------------------------------------- /config/logo.conf: -------------------------------------------------------------------------------- 1 | ______ ______ ______ ______ _______ ______ 2 | / \ / \ / \ / \ | \ / \ 3 | | ######\| ######\| ######\ | ######\| #######\| ######\ 4 | \##__| ##| ##___\##| ###\| ## | ## | ##| ##__/ ##| ##___\## 5 | | ##| ## \ | ####\ ## | ## | ##| ## ## \## \ 6 | __\#####\| #######\| ##\##\## | ## | ##| ####### _\######\ 7 | | \__| ##| ##__/ ##| ##_\#### | ##__/ ##| ## | \__| ## 8 | \## ## \## ## \## \### \## ##| ## \## ## 9 | \###### \###### \###### \###### \## \###### 10 | 11 | -------------------------------------------------------------------------------- /tools/qnatsh/logo.conf: -------------------------------------------------------------------------------- 1 | ______ ______ ______ ______ _______ ______ 2 | / \ / \ / \ / \ | \ / \ 3 | | ######\| ######\| ######\ | ######\| #######\| ######\ 4 | \##__| ##| ##___\##| ###\| ## | ## | ##| ##__/ ##| ##___\## 5 | | ##| ## \ | ####\ ## | ## | ##| ## ## \## \ 6 | __\#####\| #######\| ##\##\## | ## | ##| ####### _\######\ 7 | | \__| ##| ##__/ ##| ##_\#### | ##__/ ##| ## | \__| ## 8 | \## ## \## ## \## \### \## ##| ## \## ## 9 | \###### \###### \###### \###### \## \###### 10 | 11 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.6/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for libipvs 2 | 3 | CC = gcc 4 | CFLAGS = -g -O2 -I/usr/src/linux/include -I/usr/src/linux/include -DLIBIPVS_DONTUSE_NL -Wall -Wunused 5 | 6 | CFLAGS += -I ../../../../include 7 | CFLAGS += -I ./libsockopt 8 | 9 | export OBJS += libipvs.a 10 | 11 | STATIC_LIB = libipvs.a 12 | 13 | all: $(STATIC_LIB) 14 | 15 | test: sockopt.o test.o 16 | $(CC) $(CFLAGS) -o $@ $^ 17 | 18 | $(STATIC_LIB): sockopt.o libipvs.o ip_vs_nl_policy.o 19 | ar rv $@ $^ 20 | rm $^ 21 | 22 | %.o: %.c 23 | $(CC) $(CFLAGS) -c -o $@ $< 24 | 25 | clean: 26 | rm -f *.[ao] *~ *.orig *.rej core 27 | 28 | distclean: clean 29 | -------------------------------------------------------------------------------- /tools/ipvsadm/ipvsadm-restore: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ipvsadm-restore - Restore IPVS rules 3 | # 4 | # A very simple wrapper to restore IPVS rules 5 | # Inspired by ipchains-save. 6 | # 7 | # Version: $Id$ 8 | # 9 | # Script Author: Horms 10 | # 11 | # This file: 12 | # 13 | # ChangeLog 14 | # Horms : Clear IPVS rules before adding from STDIN 15 | # Horms : Filter out "^#" 16 | # 17 | # 18 | 19 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 20 | 21 | # All the work is actually done in ipvsadm, hooray 22 | 23 | INPUT="$(grep -v '^#')" 24 | ipvsadm -C 25 | echo "$INPUT" | ipvsadm -R 26 | 27 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.misc_check_arg: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server 10.10.10.2 1358 { 14 | delay_loop 6 15 | lb_algo rr 16 | lb_kind NAT 17 | nat_mask 255.255.255.0 18 | persistence_timeout 50 19 | protocol TCP 20 | 21 | real_server 192.168.200.6 1358 { 22 | weight 1 23 | MISC_CHECK { 24 | misc_path "/usr/local/bin/script.sh arg1 arg2" 25 | } 26 | } 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /tools/ipvsadm/ipvsadm-save.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" ipvsadm-save(8) manual page 3 | .\" Inspired by ipchains-save 4 | .\" 5 | .\" $Id$ 6 | .\" 7 | .\" Authors: Wensong Zhang 8 | .\" 9 | .\" Changes: 10 | .\" 11 | .\" 12 | .TH IPVSADM-SAVE 8 "22nd March 2001" "LVS Administration" "Linux Administrator's Guide" 13 | .SH NAME 14 | ipvsadm\-save \- save the IPVS table to stdout 15 | .SH SYNOPSIS 16 | .BR "ipvsadm\-save " [ -n ] 17 | .SH DESCRIPTION 18 | ipvsadm\-save prints the IPVS table to stdout. 19 | .SH OPTIONS 20 | The option that is recognized by 21 | .B ipvsadm-save 22 | is: 23 | .TP 24 | .BR -n 25 | print out the table in numeric format. 26 | .SH SEE ALSO 27 | ipvsadm(8), the LVS\-HOWTO. 28 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.misc_check: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server 10.10.10.2 1358 { 14 | delay_loop 6 15 | lb_algo rr 16 | lb_kind NAT 17 | nat_mask 255.255.255.0 18 | persistence_timeout 50 19 | protocol TCP 20 | 21 | real_server 192.168.200.6 1358 { 22 | weight 1 23 | MISC_CHECK { 24 | misc_path /usr/local/bin/script.sh 25 | ! misc_dynamic 26 | } 27 | } 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.6/dp_vs.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_VS_H 2 | #define _DP_VS_H 3 | 4 | #include 5 | #include "conf/route.h" 6 | #include "conf/inetaddr.h" 7 | #include "conf/laddr.h" 8 | #include "conf/blklst.h" 9 | #include "conf/conn.h" 10 | 11 | enum{ 12 | DPVS_SO_SET_FLUSH = 200, 13 | DPVS_SO_SET_ZERO, 14 | DPVS_SO_SET_ADD, 15 | DPVS_SO_SET_EDIT, 16 | DPVS_SO_SET_DEL, 17 | DPVS_SO_SET_ADDDEST, 18 | DPVS_SO_SET_EDITDEST, 19 | DPVS_SO_SET_DELDEST, 20 | DPVS_SO_SET_GRATARP, 21 | }; 22 | 23 | enum{ 24 | DPVS_SO_GET_VERSION = 200, 25 | DPVS_SO_GET_INFO, 26 | DPVS_SO_GET_SERVICES, 27 | DPVS_SO_GET_SERVICE, 28 | DPVS_SO_GET_DESTS, 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/ChangeLog: -------------------------------------------------------------------------------- 1 | 2002-11-18 Alexandre Cassen 2 | * Rewrote the whole previous code to use common 3 | template libraries. 4 | 5 | 2002-01-17 Alexandre Cassen 6 | * Patched the dynamic GET request lenght allocation. 7 | 8 | 2001-11-29 Alexandre Cassen 9 | * genhash 0.4.9 released. 10 | * Rewrite the whole previous code 11 | * Jan Holmberg, and I added SSL support. 12 | * Possibility to use specific SSL certificate. 13 | * Added a command line parser using the popt library. 14 | * Added error handling support. 15 | * Review the MD5 computation. 16 | * Added a dynamic buffer allocation for remote server 17 | reply. 18 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.vrrp.static_ipaddress: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | router_id LVS_DEVEL 5 | } 6 | 7 | static_ipaddress { 8 | 192.168.200.16 dev eth0 scope link 9 | 192.168.200.17 dev eth1 scope link 10 | 192.168.200.18 dev eth2 11 | } 12 | 13 | vrrp_instance VI_1 { 14 | state MASTER 15 | interface eth0 16 | virtual_router_id 51 17 | priority 100 18 | virtual_ipaddress { 19 | 192.168.200.20 20 | } 21 | virtual_routes { 22 | src 192.168.100.1 192.168.109.0/24 via 192.168.200.254 dev eth1 23 | 192.168.110.0/24 via 192.168.200.254 dev eth1 24 | 192.168.111.0/24 dev eth2 25 | 192.168.112.0/24 via 192.168.100.254 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/etc/init.d/keepalived.sysconfig: -------------------------------------------------------------------------------- 1 | # Options for keepalived. See `keepalived --help' output and keepalived(8) and 2 | # keepalived.conf(5) man pages for a list of all options. Here are the most 3 | # common ones : 4 | # 5 | # --vrrp -P Only run with VRRP subsystem. 6 | # --check -C Only run with Health-checker subsystem. 7 | # --dont-release-vrrp -V Dont remove VRRP VIPs & VROUTEs on daemon stop. 8 | # --dont-release-ipvs -I Dont remove IPVS topology on daemon stop. 9 | # --dump-conf -d Dump the configuration data. 10 | # --log-detail -D Detailed log messages. 11 | # --log-facility -S 0-7 Set local syslog facility (default=LOG_DAEMON) 12 | # 13 | 14 | KEEPALIVED_OPTIONS="-D" 15 | 16 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/str.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: str.h,v 1.4 2005/09/19 09:53:21 hasso Exp $ 3 | */ 4 | 5 | #ifndef _ZEBRA_STR_H 6 | #define _ZEBRA_STR_H 7 | 8 | #ifndef HAVE_SNPRINTF 9 | extern int snprintf(char *, size_t, const char *, ...); 10 | #endif 11 | 12 | #ifndef HAVE_VSNPRINTF 13 | #define vsnprintf(buf, size, format, args) vsprintf(buf, format, args) 14 | #endif 15 | 16 | #ifndef HAVE_STRLCPY 17 | extern size_t strlcpy(char *, const char *, size_t); 18 | #endif 19 | 20 | #ifndef HAVE_STRLCAT 21 | extern size_t strlcat(char *, const char *, size_t); 22 | #endif 23 | 24 | #ifndef HAVE_STRNLEN 25 | extern size_t strnlen(const char *s, size_t maxlen); 26 | #endif 27 | 28 | #ifndef HAVE_STRNDUP 29 | extern char * strndup (const char *, size_t); 30 | #endif 31 | 32 | #endif /* _ZEBRA_STR_H */ 33 | 34 | -------------------------------------------------------------------------------- /tools/qnatsh/msg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * QNAT is a software NAT based on DPDK and DPVS. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "msg.h" 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/zassert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $ 3 | */ 4 | 5 | #ifndef _QUAGGA_ASSERT_H 6 | #define _QUAGGA_ASSERT_H 7 | 8 | extern void _zlog_assert_failed (const char *assertion, const char *file, 9 | unsigned int line, const char *function) 10 | __attribute__ ((noreturn)); 11 | 12 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 13 | #define __ASSERT_FUNCTION __func__ 14 | #elif defined(__GNUC__) 15 | #define __ASSERT_FUNCTION __FUNCTION__ 16 | #else 17 | #define __ASSERT_FUNCTION NULL 18 | #endif 19 | 20 | #define zassert(EX) ((void)((EX) ? 0 : \ 21 | (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ 22 | __ASSERT_FUNCTION), 0))) 23 | 24 | #undef assert 25 | #define assert(EX) zassert(EX) 26 | 27 | #endif /* _QUAGGA_ASSERT_H */ 28 | -------------------------------------------------------------------------------- /include/ipvs/proto_icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | #ifndef __DP_VS_PROTO_ICMP_H__ 17 | #define __DP_VS_PROTO_ICMP_H__ 18 | 19 | enum { 20 | DPVS_ICMP_S_NORMAL = 0, 21 | DPVS_ICMP_S_LAST 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.HTTP_GET.port: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server 192.168.200.100 443 { 14 | delay_loop 6 15 | lb_algo rr 16 | lb_kind NAT 17 | persistence_timeout 50 18 | protocol TCP 19 | 20 | real_server 192.168.201.100 443 { 21 | weight 1 22 | SSL_GET { 23 | url { 24 | path / 25 | digest ff20ad2481f97b1754ef3e12ecd3a9cc 26 | } 27 | connect_port 444 28 | connect_timeout 3 29 | nb_get_retry 3 30 | delay_before_retry 3 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/root.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICIjCCAYugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJVUzET 3 | MBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UECxMQV2lkZ2V0cyBEaXZpc2lvbjEY 4 | MBYGA1UEAxMPVGVzdCBDQTIwMDEwNTE3MB4XDTAxMDUxNzE2MDExNFoXDTA2MTIy 5 | NTE2MDExNFowVzELMAkGA1UEBhMCVVMxEzARBgNVBAoTClJURk0sIEluYy4xGTAX 6 | BgNVBAsTEFdpZGdldHMgRGl2aXNpb24xGDAWBgNVBAMTD1Rlc3QgQ0EyMDAxMDUx 7 | NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAmkX40warmH0+lnwD9YjsJhRz 8 | ZX6qXadFry0y2trZ6gMs8Mv33IKPwOu8TE7V+3PESEtjI2wr8juV9OkbIPOm+td5 9 | M8+6vXyIW+JBo3ch99i0QMTf5/jTgsW+3IjV8yEdiGcZFp2NWKLRvZPq2VRbuF7R 10 | 1pvgcaRuBJ0wGOohwnsCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCUB8zMKIlX5io8 11 | TalbzH9Qke7BcvFAL+wp/5w1ToVsWkNrINSWKv6bl/jcqOD3aPhK7qhaeOU8ZWKL 12 | PoPPCnRl9Wo+1JtsOO3qIgJP79Bl9ooLGahixF2v/gea5qNISjQvwYllLSa//APP 13 | 6kXHngO0RIRbiTBYHSkAzm6hDdsvVA== 14 | -----END CERTIFICATE----- 15 | -------------------------------------------------------------------------------- /include/cfgfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __CONFIG_H__ 19 | #define __CONFIG_H__ 20 | 21 | void try_reload(void); 22 | int cfgfile_init(void); 23 | int cfgfile_term(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tools/ipvsadm/contrib/popt-optional.diff: -------------------------------------------------------------------------------- 1 | --- rpm-4.0.4/popt/popt.c~ Sat Jan 19 07:28:30 2002 2 | +++ rpm-4.0.4/popt/popt.c Fri Aug 9 17:08:15 2002 3 | @@ -840,12 +840,17 @@ 4 | canstrip) { 5 | poptStripArg(con, con->os->next); 6 | } 7 | - 8 | + 9 | if (con->os->argv != NULL) { /* XXX can't happen */ 10 | - /* XXX watchout: subtle side-effects live here. */ 11 | - longArg = con->os->argv[con->os->next++]; 12 | - longArg = expandNextArg(con, longArg); 13 | - con->os->nextArg = longArg; 14 | + if (opt->argInfo & POPT_ARGFLAG_OPTIONAL && 15 | + con->os->argv[con->os->next][0] == '-') { 16 | + con->os->nextArg = NULL; 17 | + } else { 18 | + /* XXX watchout: subtle side-effects live here. */ 19 | + longArg = con->os->argv[con->os->next++]; 20 | + longArg = expandNextArg(con, longArg); 21 | + con->os->nextArg = longArg; 22 | + } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.track_interface: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | router_id LVS_DEVEL 5 | } 6 | 7 | static_route { 8 | 192.168.210.0/24 via 192.168.200.254 dev eth0 9 | 192.168.211.0/24 via 192.168.200.254 dev eth0 10 | 192.168.212.0/24 dev eth3 11 | 192.168.213.0/24 dev eth1 12 | } 13 | 14 | vrrp_instance VI_1 { 15 | state MASTER 16 | interface eth0.1 # Vlaned interface 17 | track_interface { # Interface state we monitor 18 | eth0 19 | eth1 20 | } 21 | virtual_router_id 51 22 | priority 100 23 | virtual_ipaddress { 24 | 192.168.200.16 25 | 192.168.200.17 dev eth1 26 | 192.168.200.18 dev eth2 27 | } 28 | virtual_routes { 29 | 192.168.110.0/24 via 192.168.200.254 dev eth1 30 | 192.168.111.0/24 dev eth2 31 | 192.168.112.0/24 via 192.168.100.254 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.inhibit: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server 10.10.10.2 1358 { 14 | delay_loop 6 15 | lb_algo rr 16 | lb_kind NAT 17 | persistence_timeout 50 18 | protocol TCP 19 | 20 | 21 | real_server 192.168.200.2 1358 { 22 | weight 1 23 | inhibit_on_failure ! set weight to 0 instead of removing service 24 | HTTP_GET { 25 | url { 26 | path /testurl3/test.jsp 27 | digest 640205b7b0fc66c1ea91c463fac6334d 28 | } 29 | connect_timeout 3 30 | nb_get_retry 3 31 | delay_before_retry 3 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /include/ipvs/rr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_RR_H__ 19 | #define __DPVS_RR_H__ 20 | 21 | #include "ipvs/service.h" 22 | #include "ipvs/dest.h" 23 | #include "ipvs/sched.h" 24 | 25 | int dp_vs_rr_init(void); 26 | int dp_vs_rr_term(void); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tools/ipvsadm/ipvsadm-save: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ipvsadm-save - Save IPVS rules 3 | # 4 | # A very simple wrapper to save IPVS rules 5 | # Inspired by ipchains-save. 6 | # 7 | # Version: $Id$ 8 | # 9 | # Script Author: Horms 10 | # 11 | # This file: 12 | # 13 | # ChangeLog 14 | # 15 | # Wensong Zhang : Added the "-n" option and the help() 16 | # 17 | 18 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 19 | NUMERIC="" 20 | 21 | 22 | help() 23 | { 24 | exec 1>&2 25 | echo `basename $0`: Script to save the IPVS table to stdout. 26 | echo " With the -n option, prints out the table in numeric format." 27 | 28 | exit 1 29 | } 30 | 31 | 32 | for arg 33 | do 34 | case "$arg" 35 | in 36 | -n) NUMERIC="-n" ;; 37 | -*) help ;; 38 | esac 39 | done 40 | 41 | 42 | # All the work is actually done in ipvsadm, horay 43 | 44 | ipvsadm -S $NUMERIC 45 | -------------------------------------------------------------------------------- /include/ipvs/wlc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_WLC_H__ 19 | #define __DPVS_WLC_H__ 20 | 21 | #include "ipvs/service.h" 22 | #include "ipvs/dest.h" 23 | #include "ipvs/sched.h" 24 | 25 | int dp_vs_wlc_init(void); 26 | int dp_vs_wlc_term(void); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/ipvs/wrr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_WRR_H__ 19 | #define __DPVS_WRR_H__ 20 | 21 | #include "ipvs/service.h" 22 | #include "ipvs/dest.h" 23 | #include "ipvs/sched.h" 24 | 25 | int dp_vs_wrr_init(void); 26 | int dp_vs_wrr_term(void); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tools/keepalived/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Jan Holmberg, : 2 | o Memory framework 3 | o HTTP/SSL checkers 4 | 5 | Bradley Baetz, : 6 | o MISC checker redesign 7 | o Scheduler framework extension to support 8 | child process handling. 9 | o Daemon framework extension to block SIGCHLD 10 | to only receive it when its unblocked in the 11 | scheduling select loop. 12 | 13 | Jeremy Rumpf, : 14 | o Added SMTP checker 15 | 16 | Chris Caputo, : 17 | o Added dont_track_primary, nopreempt, 18 | preempt_delay, and misc_dynamic. 19 | 20 | Kevin Lindsay, : 21 | o Fixed shadowed declaration reported by -Wshadow. 22 | o Redesigned signal handling. 23 | 24 | Nick Couchman, : 25 | o Patch for u_threshold and l_threshold support. 26 | 27 | Willy Tarreau, : 28 | o Extended VRRP framework to support floating 29 | priority. 30 | -------------------------------------------------------------------------------- /include/ipvs/proto_udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DP_VS_PROTO_UDP_H__ 19 | #define __DP_VS_PROTO_UDP_H__ 20 | 21 | enum { 22 | DPVS_UDP_S_NORMAL = 0, 23 | DPVS_UDP_S_LAST 24 | }; 25 | 26 | extern int g_defence_udp_drop; 27 | 28 | void install_proto_udp_keywords(void); 29 | void udp_keyword_value_init(void); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.status_code: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server 192.168.200.100 443 { 14 | delay_loop 6 15 | lb_algo rr 16 | lb_kind NAT 17 | persistence_timeout 50 18 | protocol TCP 19 | 20 | real_server 192.168.201.100 443 { 21 | weight 1 22 | SSL_GET { 23 | url { 24 | path / 25 | status_code 200 # Can only specify a HTTP status_code 26 | } 27 | url { 28 | path /mrtg/ 29 | digest 9b3a0c85a887a256d6939da88aabd8cd 30 | status_code 200 # Can mix digest and status_code 31 | } 32 | connect_timeout 3 33 | nb_get_retry 3 34 | delay_before_retry 3 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tools/qnatsh/nsh_user.h: -------------------------------------------------------------------------------- 1 | /* User authentication for vtysh. 2 | * Copyright (C) 2000 Kunihiro Ishiguro 3 | * 4 | * This file is part of GNU Zebra. 5 | * 6 | * GNU Zebra is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation; either version 2, or (at your option) any 9 | * later version. 10 | * 11 | * GNU Zebra is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Zebra; see the file COPYING. If not, write to the Free 18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 | * 02111-1307, USA. 20 | */ 21 | 22 | #ifndef _VTYSH_USER_H 23 | #define _VTYSH_USER_H 24 | 25 | int vtysh_auth (); 26 | 27 | #endif /* _VTYSH_USER_H */ 28 | -------------------------------------------------------------------------------- /include/icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_ICMP_H__ 19 | #define __DPVS_ICMP_H__ 20 | #include 21 | 22 | int icmp_init(void); 23 | int icmp_term(void); 24 | 25 | void icmp_send(struct rte_mbuf *imbuf, int type, int code, uint32_t info); 26 | 27 | #define icmp4_id(icmph) (((icmph)->un).echo.id) 28 | 29 | #endif /* __DPVS_ICMP_H__ */ 30 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.vrrp.routes: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | router_id LVS_DEVEL 5 | } 6 | 7 | static_routes { 8 | src 192.168.100.1 192.168.209.0/24 via 192.168.200.254 dev eth0 9 | 192.168.210.0/24 via 192.168.200.254 dev eth0 10 | 192.168.211.0/24 via 192.168.200.254 dev eth0 11 | 192.168.212.0/24 dev eth3 scope site 12 | 192.168.213.0/24 dev eth1 scope link 13 | } 14 | 15 | vrrp_instance VI_1 { 16 | state MASTER 17 | interface eth0 18 | virtual_router_id 51 19 | priority 100 20 | virtual_ipaddress { 21 | 192.168.200.16 22 | 192.168.200.17 dev eth1 23 | 192.168.200.18 dev eth2 24 | } 25 | virtual_routes { 26 | src 192.168.100.1 192.168.109.0/24 via 192.168.200.254 dev eth1 27 | 192.168.110.0/24 via 192.168.200.254 dev eth1 28 | 192.168.111.0/24 dev eth2 29 | 192.168.112.0/24 via 192.168.100.254 30 | 192.168.113.0/24 via 192.168.100.252 or 192.168.100.253 31 | blackhole 192.168.113.1/32 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /include/global_conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __GLOBAL_CONF_H__ 19 | #define __GLOBAL_CONF_H__ 20 | 21 | #include 22 | #include "common.h" 23 | #include "parser/parser.h" 24 | #include "dpdk.h" 25 | 26 | #define DEF_LOG_LEVEL RTE_LOG_DEBUG 27 | 28 | void install_global_keywords(void); 29 | 30 | int global_conf_init(void); 31 | int global_conf_term(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.virtualhost: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server 192.168.200.100 80 { 14 | delay_loop 6 15 | lb_algo rr 16 | lb_kind NAT 17 | persistence_timeout 50 18 | protocol TCP 19 | virtualhost www.firewall.loc # The VirtualHost string to use 20 | # in the GET query. 21 | 22 | real_server 192.168.201.100 80 { 23 | weight 1 24 | SSL_GET { 25 | url { 26 | path / 27 | digest ff20ad2481f97b1754ef3e12ecd3a9cc 28 | } 29 | url { 30 | path /mrtg/ 31 | digest 9b3a0c85a887a256d6939da88aabd8cd 32 | } 33 | connect_timeout 3 34 | nb_get_retry 3 35 | delay_before_retry 3 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tools/keepalived/README: -------------------------------------------------------------------------------- 1 | The main goal of the keepalived project is to add a strong & robust 2 | keepalive facility to the Linux Virtual Server project. 3 | It implements a multilayer TCP/IP stack checks. Keepalived implements 4 | a framework based on three family checks : Layer3, Layer4 & Layer5. 5 | This framework gives the daemon the ability of checking a LVS server 6 | pool states. Keepalived can be sumarize as a LVS driving daemon. 7 | 8 | Keepalived implementation is based on an I/O multiplexer to handle a 9 | strong multi-threading framework. All the events process use this I/O 10 | multiplexer. 11 | 12 | Keepalived is free software, Copyright (C) Alexandre Cassen. 13 | See the file COPYING for copying conditions. 14 | 15 | 16 | OPENSSL TOOLKIT LICENCE EXCEPTION 17 | 18 | In addition, as the copyright holder of Keepalived, 19 | I, Alexandre Cassen, , 20 | grant the following special exception: 21 | 22 | I, Alexandre Cassen, , explicitly allow 23 | the compilation and distribution of the Keepalived software with 24 | the OpenSSL Toolkit. 25 | 26 | -------------------------------------------------------------------------------- /src/config.mk: -------------------------------------------------------------------------------- 1 | # 2 | # DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | # 4 | # Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | # All Rights Reserved. 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | 18 | # 19 | # enable as needed. 20 | # 21 | # TODO: use standard way to define compile flags. 22 | # 23 | 24 | #CFLAGS += -D CONFIG_RECORD_BIG_LOOP 25 | #CFLAGS += -D CONFIG_DPVS_SAPOOL_DEBUG 26 | #CFLAGS += -D CONFIG_DPVS_IPVS_DEBUG 27 | #CFLAGS += -D CONFIG_SYNPROXY_DEBUG 28 | #CFLAGS += -D CONFIG_TIMER_MEASURE 29 | #CFLAGS += -D DPVS_CFG_PARSER_DEBUG 30 | #CFLAGS += -D NETIF_BONDING_DEBUG 31 | #CFLAGS += -D CONFIG_TC_DEBUG 32 | -------------------------------------------------------------------------------- /tools/ipvsadm/debian/changelog: -------------------------------------------------------------------------------- 1 | ipvsadm (1.25-nl-5) hardy; urgency=low 2 | 3 | * use strtoul to convert ip addresses from hex 4 | from Simon Horman 5 | 6 | -- Vince Busam Wed, 20 Aug 2008 10:34:58 -0700 7 | 8 | ipvsadm (1.25-nl-4) unstable; urgency=low 9 | 10 | * Fixed sorting of IPv6 addresses 11 | 12 | -- Vince Busam Fri, 15 Aug 2008 13:15:06 -0700 13 | 14 | ipvsadm (1.25-nl-2) hardy; urgency=low 15 | 16 | * Code cleanups 17 | 18 | -- Vince Busam Wed, 23 Jul 2008 13:17:46 -0700 19 | 20 | ipvsadm (1.25-nl-1) hardy; urgency=low 21 | 22 | * Add support for experimental netlink interface 23 | 24 | -- Vince Busam Tue, 22 Jul 2008 15:50:38 -0700 25 | 26 | ipvsadm (1.25-ipv6-1) nstable; urgency=low 27 | 28 | * Add IPv6 support 29 | 30 | -- "Vince Busam" Wed, 21 May 2008 15:12:42 +0200 31 | 32 | ipvsadm (1.13-1) nstable; urgency=low 33 | 34 | * A release 35 | 36 | -- Horms Thu, 14 Dec 2000 17:00:00 -0800 37 | 38 | Local variables: 39 | mode: debian-changelog 40 | End: 41 | eoch 42 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.sample: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | vrrp_instance VI_1 { 14 | interface eth0 15 | virtual_router_id 50 16 | nopreempt 17 | priority 100 18 | advert_int 1 19 | virtual_ipaddress { 20 | 192.168.200.11 21 | 192.168.200.12 22 | 192.168.200.13 23 | } 24 | } 25 | 26 | virtual_server 10.10.10.2 1358 { 27 | delay_loop 6 28 | lb_algo rr 29 | lb_kind NAT 30 | persistence_timeout 50 31 | protocol TCP 32 | 33 | sorry_server 192.168.200.200 1358 34 | 35 | real_server 192.168.200.2 1358 { 36 | weight 1 37 | HTTP_GET { 38 | url { 39 | path /testurl3/test.jsp 40 | digest 640205b7b0fc66c1ea91c463fac6334d 41 | } 42 | connect_timeout 3 43 | nb_get_retry 3 44 | delay_before_retry 3 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.IPv6: -------------------------------------------------------------------------------- 1 | # Configuration File for keepalived 2 | 3 | global_defs { 4 | router_id LVS_DEVEL 5 | } 6 | 7 | 8 | virtual_server_group IPv6_group { 9 | ae00::2-9 80 10 | ae00::1 80 11 | } 12 | 13 | #virtual_server group IPv6_group { 14 | virtual_server ae00::1 80 { 15 | delay_loop 6 16 | lb_algo rr 17 | lb_kind NAT 18 | persistence_timeout 50 19 | protocol TCP 20 | 21 | # real_server ae00::10 80 { 22 | real_server ae00::10 25 { 23 | weight 1 24 | 25 | SMTP_CHECK { 26 | connect_timeout 3 27 | retry 3 28 | helo_name "foo.bar.com" 29 | 30 | # host { 31 | # bindto ae00::2 32 | # connect_ip ae00::10 33 | # connect_port 25 34 | # } 35 | } 36 | 37 | # TCP_CHECK { 38 | # connect_port 80 39 | # bind_to ae00::2 40 | # } 41 | 42 | # HTTP_GET { 43 | # url { 44 | # path /ind.html 45 | # status_code 200 46 | # } 47 | # bindto ae00::2 48 | # connect_timeout 3 49 | # nb_get_retry 3 50 | # delay_before_retry 3 51 | # } 52 | # } 53 | 54 | 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /include/ipv4_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_IPV4_FRAG_H__ 19 | #define __DPVS_IPV4_FRAG_H__ 20 | 21 | #define IP4_FRAG_FREE_DEATH_ROW_INTERVAL 100 22 | 23 | int ipv4_frag_init(void); 24 | int ipv4_frag_term(void); 25 | int ipv4_reassamble(struct rte_mbuf *mbuf); 26 | int ipv4_fragment(struct rte_mbuf *mbuf, unsigned int mtu, 27 | int (*output)(struct rte_mbuf *)); 28 | 29 | void ip4_frag_keyword_value_init(void); 30 | void install_ip4_frag_keywords(void); 31 | 32 | #endif /* __DPVS_IPV4_FRAG_H__ */ 33 | -------------------------------------------------------------------------------- /include/pidfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __PIDFILE_H__ 19 | #define __PIDFILE_H__ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /* lock file */ 28 | #define DPVS_PIDFILE "/var/run/dpvs.pid" 29 | #define RTE_LOGTYPE_PIDFILE RTE_LOGTYPE_USER1 30 | 31 | int pidfile_write(const char *pid_file, int pid); 32 | 33 | void pidfile_rm(const char *pid_file); 34 | 35 | bool dpvs_running(const char *pid_file); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tools/qnatsh/msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * QNAT is a software NAT based on DPDK and DPVS. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | #ifndef _MSG_H_ 17 | #define _MSG_H_ 18 | 19 | #define OAM_FLAGS_RECONNECT 0x1 20 | 21 | enum req_type { 22 | REQ_GET = 0, 23 | REQ_SET, 24 | REQ_MAX, 25 | }; 26 | 27 | struct nsh_sock_msg { 28 | unsigned int version; 29 | unsigned int id; 30 | enum req_type type; 31 | size_t len; 32 | char data[0]; 33 | }; 34 | 35 | struct nsh_sock_msg_reply { 36 | unsigned int version; 37 | unsigned int id; 38 | enum req_type type; 39 | int errcode; 40 | char errstr[64]; 41 | size_t len; 42 | char data[0]; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /tools/ipvsadm/MAINTAINERS: -------------------------------------------------------------------------------- 1 | 2 | List of maintainers for the different parts of the IPVS project. 3 | (using kernel style MAINTAINERS listing) 4 | 5 | Userspace ipvsadm tool (this tool) 6 | M: Jesper Dangaard Brouer 7 | M: Simon Horman 8 | T: git://git.kernel.org/pub/scm/utils/kernel/ipvsadm/ipvsadm.git 9 | W: https://kernel.org/pub/linux/utils/kernel/ipvsadm/ (tarballs) 10 | L: lvs-devel@vger.kernel.org 11 | L: lvs-users@linuxvirtualserver.org 12 | 13 | Kernel IPVS 14 | M: Simon Horman 15 | M: Julian Anastasov 16 | M: Wensong Zhang 17 | L: netdev@vger.kernel.org 18 | L: lvs-devel@vger.kernel.org 19 | S: Maintained 20 | F: Documentation/networking/ipvs-sysctl.txt 21 | F: include/net/ip_vs.h 22 | F: include/uapi/linux/ip_vs.h 23 | F: net/netfilter/ipvs/ 24 | 25 | Homepage: http://www.linuxvirtualserver.org/ 26 | M: Wensong Zhang 27 | W: http://www.linuxvirtualserver.org/ 28 | W: http://www.Linux-vs.org/ 29 | 30 | Wikipage: http://kb.linuxvirtualserver.org/ 31 | M: Wensong Zhang 32 | M: Jesper Dangaard Brouer 33 | W: http://kb.linuxvirtualserver.org/wiki/Main_Page 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # QNAT is a software NAT based on DPDK and DPVS. 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | 15 | # 16 | # Makefile for QNAT 17 | # 18 | MAKE = make 19 | CC = gcc 20 | LD = ld 21 | 22 | SUBDIRS = src tools 23 | 24 | INSDIR = /usr/bin 25 | export INSDIR 26 | 27 | export KERNEL = $(shell /bin/uname -r) 28 | 29 | all: 30 | for i in $(SUBDIRS); do $(MAKE) -C $$i || exit 1; done 31 | 32 | clean: 33 | for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done 34 | 35 | install:all 36 | -mkdir -p $(INSDIR) 37 | for i in $(SUBDIRS); do $(MAKE) -C $$i install || exit 1; done 38 | mkdir -p /etc/qnat/ 39 | \cp config/qnat.conf config/qnatcfg.conf.sample config/qnat_blk.conf config/logo.conf /etc/qnat 40 | 41 | -------------------------------------------------------------------------------- /tools/keepalived/lib/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: logging facility. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _LOGGER_H 24 | #define _LOGGER_H 25 | 26 | void enable_console_log(void); 27 | void log_message(int priority, char* format, ...); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # QNAT is a software NAT based on DPDK and DPVS. 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | 15 | # 16 | # Makefile for tools 17 | # 18 | SUBDIRS = keepalived ipvsadm dpip qnatsh 19 | 20 | all: config 21 | for i in $(SUBDIRS); do $(MAKE) -C $$i || exit 1; done 22 | 23 | config: keepalived_conf 24 | 25 | keepalived_conf: 26 | if [ ! -f keepalived/Makefile ]; then \ 27 | cd keepalived && \ 28 | ./configure && \ 29 | cd -; \ 30 | fi 31 | 32 | clean: 33 | for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done 34 | 35 | install: 36 | install -m 744 keepalived/bin/keepalived $(INSDIR)/keepalived 37 | install -m 744 ipvsadm/ipvsadm $(INSDIR)/ipvsadm 38 | install -m 744 dpip/build/dpip $(INSDIR)/dpip 39 | install -m 744 qnatsh/qnatsh $(INSDIR)/qnatsh 40 | -------------------------------------------------------------------------------- /tools/dpip/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | # 4 | # Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | # All Rights Reserved. 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | 18 | # 19 | # Makefile for dpip 20 | # 21 | 22 | TARGET = build/dpip 23 | 24 | CFLAGS = -g -O0 25 | CFLAGS += -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes 26 | 27 | CFLAGS += -I ../../include 28 | CFLAGS += -I ../keepalived/keepalived/libipvs-2.6 29 | 30 | OBJS = dpip.o utils.o route.o addr.o neigh.o link.o vlan.o \ 31 | qsch.o cls.o ../../src/common.o \ 32 | ../keepalived/keepalived/libipvs-2.6/sockopt.o 33 | 34 | all: $(TARGET) 35 | 36 | $(TARGET): $(OBJS) 37 | -mkdir -p ./build/ 38 | gcc $(CFLAGS) -o $@ $^ 39 | 40 | clean: 41 | rm -rf ./build/ *.o 42 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/global_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_parser.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _GLOBAL_PARSER_H 24 | #define _GLOBAL_PARSER_H 25 | 26 | /* local include */ 27 | 28 | /* Prototypes */ 29 | extern void global_init_keywords(void); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tools/keepalived/lib/notify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: notify.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _NOTIFY_H 24 | #define _NOTIFY_H 25 | 26 | /* system includes */ 27 | extern int system_call(char *cmdline); 28 | extern void closeall(int fd); 29 | extern int notify_exec(char *cmd); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_parser.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_PARSER_H 24 | #define _VRRP_PARSER_H 25 | 26 | /* local include */ 27 | #include "vector.h" 28 | 29 | /* Prototypes */ 30 | extern vector_t *vrrp_init_keywords(void); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/check_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: check_parser.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _CHECK_PARSER_H 24 | #define _CHECK_PARSER_H 25 | 26 | /* local include */ 27 | #include "vector.h" 28 | 29 | /* Prototypes */ 30 | extern vector_t *check_init_keywords(void); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tools/ipvsadm/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Sample debian/rules that uses debhelper. 3 | # GNU copyright 1997 to 1999 by Joey Hess. 4 | 5 | export DH_COMPAT=2 6 | 7 | pwd:=$(shell pwd) 8 | cfg:= 9 | 10 | build: build-stamp 11 | build-stamp: 12 | dh_testdir 13 | 14 | #test -x autogen.sh && ./autogen.sh $(cfg) || ./configure $(cfg) 15 | 16 | $(MAKE) 17 | 18 | touch build-stamp 19 | 20 | clean: 21 | dh_testdir 22 | dh_testroot 23 | rm -f build-stamp 24 | 25 | -$(MAKE) distclean 26 | 27 | dh_clean 28 | 29 | install: build 30 | dh_testdir 31 | dh_testroot 32 | dh_clean -k 33 | dh_installdirs 34 | 35 | BUILD_ROOT=$(pwd)/debian/tmp make install 36 | 37 | [ ! -d $(pwd)/debian/tmp/etc/init.d/ ] && \ 38 | mkdir -p $(pwd)/debian/tmp/etc/init.d/ 39 | install -c -m 755 ipvsadm.sh $(pwd)/debian/tmp/etc/init.d/ipvsadm 40 | 41 | dh_movefiles --source=debian/tmp 42 | 43 | binary-indep: build install 44 | 45 | binary-arch: build install 46 | dh_testversion 2.0 47 | dh_testdir 48 | dh_testroot 49 | dh_installdocs 50 | dh_installchangelogs 51 | dh_link 52 | dh_strip 53 | dh_compress 54 | dh_fixperms 55 | dh_suidregister 56 | dh_makeshlibs 57 | dh_installdeb 58 | dh_shlibdeps 59 | dh_gencontrol 60 | dh_md5sums 61 | dh_builddeb 62 | 63 | binary: binary-indep binary-arch 64 | .PHONY: build clean binary-indep binary-arch binary install 65 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.virtual_server_group: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | virtual_server_group VSG_1 { 14 | 10.0.0.1 8080 15 | 10.0.0.2 80 16 | 192.168.200.1 1358 17 | 192.168.200.3-10 80 18 | fwmark 1 19 | fwmark 2 20 | } 21 | 22 | virtual_server group VSG_1 { 23 | delay_loop 6 24 | lb_algo rr 25 | lb_kind NAT 26 | persistence_timeout 50 27 | protocol TCP 28 | 29 | real_server 192.168.200.1 1358 { 30 | weight 1 31 | HTTP_GET { 32 | url { 33 | path /testurl3/test.jsp 34 | digest 640205b7b0fc66c1ea91c463fac6334d 35 | } 36 | connect_timeout 3 37 | nb_get_retry 3 38 | delay_before_retry 3 39 | } 40 | } 41 | 42 | real_server 192.168.200.2 1358 { 43 | weight 1 44 | HTTP_GET { 45 | url { 46 | path /testurl3/test.jsp 47 | digest 640205b7b0fc66c1ea91c463fac6334d 48 | } 49 | connect_timeout 3 50 | nb_get_retry 3 51 | delay_before_retry 3 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /include/ipvs/laddr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_LADDR_H__ 19 | #define __DPVS_LADDR_H__ 20 | #include "common.h" 21 | #include "ipvs/conn.h" 22 | #include "ipvs/service.h" 23 | 24 | int dp_vs_laddr_bind(struct dp_vs_conn *conn, struct dp_vs_service *svc); 25 | int dp_vs_laddr_unbind(struct dp_vs_conn *conn); 26 | 27 | int dp_vs_laddr_add(struct dp_vs_service *svc, const union inet_addr *addr, 28 | const char *ifname); 29 | int dp_vs_laddr_del(struct dp_vs_service *svc, const union inet_addr *addr); 30 | int dp_vs_laddr_flush(struct dp_vs_service *svc); 31 | 32 | int dp_vs_laddr_init(void); 33 | int dp_vs_laddr_term(void); 34 | 35 | #endif /* __DPVS_LADDR_H__ */ 36 | -------------------------------------------------------------------------------- /tools/keepalived/lib/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Keepalived OpenSource project. 4 | # 5 | # Copyright (C) 2001-2011 Alexandre Cassen, 6 | 7 | CC = gcc 8 | INCLUDES = -I. 9 | CFLAGS = -g -O2 $(INCLUDES) \ 10 | -Wall -Wunused -Wstrict-prototypes 11 | DEFS = -D_WITHOUT_SNMP_ 12 | COMPILE = $(CC) $(CFLAGS) $(DEFS) 13 | 14 | OBJS = memory.o utils.o notify.o timer.o scheduler.o \ 15 | vector.o list.o html.o parser.o signals.o logger.o \ 16 | list_head.o buffer.o command.o vty.o 17 | HEADERS = $(OBJS:.o=.h) 18 | 19 | .c.o: 20 | $(COMPILE) -c $< 21 | 22 | all: $(OBJS) 23 | 24 | clean: 25 | rm -f *.a *.o *~ 26 | 27 | distclean: clean 28 | rm -f config.h 29 | rm -f Makefile 30 | 31 | memory.o: memory.c memory.h utils.h 32 | utils.o: utils.c utils.h 33 | notify.o: notify.c notify.h 34 | timer.o: timer.c timer.h 35 | scheduler.o: scheduler.c scheduler.h memory.h utils.h 36 | vector.o: vector.c vector.h memory.h 37 | list.o: list.c list.h memory.h 38 | html.o: html.c html.h memory.h 39 | parser.o: parser.c parser.h memory.h 40 | signals.o: signals.c signals.h 41 | logger.o: logger.c logger.h 42 | list_head.o: list_head.c list_head.h 43 | buffer.o: buffer.c buffer.h memory.h 44 | command.o: command.c command.h vector.h memory.h vty.h timer.h \ 45 | config.h logger.h 46 | vty.o: vty.c vty.h scheduler.h timer.h utils.h command.h logger.h \ 47 | memory.h 48 | -------------------------------------------------------------------------------- /tools/keepalived/lib/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Keepalived OpenSource project. 4 | # 5 | # Copyright (C) 2001-2011 Alexandre Cassen, 6 | 7 | CC = @CC@ 8 | INCLUDES = -I. 9 | CFLAGS = @CFLAGS@ $(INCLUDES) \ 10 | -Wall -Wunused -Wstrict-prototypes 11 | DEFS = @DFLAGS@ -D@SNMP_SUPPORT@ 12 | COMPILE = $(CC) $(CFLAGS) $(DEFS) 13 | 14 | OBJS = memory.o utils.o notify.o timer.o scheduler.o \ 15 | vector.o list.o html.o parser.o signals.o logger.o \ 16 | list_head.o buffer.o command.o vty.o 17 | HEADERS = $(OBJS:.o=.h) 18 | 19 | .c.o: 20 | $(COMPILE) -c $< 21 | 22 | all: $(OBJS) 23 | 24 | clean: 25 | rm -f *.a *.o *~ 26 | 27 | distclean: clean 28 | rm -f config.h 29 | rm -f Makefile 30 | 31 | memory.o: memory.c memory.h utils.h 32 | utils.o: utils.c utils.h 33 | notify.o: notify.c notify.h 34 | timer.o: timer.c timer.h 35 | scheduler.o: scheduler.c scheduler.h memory.h utils.h 36 | vector.o: vector.c vector.h memory.h 37 | list.o: list.c list.h memory.h 38 | html.o: html.c html.h memory.h 39 | parser.o: parser.c parser.h memory.h 40 | signals.o: signals.c signals.h 41 | logger.o: logger.c logger.h 42 | list_head.o: list_head.c list_head.h 43 | buffer.o: buffer.c buffer.h memory.h 44 | command.o: command.c command.h vector.h memory.h vty.h timer.h \ 45 | config.h logger.h 46 | vty.o: vty.c vty.h scheduler.h timer.h utils.h command.h logger.h \ 47 | memory.h 48 | -------------------------------------------------------------------------------- /tools/keepalived/lib/html.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Perform a GET query to a remote HTTP/HTTPS server. 3 | * Set a timer to compute global remote server response 4 | * time. 5 | * 6 | * Part: parser.c include file. 7 | * 8 | * Authors: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _HTML_H 24 | #define _HTML_H 25 | 26 | /* HTTP header tag */ 27 | #define CONTENT_LENGTH "Content-Length:" 28 | 29 | /* Prototypes */ 30 | extern int extract_content_length(char *buffer, int size); 31 | extern int extract_status_code(char *buffer, int size); 32 | extern char *extract_html(char *buffer, int size_buffer); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tools/keepalived/lib/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: Global configuration elements. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | #ifndef _CONFIG_H 23 | #define _CONFIG_H 24 | 25 | #define LOG_FACILITY_MAX 7 26 | #define PROG "Keepalived" 27 | #define VERSION_STRING PROG" v1.2.13 (03/01,2018)\n" 28 | #define COPYRIGHT_STRING "Copyright (C) 2001-2012 Alexandre Cassen, " 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.vrrp.lvs_syncd: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | vrrp_sync_group VG1 { 4 | VI_2 5 | VI_3 6 | } 7 | 8 | vrrp_instance VI_1 { 9 | state MASTER 10 | interface eth0 11 | lvs_sync_daemon_interface eth1 12 | virtual_router_id 51 13 | priority 150 14 | advert_int 1 15 | authentication { 16 | auth_type PASS 17 | auth_pass grr02 18 | } 19 | virtual_ipaddress { 20 | 192.168.200.16 21 | 192.168.200.17 22 | 192.168.200.18 23 | } 24 | } 25 | 26 | vrrp_instance VI_2 { 27 | interface eth0 28 | virtual_router_id 52 29 | priority 100 30 | advert_int 1 31 | virtual_ipaddress { 32 | 192.168.200.19 33 | 192.168.200.20 34 | 192.168.200.21 35 | } 36 | } 37 | 38 | vrrp_instance VI_3 { 39 | interface eth1 40 | virtual_router_id 53 41 | priority 100 42 | advert_int 1 43 | virtual_ipaddress { 44 | 192.168.201.19 45 | 192.168.201.20 46 | 192.168.201.21 47 | } 48 | } 49 | 50 | virtual_server 192.168.200.19 80 { 51 | delay_loop 20 52 | lb_algo rr 53 | lb_kind NAT 54 | nat_mask 255.255.255.0 55 | persistence_timeout 50 56 | protocol TCP 57 | 58 | real_server 192.168.201.100 80 { 59 | weight 1 60 | TCP_CHECK { 61 | connect_timeout 3 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /include/conf/neigh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_ROUTE_CONF_H__ 19 | #define __DPVS_ROUTE_CONF_H__ 20 | 21 | #include 22 | #include 23 | 24 | enum { 25 | /* get */ 26 | SOCKOPT_GET_NEIGH_SHOW = 600, 27 | 28 | /* set */ 29 | SOCKOPT_SET_NEIGH_ADD, 30 | SOCKOPT_SET_NEIGH_DEL, 31 | }; 32 | 33 | struct dp_vs_neigh_conf { 34 | int af; 35 | uint8_t flag; 36 | union inet_addr ip_addr; 37 | struct ether_addr eth_addr; 38 | uint32_t que_num; 39 | char ifname[IFNAMSIZ]; 40 | }__attribute__((__packed__)); 41 | 42 | struct dp_vs_neigh_conf_array { 43 | int n_neigh; 44 | struct dp_vs_neigh_conf addrs[0]; 45 | }__attribute__((__packed__)); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /tools/keepalived/lib/config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: Global configuration elements. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | #ifndef _CONFIG_H 23 | #define _CONFIG_H 24 | 25 | #define LOG_FACILITY_MAX 7 26 | #define PROG "Keepalived" 27 | #define VERSION_STRING PROG" v@VERSION@ (@VERSION_DATE@)\n" 28 | #define COPYRIGHT_STRING "Copyright (C) 2001-2012 Alexandre Cassen, " 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.vrrp.scripts: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | ! extra script call demonstration 3 | ! scripts are supported in Instance and groupes 4 | ! declarations. 5 | 6 | vrrp_sync_group G1 { 7 | group { 8 | VI_2 9 | VI_3 10 | } 11 | notify_backup "/usr/local/bin/vrrp.back arg1 arg2" 12 | notify_master "/usr/local/bin/vrrp.mast arg1 arg2" 13 | notify_fault "/usr/local/bin/vrrp.fault arg1 arg2" 14 | } 15 | 16 | vrrp_instance VI_1 { 17 | state MASTER 18 | interface eth0 19 | smtp_alert 20 | virtual_router_id 51 21 | priority 100 22 | advert_int 1 23 | authentication { 24 | auth_type PASS 25 | auth_pass 1111 26 | } 27 | virtual_ipaddress { 28 | 192.168.200.16 29 | 192.168.200.17 30 | 192.168.200.18 31 | } 32 | notify_backup "/usr/local/bin/vrrp.sh BACKUP VI_1" 33 | notify_master "/usr/local/bin/vrrp.sh MASTER VI_1" 34 | notify_fault "/usr/local/bin/vrrp.sh FAULT VI_1" 35 | } 36 | 37 | 38 | vrrp_instance VI_2 { 39 | interface eth0 40 | state MASTER 41 | virtual_router_id 52 42 | priority 150 43 | virtual_ipaddress { 44 | 192.168.200.100/27 45 | } 46 | } 47 | 48 | vrrp_instance VI_3 { 49 | interface eth0 50 | state MASTER 51 | virtual_router_id 53 52 | priority 150 53 | virtual_ipaddress { 54 | 192.168.200.101/27 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_notify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Vrrpd is an implementation of VRRPv2 as specified in rfc2338. 3 | * VRRP is a protocol which elect a master server on a LAN. If the 4 | * master fails, a backup server takes over. 5 | * The original implementation has been made by jerome etienne. 6 | * 7 | * Part: vrrp_notify.c include file. 8 | * 9 | * Author: Alexandre Cassen, 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * This program is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 19 | * 2 of the License, or (at your option) any later version. 20 | * 21 | * Copyright (C) 2001-2012 Alexandre Cassen, 22 | */ 23 | 24 | #ifndef _VRRP_NOTIFY_H 25 | #define _VRRP_NOTIFY_H 26 | 27 | /* local include */ 28 | #include "vrrp.h" 29 | 30 | extern int notify_instance_exec(vrrp_t *, int); 31 | extern int notify_group_exec(vrrp_sgroup_t *, int); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/ssl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Perform a GET query to a remote HTTP/HTTPS server. 3 | * Set a timer to compute global remote server response 4 | * time. 5 | * 6 | * Part: ssl.c include file. 7 | * 8 | * Version: $Id: ssl.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $ 9 | * 10 | * Authors: Alexandre Cassen, 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the GNU General Public License for more details. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 20 | * 2 of the License, or (at your option) any later version. 21 | * 22 | * Copyright (C) 2001-2012 Alexandre Cassen, 23 | */ 24 | 25 | #ifndef _SSL_H 26 | #define _SSL_H 27 | 28 | #include 29 | 30 | /* Prototypes */ 31 | extern void init_ssl(void); 32 | extern int ssl_connect(thread_t *); 33 | extern int ssl_printerr(int); 34 | extern int ssl_send_request(SSL *, char *, int); 35 | extern int ssl_read_thread(thread_t *); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tools/dpip/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPIP_UTILS_H__ 19 | #define __DPIP_UTILS_H__ 20 | #include "inet.h" 21 | 22 | #define __init __attribute__((constructor)) 23 | #define __exit __attribute__((destructor)) 24 | 25 | #define NEXTARG(c) ((c)->argc--, (c)->argv++) 26 | 27 | #define NEXTARG_CHECK(c, m) do { \ 28 | NEXTARG((c)); \ 29 | if ((c)->argc <= 0) { \ 30 | fprintf(stderr, "missing argument for `%s'\n", (m)); \ 31 | return -1; \ 32 | } \ 33 | } while (0) 34 | 35 | #define CURRARG(c) ((c)->argv[0]) 36 | 37 | const char *af_itoa(int af); 38 | 39 | bool inet_is_addr_any(int af, const union inet_addr *addr); 40 | int inet_pton_try(int *af, const char *src, union inet_addr *dst); 41 | 42 | #endif /* __DPIP_UTILS_H__ */ 43 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: Daemon process handling. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _DAEMON_H 24 | #define _DAEMON_H 25 | 26 | /* System includes */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | /* prototype */ 37 | extern pid_t xdaemon(int, int, int); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_daemon.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_DAEMON_H 24 | #define _VRRP_DAEMON_H 25 | 26 | /* system include */ 27 | #include 28 | #include 29 | 30 | /* Daemon define */ 31 | #define PROG_VRRP "Keepalived_vrrp" 32 | #define WDOG_VRRP "/tmp/.vrrp" 33 | 34 | /* Prototypes */ 35 | extern int start_vrrp_child(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/check_daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: check_daemon.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _CHECK_DAEMON_H 24 | #define _CHECK_DAEMON_H 25 | 26 | /* system include */ 27 | #include 28 | #include 29 | 30 | /* Daemon define */ 31 | #define PROG_CHECK "Keepalived_healthcheckers" 32 | #define WDOG_CHECK "/tmp/.healthcheckers" 33 | 34 | /* Prototypes */ 35 | extern int start_check_child(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/check_tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: check_tcp.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _CHECK_TCP_H 24 | #define _CHECK_TCP_H 25 | 26 | /* system includes */ 27 | #include 28 | #include 29 | #include 30 | 31 | /* local includes */ 32 | #include "scheduler.h" 33 | 34 | /* macro utility */ 35 | #define FMT_TCP_RS(C) FMT_CHK(C) 36 | 37 | /* Prototypes defs */ 38 | extern void install_tcp_check_keyword(void); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/parser/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __UTILS_H__ 19 | #define __UTILS_H__ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #define MALLOC(sz) (xmalloc(sz)) 27 | #define FREE(p) (xfree(p)) 28 | #define REALLOC(p, sz) (xrealloc((p), (sz))) 29 | #define FREE_PTR(p) if((p)) FREE((p)) 30 | 31 | static inline void* xmalloc(uint32_t sz) 32 | { 33 | void *mem = rte_zmalloc("cfgfile", sz, RTE_CACHE_LINE_SIZE); 34 | if (mem) 35 | memset(mem, 0, sz); 36 | 37 | return mem; 38 | } 39 | 40 | static inline void* xrealloc(void *p, uint32_t sz) 41 | { 42 | return rte_realloc(p, sz, RTE_CACHE_LINE_SIZE); 43 | } 44 | 45 | static inline void xfree(void *p) 46 | { 47 | rte_free(p); 48 | p = NULL; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /tools/qnatsh/Makefile: -------------------------------------------------------------------------------- 1 | top_srcdir=.. 2 | LIBDIR = ../lib 3 | INCDIR = . 4 | LIBZ = ./lib 5 | INCDIR_COM = ../include 6 | 7 | targets=qnatsh 8 | 9 | CC = gcc 10 | CFLAGS = -Wall -rdynamic -g #-O2 11 | CFLAGS += -Wno-unused -Wno-missing-braces #-Wno-unused-function 12 | DEFS = -DHAVE_CONFIG_H 13 | 14 | INCZEBRA = $(INCDIR)/lib 15 | INCPFLOW = $(INCDIR_COM)/pflow 16 | INCLUDE = -I$(INCZEBRA) -I. -I$(INCPFLOW) 17 | LIBS = -L$(LIBDIR) -L$(LIBZ) -lreadline -lm -lpthread 18 | ZEBRA_LIBS = -lrt -lcrypt 19 | all: $(targets) 20 | 21 | deps_objs= \ 22 | nsh_config.o \ 23 | nsh_main.o \ 24 | nsh_user.o \ 25 | nsh_cmd.o \ 26 | nsh_serv.o \ 27 | msg.o \ 28 | nsh.o \ 29 | ${LIBZ}/command.o \ 30 | ${LIBZ}/linklist.o \ 31 | ${LIBZ}/log.o \ 32 | ${LIBZ}/memory.o \ 33 | ${LIBZ}/memtypes.o \ 34 | ${LIBZ}/prefix.o \ 35 | ${LIBZ}/str.o \ 36 | ${LIBZ}/vector.o \ 37 | ${LIBZ}/vty.o \ 38 | ${LIBZ}/buffer.o \ 39 | ${LIBZ}/sockunion.o \ 40 | ${LIBZ}/privs.o \ 41 | ${LIBZ}/network.o \ 42 | ${LIBZ}/filter.o \ 43 | ${LIBZ}/md5.o \ 44 | 45 | deps_libs= 46 | 47 | .c.o: 48 | $(CC) -c $(CFLAGS) ${DEFS} $(INCLUDE) $< -o $@ 49 | 50 | $(targets): $(deps_objs) $(deps_libs) 51 | ${CC} -o $@ $^ ${CFLAGS} ${DEFS} $(LIBS) $(ZEBRA_LIBS) 52 | 53 | clean: 54 | -rm -f $(targets) $(deps_objs) 55 | 56 | .PHONY: all clean install 57 | -------------------------------------------------------------------------------- /tools/keepalived/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Keepalived OpenSource project. 4 | # 5 | # Copyright (C) 2001-2012 Alexandre Cassen, 6 | 7 | TARFILES = AUTHOR bin ChangeLog configure configure.in CONTRIBUTORS COPYING \ 8 | doc genhash INSTALL install-sh keepalived keepalived.spec.in lib Makefile.in \ 9 | README TODO VERSION 10 | 11 | TARBALL = keepalived-1.2.13.tar.gz 12 | 13 | all: 14 | $(MAKE) -C lib || exit 1; 15 | $(MAKE) -C keepalived 16 | $(MAKE) -C genhash 17 | @echo "" 18 | @echo "Make complete" 19 | 20 | debug: 21 | $(MAKE) -C lib || exit 1; 22 | $(MAKE) -C keepalived debug 23 | @echo "" 24 | @echo "Make complete" 25 | 26 | profile: 27 | $(MAKE) -C lib || exit 1; 28 | $(MAKE) -C keepalived profile 29 | @echo "" 30 | @echo "Make complete" 31 | 32 | clean: 33 | $(MAKE) -C lib clean 34 | $(MAKE) -C keepalived clean 35 | $(MAKE) -C genhash clean 36 | 37 | distclean: 38 | $(MAKE) -C lib distclean 39 | $(MAKE) -C keepalived distclean 40 | $(MAKE) -C genhash distclean 41 | rm -f Makefile 42 | rm -f keepalived.spec 43 | 44 | mrproper: distclean 45 | rm -f config.* 46 | 47 | uninstall: 48 | $(MAKE) -C keepalived uninstall 49 | $(MAKE) -C genhash uninstall 50 | 51 | install: 52 | $(MAKE) -C keepalived install 53 | $(MAKE) -C genhash install 54 | 55 | tarball: mrproper 56 | mkdir keepalived-1.2.13 57 | cp -a $(TARFILES) keepalived-1.2.13 58 | tar --exclude .git -czf $(TARBALL) keepalived-1.2.13 59 | rm -rf keepalived-1.2.13 60 | 61 | rpm: 62 | rpmbuild -ba keepalived.spec 63 | -------------------------------------------------------------------------------- /include/ipvs/blklst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_BLKLST_H__ 19 | #define __DPVS_BLKLST_H__ 20 | #include "common.h" 21 | #include "ipvs/service.h" 22 | #include "timer.h" 23 | 24 | struct blklst_entry { 25 | struct list_head list; 26 | union inet_addr vaddr; 27 | union inet_addr blklst; 28 | struct dpvs_timer timer; 29 | rte_atomic32_t refcnt; 30 | }; 31 | 32 | static inline void blklst_put(struct blklst_entry *blklst_node) 33 | { 34 | rte_atomic32_dec(&blklst_node->refcnt); 35 | } 36 | 37 | struct blklst_entry *dp_vs_blklst_lookup(const union inet_addr *vaddr, 38 | const union inet_addr *blklst); 39 | void dp_vs_blklst_flush(struct dp_vs_service *svc); 40 | 41 | int dp_vs_blklst_init(void); 42 | int dp_vs_blklst_term(void); 43 | 44 | #endif /* __DPVS_BLKLST_H__ */ 45 | -------------------------------------------------------------------------------- /tools/keepalived/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Keepalived OpenSource project. 4 | # 5 | # Copyright (C) 2001-2012 Alexandre Cassen, 6 | 7 | TARFILES = AUTHOR bin ChangeLog configure configure.in CONTRIBUTORS COPYING \ 8 | doc genhash INSTALL install-sh keepalived keepalived.spec.in lib Makefile.in \ 9 | README TODO VERSION 10 | 11 | TARBALL = keepalived-@VERSION@.tar.gz 12 | 13 | all: 14 | $(MAKE) -C lib || exit 1; 15 | $(MAKE) -C keepalived 16 | $(MAKE) -C genhash 17 | @echo "" 18 | @echo "Make complete" 19 | 20 | debug: 21 | $(MAKE) -C lib || exit 1; 22 | $(MAKE) -C keepalived debug 23 | @echo "" 24 | @echo "Make complete" 25 | 26 | profile: 27 | $(MAKE) -C lib || exit 1; 28 | $(MAKE) -C keepalived profile 29 | @echo "" 30 | @echo "Make complete" 31 | 32 | clean: 33 | $(MAKE) -C lib clean 34 | $(MAKE) -C keepalived clean 35 | $(MAKE) -C genhash clean 36 | 37 | distclean: 38 | $(MAKE) -C lib distclean 39 | $(MAKE) -C keepalived distclean 40 | $(MAKE) -C genhash distclean 41 | rm -f Makefile 42 | rm -f keepalived.spec 43 | 44 | mrproper: distclean 45 | rm -f config.* 46 | 47 | uninstall: 48 | $(MAKE) -C keepalived uninstall 49 | $(MAKE) -C genhash uninstall 50 | 51 | install: 52 | $(MAKE) -C keepalived install 53 | $(MAKE) -C genhash install 54 | 55 | tarball: mrproper 56 | mkdir keepalived-@VERSION@ 57 | cp -a $(TARFILES) keepalived-@VERSION@ 58 | tar --exclude .git -czf $(TARBALL) keepalived-@VERSION@ 59 | rm -rf keepalived-@VERSION@ 60 | 61 | rpm: 62 | rpmbuild -ba keepalived.spec 63 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.6/sockopt.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define SOCKOPT_VERSION_MAJOR 1 7 | #define SOCKOPT_VERSION_MINOR 0 8 | #define SOCKOPT_VERSION_PATCH 0 9 | #define SOCKOPT_VERSION ((SOCKOPT_VERSION_MAJOR << 16) + \ 10 | (SOCKOPT_VERSION_MINOR << 8) + SOCKOPT_VERSION_PATCH) 11 | 12 | #define SOCKOPT_MSG_BUFFER_SIZE (1UL << 12) 13 | #define SOCKOPT_ERRSTR_LEN 64 14 | 15 | enum { 16 | ESOCKOPT_INVAL = -16385, 17 | ESOCKOPT_IO, 18 | ESOCKOPT_NOMEM, 19 | ESOCKOPT_VERSION, 20 | ESOCKOPT_UNKOWN = 65535, 21 | ESOCKOPT_OK = 0, 22 | }; 23 | 24 | typedef uint32_t sockoptid_t; 25 | 26 | enum sockopt_type { 27 | SOCKOPT_GET = 0, 28 | SOCKOPT_SET, 29 | SOCKOPT_TYPE_MAX, 30 | }; 31 | 32 | struct dpvs_sock_msg { 33 | uint32_t version; 34 | sockoptid_t id; 35 | enum sockopt_type type; 36 | size_t len; 37 | char data[0]; 38 | }; 39 | 40 | struct dpvs_sock_msg_reply { 41 | uint32_t version; 42 | sockoptid_t id; 43 | enum sockopt_type type; 44 | int errcode; 45 | char errstr[SOCKOPT_ERRSTR_LEN]; 46 | size_t len; 47 | char data[0]; 48 | }; 49 | 50 | int dpvs_setsockopt(sockoptid_t cmd, const void *in, size_t in_len); 51 | int dpvs_getsockopt(sockoptid_t cmd, const void *in, size_t in_len, 52 | void **out, size_t *out_len); 53 | 54 | static inline void dpvs_sockopt_msg_free(void *msg) 55 | { 56 | free(msg); 57 | msg = NULL; 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /include/conf/vlan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_VLAN_CONF_H__ 19 | #define __DPVS_VLAN_CONF_H__ 20 | #include 21 | #include 22 | #include "vlan.h" 23 | 24 | enum { 25 | /* set */ 26 | SOCKOPT_SET_VLAN_ADD = 800, 27 | SOCKOPT_SET_VLAN_DEL, 28 | 29 | /* get */ 30 | SOCKOPT_GET_VLAN_SHOW, 31 | }; 32 | 33 | struct vlan_param { 34 | char real_dev[IFNAMSIZ]; /* underlying device name */ 35 | char ifname[IFNAMSIZ]; /* vlan device name, e.g., dpdk0.100 36 | leave it empty auto-generate when add. */ 37 | uint16_t vlan_proto; /* ETH_P_8021Q ... */ 38 | uint16_t vlan_id; /* host byte order */ 39 | } __attribute__((__packed__)); 40 | 41 | struct vlan_param_array { 42 | int nparam; 43 | struct vlan_param params[0]; 44 | }; 45 | 46 | #endif /* __DPVS_VLAN_CONF_H__ */ 47 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Network library header. 3 | * Copyright (C) 1998 Kunihiro Ishiguro 4 | * 5 | * This file is part of GNU Zebra. 6 | * 7 | * GNU Zebra is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2, or (at your option) any 10 | * later version. 11 | * 12 | * GNU Zebra is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 | * 02111-1307, USA. 21 | */ 22 | 23 | #ifndef _ZEBRA_NETWORK_H 24 | #define _ZEBRA_NETWORK_H 25 | 26 | /* Both readn and writen are deprecated and will be removed. They are not 27 | suitable for use with non-blocking file descriptors. 28 | */ 29 | extern int readn (int, u_char *, int); 30 | extern int writen (int, const u_char *, int); 31 | 32 | /* Set the file descriptor to use non-blocking I/O. Returns 0 for success, 33 | -1 on error. */ 34 | extern int set_nonblocking(int fd); 35 | 36 | /* Does the I/O error indicate that the operation should be retried later? */ 37 | #define ERRNO_IO_RETRY(EN) \ 38 | (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR)) 39 | 40 | #endif /* _ZEBRA_NETWORK_H */ 41 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/etc/init.d/keepalived.rh.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Startup script for the Keepalived daemon 4 | # 5 | # processname: keepalived 6 | # pidfile: /var/run/keepalived.pid 7 | # config: /etc/keepalived/keepalived.conf 8 | # chkconfig: 35 21 79 9 | # description: Start and stop Keepalived 10 | 11 | # Global definitions 12 | PID_FILE="/var/run/keepalived.pid" 13 | 14 | # source function library 15 | . /etc/init.d/functions 16 | 17 | RETVAL=0 18 | 19 | start() { 20 | echo -n "Starting Keepalived for LVS: " 21 | daemon keepalived -D 22 | RETVAL=$? 23 | echo 24 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/keepalived 25 | return $RETVAL 26 | } 27 | 28 | stop() { 29 | echo -n "Shutting down Keepalived for LVS: " 30 | killproc keepalived 31 | RETVAL=0 32 | echo 33 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/keepalived 34 | return $RETVAL 35 | } 36 | 37 | reload() { 38 | echo -n "Reloading Keepalived config: " 39 | killproc keepalived -1 40 | RETVAL=$? 41 | echo 42 | return $RETVAL 43 | } 44 | 45 | # See how we were called. 46 | case "$1" in 47 | start) 48 | start 49 | ;; 50 | stop) 51 | stop 52 | ;; 53 | restart) 54 | stop 55 | start 56 | ;; 57 | reload) 58 | reload 59 | ;; 60 | status) 61 | status keepalived 62 | ;; 63 | condrestart) 64 | [ -f /var/lock/subsys/keepalived ] && $0 restart || : 65 | ;; 66 | *) 67 | echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" 68 | exit 1 69 | esac 70 | 71 | exit 0 72 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/check_ssl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: check_http.c include file. 7 | * 8 | * Authors: Alexandre Cassen, 9 | * Jan Holmberg, 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * This program is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 19 | * 2 of the License, or (at your option) any later version. 20 | * 21 | * Copyright (C) 2001-2012 Alexandre Cassen, 22 | */ 23 | 24 | #ifndef _CHECK_SSL_H 25 | #define _CHECK_SSL_H 26 | 27 | /* local includes */ 28 | #include "check_http.h" 29 | 30 | /* Prototypes */ 31 | extern void install_ssl_check_keyword(void); 32 | extern int init_ssl_ctx(void); 33 | extern void clear_ssl(ssl_data_t *); 34 | extern int ssl_connect(thread_t *, int); 35 | extern int ssl_printerr(int); 36 | extern int ssl_send_request(SSL *, char *, int); 37 | extern int ssl_read_thread(thread_t *); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/version.h: -------------------------------------------------------------------------------- 1 | /* lib/version.h. Generated from version.h.in by configure. 2 | * 3 | * Quagga version 4 | * Copyright (C) 1997, 1999 Kunihiro Ishiguro 5 | * 6 | * This file is part of GNU Zebra. 7 | * 8 | * GNU Zebra is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2, or (at your option) any 11 | * later version. 12 | * 13 | * GNU Zebra is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Zebra; see the file COPYING. If not, write to the Free 20 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 21 | * 02111-1307, USA. 22 | */ 23 | 24 | #ifndef _ZEBRA_VERSION_H 25 | #define _ZEBRA_VERSION_H 26 | 27 | //#define QUAGGA_PROGNAME "Quagga" 28 | #define QUAGGA_PROGNAME "nsh" 29 | 30 | //#define QUAGGA_VERSION "0.99.17" 31 | #define QUAGGA_VERSION "0.1.1" 32 | 33 | #define ZEBRA_BUG_ADDRESS "https://bugzilla.quagga.net" 34 | 35 | #define QUAGGA_URL "http://www.quagga.net" 36 | 37 | //#define QUAGGA_COPYRIGHT "Copyright 1996-2005 Kunihiro Ishiguro, et al." 38 | #define QUAGGA_COPYRIGHT "Copyright xxxx-xxxx xxxx." 39 | 40 | pid_t pid_output (const char *); 41 | 42 | #ifndef HAVE_DAEMON 43 | int daemon(int, int); 44 | #endif 45 | 46 | #endif /* _ZEBRA_VERSION_H */ 47 | -------------------------------------------------------------------------------- /tools/keepalived/lib/signals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: signals.c include file. 7 | * 8 | * Author: Kevin Lindsay, 9 | * Alexandre Cassen, 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * This program is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 19 | * 2 of the License, or (at your option) any later version. 20 | * 21 | * Copyright (C) 2001-2012 Alexandre Cassen, 22 | */ 23 | 24 | #ifndef _SIGNALS_H 25 | #define _SIGNALS_H 26 | 27 | /* Prototypes */ 28 | extern int signal_pending(void); 29 | extern void *signal_set(int signo, void (*func) (void *, int), void *); 30 | extern void *signal_ignore(int signo); 31 | extern void signal_handler_init(void); 32 | extern void signal_handler_destroy(void); 33 | extern void signal_reset(void); 34 | extern void signal_run_callback(void); 35 | extern void signal_wait_handlers(void); 36 | 37 | extern int signal_rfd(void); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/check_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: check_misc.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * Eric Jarman, 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * This program is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 19 | * 2 of the License, or (at your option) any later version. 20 | * 21 | * Copyright (C) 2001-2012 Alexandre Cassen, 22 | */ 23 | 24 | #ifndef _CHECK_MISC_H 25 | #define _CHECK_MISC_H 26 | 27 | /* system includes */ 28 | #include 29 | 30 | /* local includes */ 31 | #include "scheduler.h" 32 | 33 | /* Checker argument structure */ 34 | typedef struct _misc_checker { 35 | char *path; 36 | long timeout; 37 | int dynamic; /* 0: old-style, 1: exit code from checker affects weight */ 38 | } misc_checker_t; 39 | 40 | /* Prototypes defs */ 41 | extern void install_misc_check_keyword(void); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/core/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Keepalived OpenSource project. 4 | # 5 | # Copyright (C) 2001-2012 Alexandre Cassen, 6 | 7 | CC = @CC@ 8 | SNMP_FLAG = @SNMP_SUPPORT@ 9 | INCLUDES = -I../include -I../../lib 10 | CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \ 11 | -Wall -Wunused -Wstrict-prototypes 12 | CFLAGS += -I ../../../../include 13 | DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ -D@SO_MARK_SUPPORT@ @DFLAGS@ 14 | COMPILE = $(CC) $(CFLAGS) $(DEFS) 15 | 16 | OBJS = main.o daemon.o pidfile.o layer4.o smtp.o \ 17 | global_data.o global_parser.o 18 | ifeq ($(SNMP_FLAG),_WITH_SNMP_) 19 | OBJS += snmp.o 20 | endif 21 | HEADERS = $(OBJS:.o=.h) 22 | 23 | .c.o: 24 | $(COMPILE) -c $< 25 | 26 | all: $(OBJS) 27 | 28 | clean: 29 | rm -f *.a *.o *~ 30 | 31 | distclean: clean 32 | rm -f Makefile 33 | 34 | 35 | main.o: main.c ../include/main.h ../../lib/config.h ../../lib/signals.h 36 | daemon.o: daemon.c ../include/daemon.h ../../lib/utils.h 37 | pidfile.o: pidfile.c ../include/pidfile.h 38 | layer4.o: layer4.c ../include/layer4.h ../include/check_api.h ../../lib/utils.h 39 | smtp.o: smtp.c ../include/smtp.h ../include/global_data.h ../../lib/memory.h \ 40 | ../../lib/list.h ../../lib/utils.h 41 | global_data.o: global_data.c ../include/global_data.h ../../lib/memory.h \ 42 | ../../lib/list.h ../../lib/utils.h 43 | global_parser.o: global_parser.c ../include/global_parser.h \ 44 | ../include/global_data.h ../../lib/parser.h ../../lib/memory.h \ 45 | ../../lib/utils.h 46 | snmp.o: snmp.c ../include/snmp.h ../../lib/logger.h ../../lib/list.h \ 47 | ../../lib/config.h ../include/global_data.h 48 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/etc/init.d/keepalived.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Startup script for the Keepalived daemon 4 | # 5 | # processname: keepalived 6 | # pidfile: /var/run/keepalived.pid 7 | # config: /etc/keepalived/keepalived.conf 8 | # chkconfig: - 21 79 9 | # description: Start and stop Keepalived 10 | 11 | # Source function library 12 | . /etc/rc.d/init.d/functions 13 | 14 | # Source configuration file (we set KEEPALIVED_OPTIONS there) 15 | . /etc/sysconfig/keepalived 16 | 17 | RETVAL=0 18 | 19 | prog="keepalived" 20 | 21 | start() { 22 | echo -n $"Starting $prog: " 23 | daemon keepalived ${KEEPALIVED_OPTIONS} 24 | RETVAL=$? 25 | echo 26 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog 27 | } 28 | 29 | stop() { 30 | echo -n $"Stopping $prog: " 31 | killproc keepalived 32 | RETVAL=$? 33 | echo 34 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog 35 | } 36 | 37 | reload() { 38 | echo -n $"Reloading $prog: " 39 | killproc keepalived -1 40 | RETVAL=$? 41 | echo 42 | } 43 | 44 | # See how we were called. 45 | case "$1" in 46 | start) 47 | start 48 | ;; 49 | stop) 50 | stop 51 | ;; 52 | reload) 53 | reload 54 | ;; 55 | restart) 56 | stop 57 | start 58 | ;; 59 | condrestart) 60 | if [ -f /var/lock/subsys/$prog ]; then 61 | stop 62 | start 63 | fi 64 | ;; 65 | status) 66 | status keepalived 67 | RETVAL=$? 68 | ;; 69 | *) 70 | echo "Usage: $0 {start|stop|reload|restart|condrestart|status}" 71 | RETVAL=1 72 | esac 73 | 74 | exit $RETVAL 75 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/core/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Keepalived OpenSource project. 4 | # 5 | # Copyright (C) 2001-2012 Alexandre Cassen, 6 | 7 | CC = gcc 8 | SNMP_FLAG = _WITHOUT_SNMP_ 9 | INCLUDES = -I../include -I../../lib 10 | CFLAGS = -g -O2 -I/usr/src/linux/include -I/usr/src/linux/include $(INCLUDES) \ 11 | -Wall -Wunused -Wstrict-prototypes 12 | CFLAGS += -I ../../../../include 13 | DEFS = -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITH_SO_MARK_ 14 | COMPILE = $(CC) $(CFLAGS) $(DEFS) 15 | 16 | OBJS = main.o daemon.o pidfile.o layer4.o smtp.o \ 17 | global_data.o global_parser.o 18 | ifeq ($(SNMP_FLAG),_WITH_SNMP_) 19 | OBJS += snmp.o 20 | endif 21 | HEADERS = $(OBJS:.o=.h) 22 | 23 | .c.o: 24 | $(COMPILE) -c $< 25 | 26 | all: $(OBJS) 27 | 28 | clean: 29 | rm -f *.a *.o *~ 30 | 31 | distclean: clean 32 | rm -f Makefile 33 | 34 | 35 | main.o: main.c ../include/main.h ../../lib/config.h ../../lib/signals.h 36 | daemon.o: daemon.c ../include/daemon.h ../../lib/utils.h 37 | pidfile.o: pidfile.c ../include/pidfile.h 38 | layer4.o: layer4.c ../include/layer4.h ../include/check_api.h ../../lib/utils.h 39 | smtp.o: smtp.c ../include/smtp.h ../include/global_data.h ../../lib/memory.h \ 40 | ../../lib/list.h ../../lib/utils.h 41 | global_data.o: global_data.c ../include/global_data.h ../../lib/memory.h \ 42 | ../../lib/list.h ../../lib/utils.h 43 | global_parser.o: global_parser.c ../include/global_parser.h \ 44 | ../include/global_data.h ../../lib/parser.h ../../lib/memory.h \ 45 | ../../lib/utils.h 46 | snmp.o: snmp.c ../include/snmp.h ../../lib/logger.h ../../lib/list.h \ 47 | ../../lib/config.h ../include/global_data.h 48 | -------------------------------------------------------------------------------- /include/conf/blklst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | /** 19 | * Note: control plane only 20 | * based on dpvs_sockopt. 21 | */ 22 | #ifndef __DPVS_BLKLST_CONF_H__ 23 | #define __DPVS_BLKLST_CONF_H__ 24 | #include "inet.h" 25 | 26 | enum { 27 | /* set */ 28 | SOCKOPT_SET_BLKLST_ADD = 700, 29 | SOCKOPT_SET_BLKLST_DEL, 30 | SOCKOPT_SET_BLKLST_FLUSH, 31 | /* get */ 32 | SOCKOPT_GET_BLKLST_GETALL, 33 | }; 34 | 35 | struct dp_vs_blklst_entry { 36 | union inet_addr addr; 37 | }; 38 | 39 | struct dp_vs_blklst_conf { 40 | /* identify service */ 41 | int af; 42 | uint8_t proto; 43 | union inet_addr vaddr; 44 | uint16_t vport; 45 | uint32_t fwmark; 46 | 47 | /* for set */ 48 | union inet_addr blklst; 49 | }; 50 | 51 | struct dp_vs_blklst_conf_array { 52 | int naddr; 53 | struct dp_vs_blklst_conf blklsts[0]; 54 | } __attribute__((__packed__)); 55 | 56 | #endif /* __DPVS_BLKLST_CONF_H__ */ 57 | -------------------------------------------------------------------------------- /tools/keepalived/lib/logger.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: logging facility. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /* Boolean flag - send messages to console as well as syslog */ 28 | static int log_console = 0; 29 | 30 | void 31 | enable_console_log(void) 32 | { 33 | log_console = 1; 34 | } 35 | 36 | void 37 | log_message(const int facility, const char *format, ...) 38 | { 39 | va_list args; 40 | char buf[256]; 41 | 42 | va_start(args, format); 43 | vsnprintf(buf, sizeof(buf), format, args); 44 | va_end(args); 45 | 46 | if (log_console) { 47 | fprintf(stderr, "%s\n", buf); 48 | } 49 | 50 | syslog(facility, "%s", buf); 51 | } 52 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_index.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_INDEX_H 24 | #define _VRRP_INDEX_H 25 | 26 | /* global includes */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* local includes */ 34 | #include "vrrp.h" 35 | 36 | /* Macro definition */ 37 | 38 | /* prototypes */ 39 | extern void alloc_vrrp_bucket(vrrp_t *); 40 | extern void alloc_vrrp_fd_bucket(vrrp_t *); 41 | extern void remove_vrrp_fd_bucket(vrrp_t *); 42 | extern void set_vrrp_fd_bucket(int, vrrp_t *); 43 | extern vrrp_t *vrrp_index_lookup(const int, const int); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_vmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_vmac.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_VMAC_H 24 | #define _VRRP_VMAC_H 25 | 26 | /* global includes */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | /* local includes */ 35 | #include "vrrp.h" 36 | #include "vrrp_if.h" 37 | 38 | /* Defines */ 39 | #define VRRP_VMAC_FL_SET (1 << 0) 40 | #define VRRP_VMAC_FL_UP (1 << 1) 41 | #define VRRP_VMAC_FL_XMITBASE (1 << 2) 42 | 43 | /* prototypes */ 44 | extern int netlink_link_add_vmac(vrrp_t *); 45 | extern int netlink_link_del_vmac(vrrp_t *); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/kni.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | /** 19 | * DPDK KNI device management. 20 | * 21 | * KNI device should be add/del by request. And any real devices, 22 | * can be attached on. Such as dpdk phy device, dpdk bonding 23 | * device and even virtual vlan device. 24 | * 25 | * raychen@qiyi.com, June 2017, initial. 26 | */ 27 | #ifndef __DPVS_KNI_H__ 28 | #define __DPVS_KNI_H__ 29 | #include 30 | #include "netif.h" 31 | 32 | /* 33 | * @dev - real device kni attach to. 34 | * @kniname - optional, kni device name or auto generate. 35 | */ 36 | int kni_add_dev(struct netif_port *dev, const char *kniname); 37 | 38 | int kni_del_dev(struct netif_port *dev); 39 | int kni_init(void); 40 | 41 | static inline bool kni_dev_exist(const struct netif_port *dev) 42 | { 43 | return dev->kni.kni ? true : false; 44 | } 45 | 46 | static inline void kni_handle_request(const struct netif_port *dev) 47 | { 48 | if (!kni_dev_exist(dev)) 49 | return; 50 | 51 | rte_kni_handle_request(dev->kni.kni); 52 | } 53 | 54 | #endif /* __DPVS_KNI_H__ */ 55 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/readline/rlstdc.h: -------------------------------------------------------------------------------- 1 | /* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */ 2 | 3 | /* Copyright (C) 1993-2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #if !defined (_RL_STDC_H_) 23 | #define _RL_STDC_H_ 24 | 25 | /* Adapted from BSD /usr/include/sys/cdefs.h. */ 26 | 27 | /* A function can be defined using prototypes and compile on both ANSI C 28 | and traditional C compilers with something like this: 29 | extern char *func PARAMS((char *, char *, int)); */ 30 | 31 | #if !defined (PARAMS) 32 | # if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) 33 | # define PARAMS(protos) protos 34 | # else 35 | # define PARAMS(protos) () 36 | # endif 37 | #endif 38 | 39 | #ifndef __attribute__ 40 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) 41 | # define __attribute__(x) 42 | # endif 43 | #endif 44 | 45 | #endif /* !_RL_STDC_H_ */ 46 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/sock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Perform a GET query to a remote HTTP/HTTPS server. 3 | * Set a timer to compute global remote server response 4 | * time. 5 | * 6 | * Part: sock.c include file. 7 | * 8 | * Version: $Id: sock.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $ 9 | * 10 | * Authors: Alexandre Cassen, 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the GNU General Public License for more details. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 20 | * 2 of the License, or (at your option) any later version. 21 | * 22 | * Copyright (C) 2001-2012 Alexandre Cassen, 23 | */ 24 | 25 | #ifndef _SOCK_H 26 | #define _SOCK_H 27 | 28 | /* system includes */ 29 | #include 30 | 31 | /* local includes */ 32 | #include "hash.h" 33 | 34 | /* Engine socket pool element structure */ 35 | typedef struct { 36 | int fd; 37 | SSL *ssl; 38 | BIO *bio; 39 | const hash_t *hash; 40 | hash_context_t context; 41 | int status; 42 | int lock; 43 | char *buffer; 44 | char *extracted; 45 | int size; 46 | int total_size; 47 | } SOCK; 48 | 49 | /* global vars exported */ 50 | extern SOCK *sock; 51 | 52 | /* Prototypes */ 53 | extern void free_sock(SOCK *); 54 | extern void init_sock(void); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/pidfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: pidfile.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _PIDFILE_H 24 | #define _PIDFILE_H 25 | 26 | /* system include */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* lock pidfile */ 34 | #define KEEPALIVED_PID_FILE "/var/run/keepalived.pid" 35 | #define KEEPALIVED_VRRP_PID_FILE "/var/run/keepalived_vrrp.pid" 36 | #define KEEPALIVED_CHECKERS_PID_FILE "/var/run/keepalived_checkers.pid" 37 | #define VRRP_PID_FILE "/var/run/vrrp.pid" 38 | #define CHECKERS_PID_FILE "/var/run/checkers.pid" 39 | 40 | /* Prototypes */ 41 | extern int pidfile_write(char *, int); 42 | extern void pidfile_rm(char *); 43 | extern int keepalived_running(int); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * md5.h Structures and prototypes for md5. 3 | * 4 | * Version: $Id: md5.h,v 1.2 2013/04/08 11:53:33 liminyi Exp $ 5 | * License: LGPL, but largely derived from a public domain source. 6 | * 7 | */ 8 | 9 | 10 | 11 | /* The below was retrieved from 12 | * http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/crypto/md5.h?rev=1.1 13 | * With the following changes: uint64_t => u32[2] 14 | * Commented out #include 15 | * Commented out the __BEGIN and __END _DECLS, and the __attributes. 16 | */ 17 | 18 | /* 19 | * This code implements the MD5 message-digest algorithm. 20 | * The algorithm is due to Ron Rivest. This code was 21 | * written by Colin Plumb in 1993, no copyright is claimed. 22 | * This code is in the public domain; do with it what you wish. 23 | * 24 | * Equivalent code is available from RSA Data Security, Inc. 25 | * This code has been tested against that, and is equivalent, 26 | * except that you don't need to include two pages of legalese 27 | * with every copy. 28 | */ 29 | #ifndef _LIB_MD5_H 30 | #define _LIB_MD5_H 31 | 32 | #define MD5_BLOCK_LENGTH 64 33 | #define MD5_DIGEST_LENGTH 16 34 | #ifndef u32 35 | typedef unsigned int u32; 36 | #endif 37 | typedef unsigned char u8; 38 | typedef struct MD5Context { 39 | u32 state[4]; /* state */ 40 | u32 count[2]; /* number of bits, mod 2^64 */ 41 | u8 buffer[MD5_BLOCK_LENGTH]; /* input buffer */ 42 | } MD5_CTX; 43 | 44 | 45 | void MD5Init(MD5_CTX *); 46 | void MD5Update(MD5_CTX *, const u8 *, size_t); 47 | void MD5Final(u8 [MD5_DIGEST_LENGTH], MD5_CTX *); 48 | void MD5Transform(u32 [4], const u8 [MD5_BLOCK_LENGTH]); 49 | 50 | void md5_calc(unsigned char *output, unsigned char *input, 51 | unsigned int inputlen); 52 | 53 | #endif /* _LIB_MD5_H */ 54 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.vrrp: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | 14 | vrrp_instance VI_1 { 15 | state MASTER 16 | interface eth0 17 | garp_master_delay 10 18 | smtp_alert 19 | virtual_router_id 51 20 | priority 100 21 | advert_int 1 22 | authentication { 23 | auth_type PASS 24 | auth_pass 1111 25 | } 26 | virtual_ipaddress { 27 | 192.168.200.16 28 | 192.168.200.17 29 | 192.168.200.18 30 | 31 | # optional label. should be of the form "realdev:sometext" for 32 | # compatibility with ifconfig. 33 | 192.168.200.18 label eth0:1 34 | } 35 | } 36 | 37 | vrrp_instance VI_2 { 38 | interface eth0 39 | smtp_alert 40 | virtual_router_id 50 41 | priority 50 42 | advert_int 1 43 | virtual_ipaddress { 44 | 192.168.200.13 45 | 192.168.200.14 46 | 192.168.200.15 47 | } 48 | } 49 | 50 | vrrp_instance VI_3 { 51 | state MASTER 52 | interface eth1 53 | smtp_alert 54 | virtual_router_id 52 55 | priority 100 56 | advert_int 1 57 | authentication { 58 | auth_type PASS 59 | auth_pass 1111 60 | } 61 | virtual_ipaddress { 62 | 192.168.201.13 63 | 192.168.201.14 64 | 192.168.201.15 65 | } 66 | } 67 | 68 | vrrp_instance VI_4 { 69 | interface eth1 70 | smtp_alert 71 | virtual_router_id 53 72 | priority 50 73 | advert_int 1 74 | virtual_ipaddress { 75 | 192.168.201.16 76 | 192.168.201.17 77 | 192.168.201.18 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /include/ipvs/ipvs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_IPVS_H__ 19 | #define __DPVS_IPVS_H__ 20 | #include "common.h" 21 | #include "inet.h" 22 | #include "ipvs/service.h" 23 | 24 | #ifndef IPVS 25 | #define IPVS 26 | #define RTE_LOGTYPE_IPVS RTE_LOGTYPE_USER1 27 | #endif 28 | 29 | #define IPVS_TIMEOUT_MIN 0 30 | #define IPVS_TIMEOUT_MAX 31536000 /* one year */ 31 | 32 | struct dp_vs_iphdr { 33 | int af; 34 | int len; 35 | uint8_t proto; 36 | union inet_addr saddr; 37 | union inet_addr daddr; 38 | }; 39 | 40 | /* for sequence number adjusting */ 41 | struct dp_vs_seq { 42 | uint32_t isn; 43 | uint32_t delta; 44 | uint32_t fdata_seq; 45 | uint32_t prev_delta; 46 | }; 47 | 48 | int dp_vs_init(void); 49 | int dp_vs_term(void); 50 | 51 | struct dp_vs_service; 52 | 53 | struct dp_vs_conn *dp_vs_schedule(struct dp_vs_service *svc, 54 | const struct dp_vs_iphdr *iph, 55 | struct rte_mbuf *mbuf, 56 | bool is_synproxy_on); 57 | 58 | #endif /* __DPVS_IPVS_H__ */ 59 | -------------------------------------------------------------------------------- /tools/keepalived/INSTALL: -------------------------------------------------------------------------------- 1 | Kernel needing 2 | ============== 3 | 4 | Compile a kernel with the following options : 5 | 6 | Kernel/User netlink socket 7 | Network firewalls (for Kernel 2.2) 8 | LinuxVirtualServer 9 | 10 | Keepalived support all LVS code : including IPVS code for kernel 2.2 11 | and kernel 2.4 12 | 13 | Libraries dependency 14 | ==================== 15 | 16 | In order to compile Keepalived needs the following libraries : 17 | 18 | * OpenSSL, 19 | * popt 20 | 21 | Installation 22 | ============ 23 | 24 | 1. uncompress the tarball 25 | 2. cd into the directory 26 | 3. './configure' 27 | 4. 'make' 28 | 5. 'make install'. This will install keepalived on your system, 29 | binaries and configuration file : 30 | * keepalived : The keepalived daemon program. 31 | * genhash : The MD5 url digest generator. You need it to 32 | configure HTTP GET check and SSL GET check in 33 | order to compute MD5SUM digest etalon. 34 | * /etc/keepalived/keepalived.conf 35 | 6. link keepalived.init into your runlevel directory. On redhat systems : 36 | ln -s /etc/rc.d/init.d/keepalived.init /etc/rc.d/rc3.d/S99keepalived 37 | 38 | By default configure script use /usr/local as base directory. You can change 39 | this value to your own by passing --prefix value to configure script 40 | 41 | eg: './configure --prefix=/usr/' 42 | 43 | Configuration 44 | ============= 45 | 46 | Just take a look to the /etc/keepalived/keepalived.conf file installed. 47 | It will give you all the informations needed. If you want more informations 48 | considering keepalived, please refer to the keepalived homepage into the 49 | documentation section. 50 | 51 | http://www.keepalived.org 52 | 53 | 54 | Have fun with it ! 55 | 56 | Alexandre, 57 | -------------------------------------------------------------------------------- /tools/keepalived/doc/man/man1/genhash.1: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" genhash(1) 3 | .\" 4 | .\" Copyright (C) 2004 Andres Salomon 5 | .TH genhash 1 "Feb 2004" 6 | .SH NAME 7 | genhash \- md5 hash generation tool for remote web pages 8 | .SH SYNOPSIS 9 | .B "genhash [options] [-s server-address] [-p port] [-u url]" 10 | .SH DESCRIPTION 11 | .B genhash 12 | is a tool used for generating md5sum hashes of remote web pages. 13 | .B genhash 14 | can use HTTP or HTTPS to connect to the web page. The output by this 15 | utility includes the HTTP header, page data, and the md5sum of the data. 16 | This md5sum can then be used within the 17 | .B keepalived(8) 18 | program, for monitoring HTTP and HTTPS services. 19 | .SH OPTIONS 20 | .TP 21 | .B --use-ssl, -S 22 | Use SSL to connect to the server. 23 | .TP 24 | .B --server , -s 25 | Specify the ip address to connect to. 26 | .TP 27 | .B --port , -p 28 | Specify the port to connect to. 29 | .TP 30 | .B --url , -u 31 | Specify the path to the file you want to generate the hash of. 32 | .TP 33 | .B --use-virtualhost , -V 34 | Specify the virtual host to send along with the HTTP headers. 35 | .TP 36 | .B --hash , -H 37 | Specify the hash algorithm to make a digest of the target page. 38 | Consult the help screen for list of available ones with a mark 39 | of the default one. 40 | .TP 41 | .B --verbose, -v 42 | Be verbose with the output. 43 | .TP 44 | .B --help, -h 45 | Display the program help screen and exit. 46 | .TP 47 | .B --release, -r 48 | Display the release number (version) and exit. 49 | .TP 50 | .BR 51 | .SH SEE ALSO 52 | .BR keepalived (8), 53 | .BR keepalived.conf (5) 54 | .SH AUTHOR 55 | .br 56 | .B genhash 57 | was written by Alexandre Cassen . 58 | 59 | This man page was contributed by Andres Salomon 60 | for the Debian GNU/Linux system (but may be used by others). 61 | 62 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,6D3B09E4CA5421FF 4 | 5 | SaDJA2MhJ12ZmDxfGkSLhQgjYPEQYqVfs5b4DZTz+9pJqzuNxHrZZU43oArbWBdB 6 | 3DKc1THejbyHF2lY7xgPLk/5iax5r+CXesDKZroSliHyERBIOCUgDN6ecwvVGtYv 7 | C8IhlwGPEXyxr59lyV37RjkSUVXYBqiRbLlNIcQtp5T6GkFe+yftOnv6/UADCLTS 8 | Pu8xwkda1rf7dgPwYIKuk2SOTTe1VMDtWacRUGu8NteTJ4aiVaeeo9wdsKId5U2b 9 | Z7NTJjOjvdXOLRonfkGvDXmrmN4eICks0bV0ZBtkULAfGjKNGs6riY+XNGKNRmjI 10 | idRRB0za+EGorpiJ/vbe7n7uaFXIJlfqCwhTi4Up3mS8sR4tLHfmdjp85GV9P9B3 11 | xX3CHIeG5/EYDt0Qn1gRL5ODL/0O7nFGJslhcQUS6bMmcg9nSzhClTE2gREz0j9g 12 | pwzvRpEkIl3Tw4niZLIX8fW2cEIyKTBMCCG2MDwHHgXRL3SUXkOGeitFefkcXN/z 13 | /UWRS8XQcX7/lGWCiuEpgn+esoirjf8lFNVsx6OT0UXj3oBxGrz1iB/vpu/PMBVQ 14 | JsbEPSh/ElHSDUItw2ytjJmkolRtM01b7cFj16ZxbHjinXWTIGZFWUYIlaeA2zHK 15 | D/NRMFJwjrQYhjRgPqltvbw7M01Co7SNFBwSotARr36FBjsxbOH3F1jY6w+kXvJU 16 | X5m83C9UONM2K7kkKYXbE2yW+kzJF2LFX0Uu4yDluxNG767/WwqiQSI63aIzNAPp 17 | rSsaIMBSbVZia8q49gcvGyuvqBZpwm/PcZwr/PHJjvGs8hdU1ACmyQ== 18 | -----END RSA PRIVATE KEY----- 19 | -----BEGIN CERTIFICATE----- 20 | MIICFTCCAX4CAgECMA0GCSqGSIb3DQEBBAUAMFcxCzAJBgNVBAYTAlVTMRMwEQYD 21 | VQQKEwpSVEZNLCBJbmMuMRkwFwYDVQQLExBXaWRnZXRzIERpdmlzaW9uMRgwFgYD 22 | VQQDEw9UZXN0IENBMjAwMTA1MTcwHhcNMDEwNTE3MTYxMTM2WhcNMDQwMzA2MTYx 23 | MTM2WjBOMQswCQYDVQQGEwJVUzETMBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UE 24 | CxMQV2lkZ2V0cyBEaXZpc2lvbjEPMA0GA1UEAxMGY2xpZW50MIGfMA0GCSqGSIb3 25 | DQEBAQUAA4GNADCBiQKBgQCHNWSoNh6msUwYGGd7TYQDsdSG0ao6QXaYjk+78ZyM 26 | QeZUBu2dZFjG4wnzkKwrD4rp/J5PLR9AdxR72lb9AavEOKL2UDHJGsscZkGVw/bz 27 | ZbxrKF2rvdpZSvKP1OhV1MOds/WTpRm1gcmVSoV5vLOMqVjzjHoxQ/+1zpjzMxWL 28 | 0wIDAQABMA0GCSqGSIb3DQEBBAUAA4GBACTJhRR5tv8A7dc5+zmKR1Q/i8qE3Mrn 29 | mp/MOXHfX+ifJ/w+twoc/yd4En+7pr+hGsiTofct1JOZDW9Akq/ZGu1+NpVRT7Cw 30 | 53EdMwpi7ArwZAsLIUBsKA7QmLTbdwjU5S7WlZ24eygZHyqZrK4Few+JuzlFkkoI 31 | FIDCfinyz24m 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /src/dpdk.mk: -------------------------------------------------------------------------------- 1 | # 2 | # DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | # 4 | # Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | # All Rights Reserved. 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | 18 | ifeq ($(RTE_SDK),) 19 | $(error "The variable RTE_SDK is not defined.") 20 | endif 21 | # default target, may be overriden. 22 | RTE_TARGET ?= build 23 | 24 | DPDKDIR := $(RTE_SDK)/$(RTE_TARGET) 25 | 26 | INCDIRS += -I $(DPDKDIR)/include 27 | 28 | CFLAGS += -include $(DPDKDIR)/include/rte_config.h 29 | 30 | CFLAGS += -march=native \ 31 | -DRTE_MACHINE_CPUFLAG_SSE \ 32 | -DRTE_MACHINE_CPUFLAG_SSE2 \ 33 | -DRTE_MACHINE_CPUFLAG_SSE3 \ 34 | -DRTE_MACHINE_CPUFLAG_SSSE3 \ 35 | -DRTE_MACHINE_CPUFLAG_SSE4_1 \ 36 | -DRTE_MACHINE_CPUFLAG_SSE4_2 \ 37 | -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2 38 | 39 | LIBS += -L $(DPDKDIR)/lib 40 | 41 | LIBS += -Wl,--no-as-needed -fvisibility=default \ 42 | -Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe \ 43 | -lrte_pmd_e1000 -lrte_pmd_ring -lrte_pmd_bond -lrte_ethdev -lrte_ip_frag \ 44 | -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lrte_eal \ 45 | -Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni \ 46 | -lrte_mempool_ring -lrte_timer -lrte_net -Wl,-lrte_pmd_virtio \ 47 | -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto 48 | -------------------------------------------------------------------------------- /include/ipvs/xmit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_XMIT_H__ 19 | #define __DPVS_XMIT_H__ 20 | #include "dpdk.h" 21 | #include "ipvs/proto.h" 22 | #include "ipvs/conn.h" 23 | 24 | int dp_vs_xmit_fnat(struct dp_vs_proto *proto, 25 | struct dp_vs_conn *conn, 26 | struct rte_mbuf *mbuf); 27 | 28 | int dp_vs_out_xmit_fnat(struct dp_vs_proto *prot, 29 | struct dp_vs_conn *conn, 30 | struct rte_mbuf *mbuf); 31 | 32 | void dp_vs_xmit_icmp(struct rte_mbuf *mbuf, 33 | struct dp_vs_proto *prot, 34 | struct dp_vs_conn *conn, 35 | int dir); 36 | 37 | int dp_vs_xmit_dr(struct dp_vs_proto *proto, 38 | struct dp_vs_conn *conn, 39 | struct rte_mbuf *mbuf); 40 | 41 | int dp_vs_xmit_snat(struct dp_vs_proto *proto, 42 | struct dp_vs_conn *conn, 43 | struct rte_mbuf *mbuf); 44 | 45 | int dp_vs_out_xmit_snat(struct dp_vs_proto *proto, 46 | struct dp_vs_conn *conn, 47 | struct rte_mbuf *mbuf); 48 | 49 | void install_xmit_keywords(void); 50 | 51 | #endif /* __DPVS_XMIT_H__ */ 52 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/vrrp/vrrp_arp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: ARP primitives. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | /* system includes */ 24 | #include 25 | #include 26 | 27 | /* local includes */ 28 | #include "logger.h" 29 | #include "memory.h" 30 | #include "utils.h" 31 | #include "vrrp_arp.h" 32 | 33 | 34 | /* Build a gratuitous ARP message over a specific interface */ 35 | int send_gratuitous_arp(ip_address_t *ipaddress) 36 | { 37 | log_message(LOG_INFO, "send garp for addr %s.\n", 38 | inet_ntop2(ipaddress->u.sin.sin_addr.s_addr)); 39 | return ipvs_send_gratuitous_arp(&(ipaddress->u.sin.sin_addr)); 40 | } 41 | 42 | 43 | /* 44 | * Gratuitous ARP init/close 45 | */ 46 | void gratuitous_arp_init(void) 47 | { 48 | log_message(LOG_INFO, "Registering DPVS gratuitous ARP.\n"); 49 | } 50 | void gratuitous_arp_close(void) 51 | { 52 | log_message(LOG_INFO, "Unregistering DPVS gratuitous ARP.\n"); 53 | } 54 | -------------------------------------------------------------------------------- /include/conf/laddr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | /** 19 | * Note: control plane only 20 | * based on dpvs_sockopt. 21 | */ 22 | #ifndef __DPVS_LADDR_CONF_H__ 23 | #define __DPVS_LADDR_CONF_H__ 24 | #include "inet.h" 25 | #include "net/if.h" 26 | 27 | enum { 28 | /* set */ 29 | SOCKOPT_SET_LADDR_ADD = 100, 30 | SOCKOPT_SET_LADDR_DEL, 31 | SOCKOPT_SET_LADDR_FLUSH, 32 | 33 | /* get */ 34 | SOCKOPT_GET_LADDR_GETALL, 35 | }; 36 | 37 | struct dp_vs_laddr_entry { 38 | union inet_addr addr; 39 | uint64_t nport_conflict; 40 | uint32_t nconns; 41 | }; 42 | 43 | struct dp_vs_laddr_conf { 44 | /* identify service */ 45 | int af; 46 | uint8_t proto; 47 | union inet_addr vaddr; 48 | uint16_t vport; 49 | uint32_t fwmark; 50 | char srange[256]; 51 | char drange[256]; 52 | char iifname[IFNAMSIZ]; 53 | char oifname[IFNAMSIZ]; 54 | 55 | /* for set */ 56 | union inet_addr laddr; 57 | char ifname[IFNAMSIZ]; 58 | 59 | /* for get */ 60 | int nladdrs; 61 | struct dp_vs_laddr_entry laddrs[0]; 62 | }; 63 | 64 | #endif /* __DPVS_LADDR_CONF_H__ */ 65 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.SSL_GET: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | global_defs { 4 | notification_email { 5 | acassen 6 | } 7 | notification_email_from Alexandre.Cassen@firewall.loc 8 | smtp_server 192.168.200.1 9 | smtp_connect_timeout 30 10 | router_id LVS_DEVEL 11 | } 12 | 13 | vrrp_instance VI_1 { 14 | state MASTER 15 | interface eth0 16 | virtual_router_id 51 17 | priority 100 18 | advert_int 1 19 | authentication { 20 | auth_type AH 21 | auth_pass 1111 22 | } 23 | virtual_ipaddress { 24 | 192.168.200.16 25 | 192.168.200.17 26 | 192.168.200.18 27 | } 28 | } 29 | 30 | virtual_server 192.168.200.100 443 { 31 | delay_loop 6 32 | lb_algo rr 33 | lb_kind NAT 34 | persistence_timeout 50 35 | protocol TCP 36 | 37 | real_server 192.168.201.100 443 { 38 | weight 1 39 | SSL_GET { 40 | url { 41 | path / 42 | digest ff20ad2481f97b1754ef3e12ecd3a9cc 43 | } 44 | url { 45 | path /mrtg/ 46 | digest 9b3a0c85a887a256d6939da88aabd8cd 47 | } 48 | connect_timeout 3 49 | nb_get_retry 3 50 | delay_before_retry 3 51 | } 52 | } 53 | } 54 | 55 | virtual_server 192.168.200.100 80 { 56 | delay_loop 6 57 | lb_algo rr 58 | lb_kind NAT 59 | persistence_timeout 50 60 | protocol TCP 61 | 62 | real_server 192.168.201.100 80 { 63 | weight 1 64 | HTTP_GET { 65 | url { 66 | path / 67 | digest ff20ad2481f97b1754ef3e12ecd3a9cc 68 | } 69 | url { 70 | path /mrtg/ 71 | digest 9b3a0c85a887a256d6939da88aabd8cd 72 | } 73 | connect_timeout 3 74 | nb_get_retry 3 75 | delay_before_retry 3 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /include/ipvs/sched.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_SCHED_H__ 19 | #define __DPVS_SCHED_H__ 20 | #include "list.h" 21 | #include "dpdk.h" 22 | #include "common.h" 23 | #include "ipvs/service.h" 24 | 25 | 26 | struct dp_vs_scheduler { 27 | struct list_head n_list; 28 | char *name; 29 | // rte_atomic32_t refcnt; 30 | 31 | struct dp_vs_dest * 32 | (*schedule)(struct dp_vs_service *svc, 33 | const struct rte_mbuf *mbuf); 34 | 35 | int (*init_service)(struct dp_vs_service *svc); 36 | int (*exit_service)(struct dp_vs_service *svc); 37 | int (*update_service)(struct dp_vs_service *svc); 38 | } __rte_cache_aligned; 39 | 40 | int dp_vs_sched_init(void); 41 | int dp_vs_sched_term(void); 42 | 43 | struct dp_vs_scheduler * 44 | dp_vs_scheduler_get(const char *name); 45 | 46 | int dp_vs_bind_scheduler(struct dp_vs_service *svc, 47 | struct dp_vs_scheduler *scheduler); 48 | 49 | int dp_vs_unbind_scheduler(struct dp_vs_service *svc); 50 | 51 | void dp_vs_scheduler_put(struct dp_vs_scheduler *scheduler); 52 | 53 | int register_dp_vs_scheduler(struct dp_vs_scheduler *scheduler); 54 | 55 | int unregister_dp_vs_scheduler(struct dp_vs_scheduler *scheduler); 56 | 57 | #endif /* __DPVS_SCHED_H__ */ 58 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # QNAT is a software NAT based on DPDK and DPVS. 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | 15 | # 16 | # Makefile for QNAT 17 | # 18 | 19 | #DEBUG := 1 # enable for debug 20 | 21 | TARGET := qnat 22 | 23 | # same path of THIS Makefile 24 | SRCDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) 25 | 26 | include $(SRCDIR)/dpdk.mk 27 | include $(SRCDIR)/config.mk 28 | 29 | INCDIRS += -I $(SRCDIR)/../include 30 | 31 | # for dpvs main program. 32 | CFLAGS += -D __DPVS__ 33 | 34 | CFLAGS += -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes 35 | 36 | ifeq ($(DEBUG),) 37 | CFLAGS += -O3 -DCONFIG_NETOPS_CONN_THRESH -DCONFIG_NETOPS_ACL_RANGE -DCONFIG_NETOPS_BYPASS_ROUTING 38 | #CFLAGS += -O0 -g -DCONFIG_NETOPS_CONN_THRESH -DCONFIG_NETOPS_ACL_RANGE -DCONFIG_NETOPS_BYPASS_ROUTING 39 | else 40 | #CFLAGS += -g -O0 -D DEBUG 41 | CFLAGS += -g -O0 -D DEBUG -DCONFIG_NETOPS_CONN_THRESH -DCONFIG_NETOPS_ACL_RANGE -DCONFIG_NETOPS_BYPASS_ROUTING 42 | endif 43 | 44 | LIBS += -lpthread 45 | 46 | CFLAGS += $(INCDIRS) $(LIBS) 47 | 48 | OBJS := $(shell find $(SRCDIR) -name '*.c' | sort) 49 | OBJS := $(patsubst %.c,%.o,$(OBJS)) 50 | 51 | all: $(TARGET) 52 | 53 | $(TARGET): $(OBJS) 54 | @$(CC) $(CFLAGS) $^ -o $@ 55 | @echo " $(notdir $@)" 56 | 57 | %.o: %.c 58 | @$(CC) -c $(CFLAGS) $< -o $@ 59 | @echo " $(notdir $@)" 60 | 61 | clean: 62 | find $(SRCDIR) -name '*.o' | xargs rm -f 63 | rm -f ./$(TARGET) 64 | 65 | install: 66 | install -m 744 $(TARGET) $(INSDIR) 67 | -------------------------------------------------------------------------------- /include/dpdk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_DPDK_H__ 19 | #define __DPVS_DPDK_H__ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include "mbuf.h" 58 | 59 | typedef uint8_t lcoreid_t; 60 | typedef uint8_t portid_t; 61 | typedef uint16_t queueid_t; 62 | 63 | #endif /* __DPVS_DPDK_H__ */ 64 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in 2 | # 3 | # Copyright (C) 2001-2012 Alexandre Cassen, 4 | 5 | EXEC = genhash 6 | BIN = ../bin 7 | 8 | prefix = @prefix@ 9 | exec_prefix = @exec_prefix@ 10 | bindir = @bindir@ 11 | mandir = @mandir@ 12 | datarootdir = @datarootdir@ 13 | 14 | CC = @CC@ 15 | STRIP = @STRIP@ 16 | INCLUDES = -I../lib 17 | CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \ 18 | -Wall -Wunused -Wstrict-prototypes 19 | LDFLAGS = @LIBS@ @LDFLAGS@ 20 | 21 | OBJS = main.o sock.o layer4.o http.o ssl.o 22 | LIB_OBJS = ../lib/timer.o ../lib/scheduler.o ../lib/memory.o ../lib/list.o \ 23 | ../lib/utils.o ../lib/html.o ../lib/signals.o ../lib/logger.o 24 | 25 | all: $(BIN)/$(EXEC) 26 | $(STRIP) $(BIN)/$(EXEC) 27 | @echo "" 28 | @echo "Make complete" 29 | 30 | $(BIN)/$(EXEC): $(LIB_OBJS) $(OBJS) 31 | @set -e; \ 32 | echo "Building $(BIN)/$(EXEC)" && \ 33 | $(CC) -o $(BIN)/$(EXEC) $(LIB_OBJS) $(OBJS) $(LDFLAGS) 34 | 35 | clean: 36 | rm -f core *.o 37 | 38 | distclean: clean 39 | rm -f Makefile $(BIN)/$(EXEC) 40 | 41 | uninstall: 42 | rm -f $(DESTDIR)$(bindir)/$(EXEC) 43 | rm -f $(DESTDIR)$(mandir)/man1/genhash.1 44 | 45 | install: 46 | install -d $(DESTDIR)$(bindir) 47 | install -m 755 $(BIN)/$(EXEC) $(DESTDIR)$(bindir)/ 48 | install -d $(DESTDIR)$(mandir)/man1 49 | install -m 644 ../doc/man/man1/genhash.1 $(DESTDIR)$(mandir)/man1 50 | 51 | mrproper: clean distclean 52 | rm -f config.* 53 | 54 | # Code dependencies 55 | 56 | main.o: main.c main.h ../lib/utils.h sock.h ../lib/timer.h \ 57 | http.h ssl.h ../lib/scheduler.h ../lib/memory.h 58 | sock.o: sock.c sock.h ../lib/utils.h layer4.h ssl.h main.h \ 59 | ../lib/memory.h 60 | layer4.o: layer4.c layer4.h ../lib/scheduler.h ../lib/utils.h \ 61 | main.h ssl.h 62 | http.o: http.c http.h sock.h ../lib/scheduler.h ../lib/utils.h \ 63 | layer4.h main.h ../lib/html.h ../lib/timer.h ../lib/scheduler.h \ 64 | ../lib/memory.h 65 | ssl.o: ssl.c ssl.h http.h main.h ../lib/utils.h ../lib/html.h 66 | -------------------------------------------------------------------------------- /src/pidfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #include 19 | #include 20 | #include "pidfile.h" 21 | 22 | /* Create the running pidfile */ 23 | int pidfile_write(const char *pid_file, int pid) 24 | { 25 | assert(pid_file && pid > 0); 26 | 27 | FILE *pidfile = fopen(pid_file, "w"); 28 | 29 | if (!pidfile) { 30 | syslog(LOG_INFO, "%s: Cannot open %s pid file\n", __func__, pid_file); 31 | return 0; 32 | } 33 | 34 | fprintf(pidfile, "%d\n", pid); 35 | fclose(pidfile); 36 | return 1; 37 | } 38 | 39 | /* Remove the running pidfile */ 40 | void pidfile_rm(const char *pid_file) 41 | { 42 | if (pid_file) 43 | unlink(pid_file); 44 | } 45 | 46 | /* Return the running state */ 47 | bool dpvs_running(const char *pid_file) 48 | { 49 | FILE *pidfile = fopen(pid_file, "r"); 50 | pid_t pid; 51 | 52 | /* pidfile not exist */ 53 | if (!pidfile) 54 | return false; 55 | 56 | if (fscanf(pidfile, "%d", &pid) != 1) 57 | return false; 58 | fclose(pidfile); 59 | 60 | /* remove pidfile if no process attached to it */ 61 | if (kill(pid, 0)) { 62 | syslog(LOG_INFO, "%s: Remove a zombie pid file %s\n", __func__, pid_file); 63 | pidfile_rm(pid_file); 64 | return false; 65 | } 66 | 67 | return true; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/sock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Perform a GET query to a remote HTTP/HTTPS server. 3 | * Set a timer to compute global remote server response 4 | * time. 5 | * 6 | * Part: Socket pool utility functions. 7 | * 8 | * Version: $Id: sock.c,v 1.1.16 2009/02/14 03:25:07 acassen Exp $ 9 | * 10 | * Authors: Alexandre Cassen, 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the GNU General Public License for more details. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 20 | * 2 of the License, or (at your option) any later version. 21 | * 22 | * Copyright (C) 2001-2012 Alexandre Cassen, 23 | */ 24 | 25 | #include 26 | #include "memory.h" 27 | #include "utils.h" 28 | #include "list.h" 29 | #include "sock.h" 30 | #include "layer4.h" 31 | #include "ssl.h" 32 | #include "main.h" 33 | 34 | /* global var */ 35 | SOCK *sock = NULL; 36 | 37 | /* Close the descriptor */ 38 | static void 39 | close_sock(SOCK * sock_obj) 40 | { 41 | if (sock_obj->ssl) { 42 | SSL_shutdown(sock_obj->ssl); 43 | SSL_free(sock_obj->ssl); 44 | } 45 | close(sock_obj->fd); 46 | } 47 | 48 | /* Destroy the socket handler */ 49 | void 50 | free_sock(SOCK * sock_obj) 51 | { 52 | DBG("Freeing fd:%d\n", sock_obj->fd); 53 | 54 | close_sock(sock_obj); 55 | FREE(sock_obj); 56 | } 57 | 58 | /* Init socket handler */ 59 | void 60 | init_sock(void) 61 | { 62 | sock = (SOCK *) MALLOC(sizeof (SOCK)); 63 | memset(sock, 0, sizeof (SOCK)); 64 | thread_add_event(master, tcp_connect_thread, sock, 0); 65 | } 66 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/layer4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: layer4.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _LAYER4_H 24 | #define _LAYER4_H 25 | 26 | /* system includes */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /* local includes */ 36 | #include "scheduler.h" 37 | #include "check_api.h" 38 | 39 | enum connect_result { 40 | connect_error, 41 | connect_in_progress, 42 | connect_timeout, 43 | connect_success 44 | }; 45 | 46 | /* Prototypes defs */ 47 | extern enum connect_result 48 | tcp_bind_connect(int, conn_opts_t *); 49 | 50 | extern enum connect_result 51 | tcp_connect(int, struct sockaddr_storage *); 52 | 53 | extern enum connect_result 54 | tcp_socket_state(int, thread_t *, int (*func) (thread_t *)); 55 | 56 | extern int 57 | tcp_connection_state(int, enum connect_result 58 | , thread_t *, int (*func) (thread_t *) 59 | , long); 60 | #endif 61 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/layer4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Perform a GET query to a remote HTTP/HTTPS server. 3 | * Set a timer to compute global remote server response 4 | * time. 5 | * 6 | * Part: layer4.c include file. 7 | * 8 | * Version: $Id: layer4.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $ 9 | * 10 | * Authors: Alexandre Cassen, 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the GNU General Public License for more details. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 20 | * 2 of the License, or (at your option) any later version. 21 | * 22 | * Copyright (C) 2001-2012 Alexandre Cassen, 23 | */ 24 | 25 | #ifndef _LAYER4_H 26 | #define _LAYER4_H 27 | 28 | /* system includes */ 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /* local includes */ 38 | #include "scheduler.h" 39 | #include "main.h" 40 | 41 | enum connect_result { 42 | connect_error, 43 | connect_in_progress, 44 | connect_timeout, 45 | connect_success 46 | }; 47 | 48 | /* Prototypes defs */ 49 | extern enum connect_result 50 | tcp_connect(int fd, REQ *); 51 | 52 | extern enum connect_result 53 | tcp_socket_state(int, thread_t *, char *, uint16_t, 54 | int (*func) (thread_t *)); 55 | 56 | extern void 57 | tcp_connection_state(int, enum connect_result 58 | , thread_t *, int (*func) (thread_t *) 59 | , long); 60 | 61 | extern int tcp_connect_thread(thread_t *); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: Main program include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _MAIN_H 24 | #define _MAIN_H 25 | 26 | /* global includes */ 27 | #include 28 | #include 29 | #include 30 | 31 | /* local includes */ 32 | #include "daemon.h" 33 | #include "memory.h" 34 | #include "utils.h" 35 | #include "pidfile.h" 36 | #include "scheduler.h" 37 | #include "parser.h" 38 | #include "vrrp_daemon.h" 39 | #include "check_daemon.h" 40 | #include "global_data.h" 41 | 42 | /* Global vars exported */ 43 | extern char *conf_file; /* Configuration file */ 44 | extern int log_facility; /* Optional logging facilities */ 45 | extern pid_t vrrp_child; /* VRRP child process ID */ 46 | extern pid_t checkers_child; /* Healthcheckers child process ID */ 47 | extern int daemon_mode; /* VRRP/CHECK subsystem selection */ 48 | extern int linkwatch; /* Use linkwatch kernel netlink reflection */ 49 | #ifdef _WITH_SNMP_ 50 | extern int snmp; /* Enable SNMP support */ 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile.in 2 | # 3 | # Copyright (C) 2001-2012 Alexandre Cassen, 4 | 5 | EXEC = genhash 6 | BIN = ../bin 7 | 8 | prefix = /usr/local 9 | exec_prefix = ${prefix} 10 | bindir = ${exec_prefix}/bin 11 | mandir = ${datarootdir}/man 12 | datarootdir = ${prefix}/share 13 | 14 | CC = gcc 15 | STRIP = strip 16 | INCLUDES = -I../lib 17 | CFLAGS = -g -O2 -I/usr/src/linux/include -I/usr/src/linux/include $(INCLUDES) \ 18 | -Wall -Wunused -Wstrict-prototypes 19 | LDFLAGS = -lssl -lcrypto -lcrypt 20 | 21 | OBJS = main.o sock.o layer4.o http.o ssl.o 22 | LIB_OBJS = ../lib/timer.o ../lib/scheduler.o ../lib/memory.o ../lib/list.o \ 23 | ../lib/utils.o ../lib/html.o ../lib/signals.o ../lib/logger.o 24 | 25 | all: $(BIN)/$(EXEC) 26 | $(STRIP) $(BIN)/$(EXEC) 27 | @echo "" 28 | @echo "Make complete" 29 | 30 | $(BIN)/$(EXEC): $(LIB_OBJS) $(OBJS) 31 | @set -e; \ 32 | echo "Building $(BIN)/$(EXEC)" && \ 33 | $(CC) -o $(BIN)/$(EXEC) $(LIB_OBJS) $(OBJS) $(LDFLAGS) 34 | 35 | clean: 36 | rm -f core *.o 37 | 38 | distclean: clean 39 | rm -f Makefile $(BIN)/$(EXEC) 40 | 41 | uninstall: 42 | rm -f $(DESTDIR)$(bindir)/$(EXEC) 43 | rm -f $(DESTDIR)$(mandir)/man1/genhash.1 44 | 45 | install: 46 | install -d $(DESTDIR)$(bindir) 47 | install -m 755 $(BIN)/$(EXEC) $(DESTDIR)$(bindir)/ 48 | install -d $(DESTDIR)$(mandir)/man1 49 | install -m 644 ../doc/man/man1/genhash.1 $(DESTDIR)$(mandir)/man1 50 | 51 | mrproper: clean distclean 52 | rm -f config.* 53 | 54 | # Code dependencies 55 | 56 | main.o: main.c main.h ../lib/utils.h sock.h ../lib/timer.h \ 57 | http.h ssl.h ../lib/scheduler.h ../lib/memory.h 58 | sock.o: sock.c sock.h ../lib/utils.h layer4.h ssl.h main.h \ 59 | ../lib/memory.h 60 | layer4.o: layer4.c layer4.h ../lib/scheduler.h ../lib/utils.h \ 61 | main.h ssl.h 62 | http.o: http.c http.h sock.h ../lib/scheduler.h ../lib/utils.h \ 63 | layer4.h main.h ../lib/html.h ../lib/timer.h ../lib/scheduler.h \ 64 | ../lib/memory.h 65 | ssl.o: ssl.c ssl.h http.h main.h ../lib/utils.h ../lib/html.h 66 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Route filtering function. 3 | * Copyright (C) 1998 Kunihiro Ishiguro 4 | * 5 | * This file is part of GNU Zebra. 6 | * 7 | * GNU Zebra is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published 9 | * by the Free Software Foundation; either version 2, or (at your 10 | * option) any later version. 11 | * 12 | * GNU Zebra is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Zebra; see the file COPYING. If not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | #ifndef _ZEBRA_FILTER_H 24 | #define _ZEBRA_FILTER_H 25 | 26 | //#include "if.h" 27 | 28 | /* Filter type is made by `permit', `deny' and `dynamic'. */ 29 | enum filter_type 30 | { 31 | FILTER_DENY, 32 | FILTER_PERMIT, 33 | FILTER_DYNAMIC 34 | }; 35 | 36 | enum access_type 37 | { 38 | ACCESS_TYPE_STRING, 39 | ACCESS_TYPE_NUMBER 40 | }; 41 | 42 | /* Access list */ 43 | struct access_list 44 | { 45 | char *name; 46 | char *remark; 47 | 48 | struct access_master *master; 49 | 50 | enum access_type type; 51 | 52 | struct access_list *next; 53 | struct access_list *prev; 54 | 55 | struct filter *head; 56 | struct filter *tail; 57 | }; 58 | 59 | /* Prototypes for access-list. */ 60 | extern void access_list_init (void); 61 | extern void access_list_reset (void); 62 | extern void access_list_add_hook (void (*func)(struct access_list *)); 63 | extern void access_list_delete_hook (void (*func)(struct access_list *)); 64 | extern struct access_list *access_list_lookup (afi_t, const char *); 65 | extern enum filter_type access_list_apply (struct access_list *, void *); 66 | 67 | #endif /* _ZEBRA_FILTER_H */ 68 | -------------------------------------------------------------------------------- /tools/dpip/dpip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPIP_H__ 19 | #define __DPIP_H__ 20 | #include "list.h" 21 | #include "utils.h" 22 | 23 | #define DPIP_NAME "dpip" 24 | #define DPIP_VERSION "v1.0.0" 25 | 26 | typedef enum dpip_cmd_e { 27 | DPIP_CMD_ADD, 28 | DPIP_CMD_DEL, 29 | DPIP_CMD_SET, 30 | DPIP_CMD_SHOW, 31 | DPIP_CMD_REPLACE, 32 | DPIP_CMD_FLUSH, 33 | DPIP_CMD_HELP, 34 | } dpip_cmd_t; 35 | 36 | struct dpip_conf { 37 | int af; 38 | int verbose; 39 | int stats; 40 | bool color; 41 | char *obj; 42 | dpip_cmd_t cmd; 43 | int argc; 44 | char **argv; 45 | }; 46 | 47 | struct dpip_obj { 48 | struct list_head list; 49 | char *name; 50 | void *param; 51 | 52 | void (*help)(void); 53 | /* @conf is used to passing general config like af, verbose, ... 54 | * we have obj.parse() to handle obj specific parameters. */ 55 | int (*do_cmd)(struct dpip_obj *obj, dpip_cmd_t cmd, 56 | struct dpip_conf *conf); 57 | /* the parser can be used to parse @conf into @param */ 58 | int (*parse)(struct dpip_obj *obj, struct dpip_conf *conf); 59 | int (*check)(const struct dpip_obj *obj, dpip_cmd_t cmd); 60 | }; 61 | 62 | void dpip_register_obj(struct dpip_obj *obj); 63 | void dpip_unregister_obj(struct dpip_obj *obj); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /tools/ipvsadm/debian/copyright: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------- 2 | 3 | ipvsadm - Version 1.14 - 11th January 2001 4 | 5 | This is free software. See below for details. 6 | 7 | ipvsadm is a utility to administer the IP virtual server services 8 | offered by the Linux kernel with IP virtual server support. 9 | 10 | This version of ipvsadm requires IPVS module v0.0.5 for kernel 2.4 or 11 | later. Check out the Linux Virtual Server Project home page on the 12 | World Wide Web: 13 | http://www.LinuxVirtualServer.org/ 14 | or 15 | http://www.Linux-VS.org/ 16 | for the most recent information and original sources about ipvsadm. 17 | 18 | To make, make sure your Linux kernel is already patched with IPVS and 19 | "make menuconfig" or "make xconfig" to setup the right compiling options, 20 | see the README of the virtual server patch for detail, then simply type 21 | make 22 | in the source directory. 23 | 24 | Install to your liking. We suggest the following pathnames: 25 | /sbin/ipvsadm 26 | /usr/man/man8/ipvsadm.8 27 | This will be done automatically when calling 28 | make install 29 | in the source directory. 30 | 31 | 32 | Wensong Zhang 33 | 34 | 35 | -------------------------------------------------------------------------- 36 | 37 | This program is free software; you can redistribute it and/or modify 38 | it under the terms of the GNU General Public License as published by 39 | the Free Software Foundation; either version 2 of the License, or 40 | (at your option) any later version. 41 | 42 | This program is distributed in the hope that it will be useful, 43 | but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | GNU General Public License for more details. 46 | 47 | You should have received a copy of the GNU General Public License 48 | along with this program; if not, write to the Free Software 49 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 50 | 51 | -------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_sync.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_SYNC_H 24 | #define _VRRP_SYNC_H 25 | 26 | /* system include */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* local include */ 34 | #include "vrrp.h" 35 | 36 | /* TSM size */ 37 | #define VRRP_MAX_TSM_STATE 3 38 | 39 | /* MACRO definition */ 40 | #define GROUP_STATE(G) ((G)->state) 41 | #define GROUP_NAME(G) ((G)->gname) 42 | 43 | /* extern prototypes */ 44 | extern void vrrp_init_instance_sands(vrrp_t *); 45 | extern void vrrp_sync_smtp_notifier(vrrp_sgroup_t *); 46 | extern void vrrp_sync_set_group(vrrp_sgroup_t *); 47 | extern int vrrp_sync_group_up(vrrp_sgroup_t *); 48 | extern int vrrp_sync_leave_fault(vrrp_t *); 49 | extern int vrrp_sync_goto_master(vrrp_t *); 50 | extern void vrrp_sync_backup(vrrp_t *); 51 | extern void vrrp_sync_master(vrrp_t *); 52 | extern void vrrp_sync_master_election(vrrp_t *); 53 | extern void vrrp_sync_fault(vrrp_t *); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /tools/keepalived/lib/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: timer.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _TIMER_H 24 | #define _TIMER_H 25 | 26 | #include 27 | 28 | typedef struct timeval timeval_t; 29 | 30 | /* Global vars */ 31 | extern timeval_t time_now; 32 | 33 | /* Some defines */ 34 | #define TIME_MAX_FORWARD_US 2000000 35 | #define TIMER_HZ 1000000 36 | #define TIMER_MAX_SEC 1000 37 | 38 | /* Some usefull macros */ 39 | #define timer_sec(T) ((T).tv_sec) 40 | #define timer_long(T) ((T).tv_sec * TIMER_HZ + (T).tv_usec) 41 | #define timer_isnull(T) ((T).tv_sec == 0 && (T).tv_usec == 0) 42 | #define timer_reset(T) (memset(&(T), 0, sizeof(timeval_t))) 43 | 44 | /* prototypes */ 45 | extern timeval_t timer_now(void); 46 | extern timeval_t set_time_now(void); 47 | extern timeval_t timer_dup(timeval_t); 48 | extern int timer_cmp(timeval_t, timeval_t); 49 | extern timeval_t timer_sub(timeval_t, timeval_t); 50 | extern timeval_t timer_add_long(timeval_t, long); 51 | extern timeval_t timer_sub_now(timeval_t); 52 | extern void timer_dump(timeval_t); 53 | extern unsigned long timer_tol(timeval_t); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.4/libipvs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libipvs.h: header file for the library ipvs 3 | * 4 | * Version: $Id: libipvs.h,v 1.3 2002/07/09 14:41:19 wensong Exp $ 5 | * 6 | * Authors: Wensong Zhang 7 | * 8 | */ 9 | 10 | #ifndef _LIBIPVS_H 11 | #define _LIBIPVS_H 12 | 13 | #include 14 | 15 | /* 16 | * The default IPVS_SVC_PERSISTENT_TIMEOUT is a little larger than average 17 | * connection time plus IPVS TCP FIN timeout (2*60 seconds). Because the 18 | * connection template won't be released until its controlled connection 19 | * entries are expired. 20 | * If IPVS_SVC_PERSISTENT_TIMEOUT is too less, the template will expire 21 | * soon and will be put in expire again and again, which causes additional 22 | * overhead. If it is too large, the same will always visit the same 23 | * server, which may make dynamic load imbalance worse. 24 | */ 25 | #define IPVS_SVC_PERSISTENT_TIMEOUT (6*60) 26 | 27 | /* ipvs info variable */ 28 | extern struct ip_vs_getinfo ipvs_info; 29 | 30 | /* init socket and get ipvs info */ 31 | extern int ipvs_init(void); 32 | 33 | /* get ipvs info separately */ 34 | extern int ipvs_getinfo(void); 35 | 36 | /* get the version number */ 37 | extern unsigned int ipvs_version(void); 38 | 39 | /* set command */ 40 | extern int ipvs_command(int cmd, struct ip_vs_rule_user *urule); 41 | 42 | /* get all the ipvs services */ 43 | extern struct ip_vs_get_services *ipvs_get_services(void); 44 | 45 | /* get the destination array of the specified service */ 46 | extern struct ip_vs_get_dests *ipvs_get_dests(struct ip_vs_service_user *svc); 47 | 48 | /* get ipvs service */ 49 | extern struct ip_vs_service_user * 50 | ipvs_get_service(u_int32_t fwmark, u_int16_t protocol, u_int32_t vaddr, u_int16_t vport); 51 | 52 | /* get ipvs timeout */ 53 | extern struct ip_vs_timeout_user *ipvs_get_timeouts(void); 54 | 55 | /* get ipvs daemon information */ 56 | extern struct ip_vs_daemon_user *ipvs_get_daemon(void); 57 | 58 | /* close the socket */ 59 | extern void ipvs_close(void); 60 | 61 | extern const char *ipvs_strerror(int err); 62 | 63 | #endif /* _LIBIPVS_H */ 64 | -------------------------------------------------------------------------------- /include/conf/inetaddr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #ifndef __DPVS_INETADDR_CONF_H__ 19 | #define __DPVS_INETADDR_CONF_H__ 20 | #include 21 | #include 22 | #include "inet.h" 23 | #include "net/if.h" 24 | 25 | enum { 26 | /* set */ 27 | SOCKOPT_SET_IFADDR_ADD = 400, 28 | SOCKOPT_SET_IFADDR_DEL, 29 | SOCKOPT_SET_IFADDR_SET, 30 | SOCKOPT_SET_IFADDR_FLUSH, 31 | 32 | /* get */ 33 | SOCKOPT_GET_IFADDR_SHOW, 34 | }; 35 | 36 | enum { 37 | IFA_SCOPE_GLOBAL = 0, 38 | IFA_SCOPE_SITE, /* IPv6 only */ 39 | IFA_SCOPE_LINK, /* link local */ 40 | IFA_SCOPE_HOST, /* valid inside the host */ 41 | IFA_SCOPE_NONE = 255, 42 | }; 43 | 44 | /* leverage IFA_F_XXX in linux/if_addr.h*/ 45 | #define IFA_F_SAPOOL 0x10000 /* if address with sockaddr pool */ 46 | 47 | struct inet_addr_param { 48 | int af; 49 | char ifname[IFNAMSIZ]; 50 | union inet_addr addr; 51 | uint8_t plen; 52 | union inet_addr bcast; 53 | uint32_t valid_lft; 54 | uint32_t prefered_lft; 55 | uint8_t scope; 56 | uint32_t flags; 57 | 58 | uint32_t sa_used; 59 | uint32_t sa_free; 60 | uint32_t sa_miss; 61 | } __attribute__((__packed__)); 62 | 63 | struct inet_addr_param_array { 64 | int naddr; 65 | struct inet_addr_param addrs[0]; 66 | }; 67 | 68 | #endif /* __DPVS_INETADDR_CONF_H__ */ 69 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Perform a GET query to a remote HTTP/HTTPS server. 3 | * Set a timer to compute global remote server response 4 | * time. 5 | * 6 | * Part: Hash-related declarations (to break circular deps). 7 | * 8 | * Version: hash.h 2013/07/22 9 | * 10 | * Authors: Jan Pokorny, 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the GNU General Public License for more details. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 20 | * 2 of the License, or (at your option) any later version. 21 | * 22 | * Copyright 2013 Red Hat, Inc. 23 | */ 24 | 25 | #ifndef _HASH_H 26 | #define _HASH_H 27 | 28 | #include 29 | #ifdef FEAT_SHA1 30 | # include 31 | #endif 32 | 33 | /* available hashes enumeration */ 34 | enum feat_hashes { 35 | hash_first, 36 | hash_md5 = hash_first, 37 | #ifdef FEAT_SHA1 38 | hash_sha1, 39 | #endif 40 | hash_guard, 41 | hash_default = hash_md5, 42 | }; 43 | 44 | typedef union { 45 | MD5_CTX md5; 46 | #ifdef FEAT_SHA1 47 | SHA_CTX sha; 48 | #endif 49 | /* this is due to poor C standard/draft wording (wrapped): 50 | https://groups.google.com/forum/#!msg/comp.lang.c/ 51 | 1kQMGXhgn4I/0VBEYG_ji44J */ 52 | char *dummy; 53 | } hash_context_t; 54 | 55 | typedef void (*hash_init_f)(hash_context_t *); 56 | typedef void (*hash_update_f)(hash_context_t *, const void *, unsigned long); 57 | typedef void (*hash_final_f)(unsigned char *, hash_context_t *); 58 | 59 | typedef struct { 60 | hash_init_f init; 61 | hash_update_f update; 62 | hash_final_f final; 63 | unsigned char length; /* length of the digest */ 64 | const char *id; /* command-line handing + help*/ 65 | const char *label; /* final output */ 66 | } hash_t; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /tools/qnatsh/nsh_serv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * QNAT is a software NAT based on DPDK and DPVS. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | #ifndef _NSH_SERV_H__20190605__FL_ 17 | #define _NSH_SERV_H__20190605__FL_ 18 | 19 | #include "nsh_cmd.h" 20 | 21 | struct poolnames_st 22 | { 23 | struct list_head pool_list; 24 | char poolname[64]; 25 | }; 26 | 27 | struct serv_info_st 28 | { 29 | struct list_head serv_list; 30 | struct nat_service_ipc *servinfo; 31 | struct list_head pools; 32 | }; 33 | 34 | struct member_info_st 35 | { 36 | struct list_head member_list; 37 | unsigned int min_ip; 38 | unsigned int max_ip; 39 | unsigned int masklen; 40 | }; 41 | 42 | struct pool_info_st 43 | { 44 | struct list_head pool_list; 45 | struct list_head members; 46 | char poolname[64]; 47 | }; 48 | 49 | struct serv_info_st *get_serv_info(struct nat_service_ipc *servinfo); 50 | struct nat_service_ipc * add_serv_to_list(struct nat_service_ipc *servinfo); 51 | void remove_serv_from_list(struct serv_info_st *serv); 52 | struct pool_info_st *get_pool_by_name(char *name); 53 | struct pool_info_st *create_pool_by_name(char *name); 54 | void remove_pool(struct pool_info_st *pool); 55 | struct member_info_st *get_member_by_ip(struct pool_info_st *pool, unsigned int minip, unsigned int maxip); 56 | struct member_info_st *create_member(struct pool_info_st *pool, unsigned int minip, unsigned int maxip); 57 | void remove_member(struct member_info_st *member); 58 | int get_member_count(char *poolname); 59 | int is_ip_in_pool(struct pool_info_st *pool, unsigned int ip); 60 | void clear_serv_config(void); 61 | void clear_pool_config(void); 62 | void init_nat_serv(void); 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /include/conf/route.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | /** 19 | * Note: control plane only 20 | * based on dpvs_sockopt. 21 | */ 22 | #ifndef __DPVS_ROUTE_CONF_H__ 23 | #define __DPVS_ROUTE_CONF_H__ 24 | #include "inet.h" 25 | #include "net/if.h" 26 | 27 | enum { 28 | /* set */ 29 | SOCKOPT_SET_ROUTE_ADD = 300, 30 | SOCKOPT_SET_ROUTE_DEL, 31 | SOCKOPT_SET_ROUTE_SET, 32 | SOCKOPT_SET_ROUTE_FLUSH, 33 | 34 | /* get */ 35 | SOCKOPT_GET_ROUTE_SHOW, 36 | }; 37 | 38 | enum { 39 | ROUTE_CF_SCOPE_NONE = 0, 40 | ROUTE_CF_SCOPE_HOST, 41 | ROUTE_CF_SCOPE_KNI, 42 | ROUTE_CF_SCOPE_LINK, 43 | ROUTE_CF_SCOPE_GLOBAL, 44 | }; 45 | 46 | enum { 47 | ROUTE_CF_PROTO_AUTO = 0, 48 | ROUTE_CF_PROTO_BOOT, 49 | ROUTE_CF_PROTO_STATIC, 50 | ROUTE_CF_PROTO_RA, 51 | ROUTE_CF_PROTO_REDIRECT, 52 | }; 53 | 54 | enum { 55 | ROUTE_CF_FLAG_ONLINK, 56 | }; 57 | 58 | struct dp_vs_route_conf { 59 | int af; 60 | union inet_addr dst; /* all-zero for default */ 61 | uint8_t plen; /* prefix length */ 62 | union inet_addr via; 63 | union inet_addr src; 64 | char ifname[IFNAMSIZ]; 65 | uint32_t mtu; 66 | uint8_t tos; 67 | uint8_t scope; 68 | uint8_t metric; 69 | uint8_t proto; /* routing protocol */ 70 | uint32_t flags; 71 | } __attribute__((__packed__)); 72 | 73 | struct dp_vs_route_conf_array { 74 | int nroute; 75 | struct dp_vs_route_conf routes[0]; 76 | } __attribute__((__packed__)); 77 | 78 | #endif /* __DPVS_ROUTE_CONF_H__ */ 79 | -------------------------------------------------------------------------------- /include/netif_addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | /** 19 | * netif unicast multicast hw address list setting. 20 | * XXX: currently, support multicast list only. 21 | * 22 | * Lei Chen , Aug. 2017, initial. 23 | */ 24 | #ifndef __DPVS_NETIF_ADDR_H__ 25 | #define __DPVS_NETIF_ADDR_H__ 26 | #include "netif.h" 27 | 28 | int __netif_mc_add(struct netif_port *dev, const struct ether_addr *addr); 29 | int __netif_mc_del(struct netif_port *dev, const struct ether_addr *addr); 30 | int netif_mc_add(struct netif_port *dev, const struct ether_addr *addr); 31 | int netif_mc_del(struct netif_port *dev, const struct ether_addr *addr); 32 | void netif_mc_flush(struct netif_port *dev); 33 | void netif_mc_init(struct netif_port *dev); 34 | int __netif_mc_dump(struct netif_port *dev, 35 | struct ether_addr *addrs, size_t *naddr); 36 | int netif_mc_dump(struct netif_port *dev, 37 | struct ether_addr *addrs, size_t *naddr); 38 | 39 | int __netif_mc_sync(struct netif_port *to, struct netif_port *from); 40 | int netif_mc_sync(struct netif_port *to, struct netif_port *from); 41 | int __netif_mc_unsync(struct netif_port *to, struct netif_port *from); 42 | int netif_mc_unsync(struct netif_port *to, struct netif_port *from); 43 | 44 | int __netif_mc_sync_multiple(struct netif_port *to, struct netif_port *from); 45 | int netif_mc_sync_multiple(struct netif_port *to, struct netif_port *from); 46 | int __netif_mc_unsync_multiple(struct netif_port *to, struct netif_port *from); 47 | int netif_mc_unsync_multiple(struct netif_port *to, struct netif_port *from); 48 | 49 | #endif /* __DPVS_NETIF_ADDR_H__ */ 50 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_scheduler.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_SCHEDULER_H 24 | #define _VRRP_SCHEDULER_H 25 | 26 | /* system include */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* local includes */ 34 | #include "scheduler.h" 35 | #include "list.h" 36 | #include "vrrp_data.h" 37 | 38 | /* VRRP FSM Macro */ 39 | #define VRRP_FSM_READ_TO(V) \ 40 | do { \ 41 | if ((*(VRRP_FSM[(V)->state].read_to))) \ 42 | (*(VRRP_FSM[(V)->state].read_to)) (V); \ 43 | } while (0) 44 | 45 | #define VRRP_FSM_READ(V, B, L) \ 46 | do { \ 47 | if ((*(VRRP_FSM[(V)->state].read))) \ 48 | (*(VRRP_FSM[(V)->state].read)) (V, B, L); \ 49 | } while (0) 50 | 51 | /* VRRP TSM Macro */ 52 | #define VRRP_TSM_HANDLE(S,V) \ 53 | do { \ 54 | if ((V)->sync && \ 55 | S != VRRP_STATE_GOTO_MASTER) \ 56 | if ((*(VRRP_TSM[S][(V)->state].handler))) \ 57 | (*(VRRP_TSM[S][(V)->state].handler)) (V); \ 58 | } while (0) 59 | 60 | /* extern prototypes */ 61 | extern void vrrp_dispatcher_release(vrrp_data_t *); 62 | extern int vrrp_dispatcher_init(thread_t *); 63 | extern int vrrp_read_dispatcher_thread(thread_t *); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /tools/dpip/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2017 iQIYI (www.iqiyi.com). 5 | * All Rights Reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include "common.h" 22 | #include "dpip.h" 23 | 24 | const char *af_itoa(int af) 25 | { 26 | struct { 27 | uint8_t i_af; 28 | const char *s_af; 29 | } family_tab[] = { 30 | { AF_INET, "inet" }, 31 | { AF_INET6, "inet6" }, 32 | { AF_UNSPEC, "unspec" }, 33 | }; 34 | int i; 35 | 36 | for (i = 0; i < NELEMS(family_tab); i++) { 37 | if (af == family_tab[i].i_af) 38 | return family_tab[i].s_af; 39 | } 40 | 41 | return ""; 42 | } 43 | 44 | bool inet_is_addr_any(int af, const union inet_addr *addr) 45 | { 46 | switch (af) { 47 | case AF_INET: 48 | return addr->in.s_addr == htonl(INADDR_ANY); 49 | case AF_INET6: 50 | return IN6_ARE_ADDR_EQUAL(&addr->in6, &in6addr_any); 51 | default: 52 | return false; /* ? */ 53 | } 54 | } 55 | 56 | int inet_pton_try(int *af, const char *src, union inet_addr *dst) 57 | { 58 | int err; 59 | 60 | if (*af == AF_INET) 61 | err = inet_pton(AF_INET, src, &dst->in); 62 | else if (*af == AF_INET6) 63 | err = inet_pton(AF_INET6, src, &dst->in6); 64 | else { 65 | if ((err = inet_pton(AF_INET, src, &dst->in)) > 0) 66 | *af = AF_INET; 67 | else if ((err = inet_pton(AF_INET6, src, &dst->in6)) > 0) 68 | *af = AF_INET6; 69 | else 70 | *af = AF_UNSPEC; 71 | } 72 | 73 | if (err <= 0) 74 | fprintf(stderr, "invalid ipaddress: %s %s\n", af_itoa(*af), src); 75 | 76 | return err; 77 | } 78 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/core/daemon.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: Main program structure. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #include 24 | #include "daemon.h" 25 | #include "logger.h" 26 | #include "utils.h" 27 | 28 | /* Daemonization function coming from zebra source code */ 29 | pid_t 30 | xdaemon(int nochdir, int noclose, int exitflag) 31 | { 32 | pid_t pid; 33 | int ret; 34 | 35 | /* In case of fork is error. */ 36 | pid = fork(); 37 | if (pid < 0) { 38 | log_message(LOG_INFO, "xdaemon: fork error"); 39 | return -1; 40 | } 41 | 42 | /* In case of this is parent process. */ 43 | if (pid != 0) { 44 | if (!exitflag) 45 | exit(0); 46 | else 47 | return pid; 48 | } 49 | 50 | /* Become session leader and get pid. */ 51 | pid = setsid(); 52 | if (pid < -1) { 53 | log_message(LOG_INFO, "xdaemon: setsid error"); 54 | return -1; 55 | } 56 | 57 | /* Change directory to root. */ 58 | if (!nochdir) { 59 | ret = chdir("/"); 60 | if (ret < 0) { 61 | log_message(LOG_INFO, "xdaemon: chdir error"); 62 | } 63 | } 64 | 65 | /* File descriptor close. */ 66 | if (!noclose) { 67 | int fd; 68 | 69 | fd = open("/dev/null", O_RDWR, 0); 70 | if (fd != -1) { 71 | dup2(fd, STDIN_FILENO); 72 | dup2(fd, STDOUT_FILENO); 73 | dup2(fd, STDERR_FILENO); 74 | if (fd > 2) 75 | close(fd); 76 | } 77 | } 78 | 79 | umask(0); 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/libipvs-2.6/test.c: -------------------------------------------------------------------------------- 1 | #include "sockopt.h" 2 | #include 3 | 4 | #define SOCKOPT_MSG_BASE 23 5 | 6 | #define SOCKOPT_MSG_SET_CMD_1 SOCKOPT_MSG_BASE + 1 7 | #define SOCKOPT_MSG_SET_CMD_2 SOCKOPT_MSG_BASE + 2 8 | #define SOCKOPT_MSG_SET_CMD_3 SOCKOPT_MSG_BASE + 3 9 | #define SOCKOPT_MSG_SET_CMD_MAX SOCKOPT_MSG_SET_CMD_3 + 1 10 | 11 | #define SOCKOPT_MSG_GET_CMD_1 SOCKOPT_MSG_BASE + 1 12 | #define SOCKOPT_MSG_GET_CMD_2 SOCKOPT_MSG_BASE + 2 13 | #define SOCKOPT_MSG_GET_CMD_3 SOCKOPT_MSG_BASE + 3 14 | #define SOCKOPT_MSG_GET_CMD_MAX SOCKOPT_MSG_GET_CMD_3 + 1 15 | 16 | static void send_set_msg(sockoptid_t cmd, char *in, size_t in_len) 17 | { 18 | printf("[%s] send set msg #%u (len=%u): %s\n", __func__, cmd, in_len, in); 19 | dpvs_setsockopt(cmd, in, in_len); 20 | } 21 | 22 | static void send_get_msg(sockoptid_t cmd, char *in, size_t in_len) 23 | { 24 | void *out; 25 | size_t out_len; 26 | 27 | printf("[%s] send get msg #%u (len=%u): %s\n", __func__, cmd, in_len, in); 28 | dpvs_getsockopt(cmd, in, in_len, &out, &out_len); 29 | if (out) { 30 | printf("[%s] get msg #%u reply:%s\n", __func__, cmd, (char *)out); 31 | dpvs_sockopt_msg_free(out); 32 | } else 33 | printf("[%s] fail to recieve get msg#%u reply\n", __func__, cmd); 34 | } 35 | 36 | 37 | int main(void) 38 | { 39 | char buf[SOCKOPT_MSG_BUFFER_SIZE]; 40 | size_t out_len = SOCKOPT_MSG_BUFFER_SIZE; 41 | 42 | printf("Start ...\n"); 43 | sprintf(buf, "Hello, I'm set#%u", SOCKOPT_MSG_SET_CMD_1); 44 | send_set_msg(SOCKOPT_MSG_SET_CMD_1, buf, strlen(buf) + 1); 45 | sprintf(buf, "Hello, I'm set#%u", SOCKOPT_MSG_SET_CMD_2); 46 | send_set_msg(SOCKOPT_MSG_SET_CMD_2, buf, strlen(buf) + 1); 47 | sprintf(buf, "Hello, I'm set#%u", SOCKOPT_MSG_SET_CMD_3); 48 | send_set_msg(SOCKOPT_MSG_SET_CMD_3, buf, strlen(buf) + 1); 49 | 50 | sprintf(buf, "Hello, I'm get#%u", SOCKOPT_MSG_GET_CMD_1); 51 | send_get_msg(SOCKOPT_MSG_SET_CMD_1, buf, strlen(buf) + 1); 52 | sprintf(buf, "Hello, I'm get#%u", SOCKOPT_MSG_GET_CMD_2); 53 | send_get_msg(SOCKOPT_MSG_SET_CMD_2, buf, strlen(buf) + 1); 54 | sprintf(buf, "Hello, I'm get#%u", SOCKOPT_MSG_GET_CMD_3); 55 | send_get_msg(SOCKOPT_MSG_SET_CMD_3, buf, strlen(buf) + 1); 56 | printf("End ...\n"); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /tools/keepalived/doc/samples/keepalived.conf.vrrp.sync: -------------------------------------------------------------------------------- 1 | ! Configuration File for keepalived 2 | 3 | vrrp_sync_group G1 { 4 | group { 5 | VI_1 6 | VI_2 7 | VI_5 8 | VI_6 9 | VI_7 10 | VI_8 11 | VI_9 12 | } 13 | notify_backup "/usr/local/bin/vrrp.back arg1 arg2" 14 | notify_master "/usr/local/bin/vrrp.mast arg1 arg2" 15 | notify_fault "/usr/local/bin/vrrp.fault arg1 arg2" 16 | } 17 | 18 | vrrp_sync_group G2 { 19 | group { 20 | VI_3 21 | VI_4 22 | } 23 | } 24 | 25 | vrrp_instance VI_1 { 26 | interface eth0 27 | state MASTER 28 | virtual_router_id 51 29 | priority 100 30 | virtual_ipaddress { 31 | 192.168.200.18/25 32 | } 33 | } 34 | 35 | vrrp_instance VI_2 { 36 | interface eth1 37 | state MASTER 38 | virtual_router_id 52 39 | priority 100 40 | virtual_ipaddress { 41 | 192.168.201.18/26 42 | } 43 | } 44 | 45 | vrrp_instance VI_3 { 46 | interface eth0 47 | virtual_router_id 53 48 | priority 100 49 | virtual_ipaddress { 50 | 192.168.200.19/27 51 | } 52 | } 53 | 54 | vrrp_instance VI_4 { 55 | interface eth1 56 | virtual_router_id 54 57 | priority 100 58 | virtual_ipaddress { 59 | 192.168.201.19/28 60 | } 61 | } 62 | 63 | vrrp_instance VI_5 { 64 | state MASTER 65 | interface eth0 66 | virtual_router_id 55 67 | priority 100 68 | virtual_ipaddress { 69 | 192.168.200.20/27 70 | } 71 | } 72 | 73 | 74 | vrrp_instance VI_6 { 75 | state MASTER 76 | interface eth0 77 | virtual_router_id 56 78 | priority 100 79 | virtual_ipaddress { 80 | 192.168.200.21/27 81 | } 82 | } 83 | 84 | vrrp_instance VI_7 { 85 | state MASTER 86 | interface eth0 87 | virtual_router_id 57 88 | priority 100 89 | virtual_ipaddress { 90 | 192.168.200.22/27 91 | } 92 | } 93 | 94 | vrrp_instance VI_8 { 95 | state MASTER 96 | interface eth0 97 | virtual_router_id 58 98 | priority 100 99 | virtual_ipaddress { 100 | 192.168.200.23/27 101 | } 102 | } 103 | 104 | vrrp_instance VI_9 { 105 | state MASTER 106 | interface eth0 107 | virtual_router_id 59 108 | priority 100 109 | virtual_ipaddress { 110 | 192.168.200.24/27 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/global_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: Dynamic data structure definition. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _GLOBAL_DATA_H 24 | #define _GLOBAL_DATA_H 25 | 26 | /* system includes */ 27 | #include 28 | #include 29 | #include 30 | 31 | /* local includes */ 32 | #include "list.h" 33 | #include "timer.h" 34 | 35 | /* constants */ 36 | #define DEFAULT_SMTP_SERVER 0x7f000001 37 | #define DEFAULT_SMTP_CONNECTION_TIMEOUT (30 * TIMER_HZ) 38 | #define DEFAULT_PLUGIN_DIR "/etc/keepalived/plugins" 39 | 40 | /* email link list */ 41 | typedef struct _email { 42 | char *addr; 43 | } email_t; 44 | 45 | /* Configuration data root */ 46 | typedef struct _data { 47 | int linkbeat_use_polling; 48 | char *router_id; 49 | char *plugin_dir; 50 | char *email_from; 51 | struct sockaddr_storage smtp_server; 52 | long smtp_connection_to; 53 | list email; 54 | struct sockaddr_storage vrrp_mcast_group4; 55 | struct sockaddr_storage vrrp_mcast_group6; 56 | #ifdef _WITH_SNMP_ 57 | int enable_traps; 58 | #endif 59 | } data_t; 60 | 61 | /* Global vars exported */ 62 | extern data_t *global_data; /* Global configuration data */ 63 | 64 | /* Prototypes */ 65 | extern void alloc_email(char *); 66 | extern data_t *alloc_global_data(void); 67 | extern void init_global_data(data_t *); 68 | extern void free_global_data(data_t *); 69 | extern void dump_global_data(data_t *); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/readline/rlconf.h: -------------------------------------------------------------------------------- 1 | /* rlconf.h -- readline configuration definitions */ 2 | 3 | /* Copyright (C) 1992-2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #if !defined (_RLCONF_H_) 23 | #define _RLCONF_H_ 24 | 25 | /* Define this if you want the vi-mode editing available. */ 26 | #define VI_MODE 27 | 28 | /* Define this to get an indication of file type when listing completions. */ 29 | #define VISIBLE_STATS 30 | 31 | /* This definition is needed by readline.c, rltty.c, and signals.c. */ 32 | /* If on, then readline handles signals in a way that doesn't screw. */ 33 | #define HANDLE_SIGNALS 34 | 35 | /* Ugly but working hack for binding prefix meta. */ 36 | #define PREFIX_META_HACK 37 | 38 | /* The next-to-last-ditch effort file name for a user-specific init file. */ 39 | #define DEFAULT_INPUTRC "~/.inputrc" 40 | 41 | /* The ultimate last-ditch filenname for an init file -- system-wide. */ 42 | #define SYS_INPUTRC "/etc/inputrc" 43 | 44 | /* If defined, expand tabs to spaces. */ 45 | #define DISPLAY_TABS 46 | 47 | /* If defined, use the terminal escape sequence to move the cursor forward 48 | over a character when updating the line rather than rewriting it. */ 49 | /* #define HACK_TERMCAP_MOTION */ 50 | 51 | /* The string inserted by the `insert comment' command. */ 52 | #define RL_COMMENT_BEGIN_DEFAULT "#" 53 | 54 | /* Define this if you want code that allows readline to be used in an 55 | X `callback' style. */ 56 | #define READLINE_CALLBACKS 57 | 58 | /* Define this if you want the cursor to indicate insert or overwrite mode. */ 59 | /* #define CURSOR_MODE */ 60 | 61 | #endif /* _RLCONF_H_ */ 62 | -------------------------------------------------------------------------------- /tools/keepalived/lib/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: list.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _LIST_H 24 | #define _LIST_H 25 | 26 | /* list definition */ 27 | typedef struct _element *element; 28 | typedef struct _list *list; 29 | 30 | struct _element { 31 | struct _element *next; 32 | struct _element *prev; 33 | void *data; 34 | }; 35 | 36 | struct _list { 37 | struct _element *head; 38 | struct _element *tail; 39 | unsigned int count; 40 | void (*free) (void *); 41 | void (*dump) (void *); 42 | }; 43 | 44 | /* utility macro */ 45 | #define ELEMENT_NEXT(E) ((E) = (E)->next) 46 | #define ELEMENT_DATA(E) ((E)->data) 47 | #define LIST_HEAD(L) ((L)->head) 48 | #define LIST_TAIL_DATA(L) ((L)->tail->data) 49 | #define LIST_ISEMPTY(L) ((L) == NULL || ((L)->head == NULL && (L)->tail == NULL)) 50 | #define LIST_SIZE(V) ((V)->count) 51 | 52 | /* Prototypes */ 53 | extern list alloc_list(void (*free_func) (void *), void (*dump_func) (void *)); 54 | extern void free_list(list l); 55 | extern void free_list_elements(list l); 56 | extern void free_list_element(list l, element e); 57 | extern void *list_element(list l, int num); 58 | extern void dump_list(list l); 59 | extern void list_add(list l, void *data); 60 | extern void list_del(list l, void *data); 61 | extern list alloc_mlist(void (*free_func) (void *), void (*dump_func) (void *), int size); 62 | extern void dump_mlist(list l, int size); 63 | extern void free_mlist(list l, int size); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /tools/qnatsh/lib/vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generic vector interface header. 3 | * Copyright (C) 1997, 98 Kunihiro Ishiguro 4 | * 5 | * This file is part of GNU Zebra. 6 | * 7 | * GNU Zebra is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2, or (at your option) any 10 | * later version. 11 | * 12 | * GNU Zebra is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 | * 02111-1307, USA. 21 | */ 22 | 23 | #ifndef _ZEBRA_VECTOR_H 24 | #define _ZEBRA_VECTOR_H 25 | 26 | /* struct for vector */ 27 | struct _vector 28 | { 29 | unsigned int active; /* number of active slots */ 30 | unsigned int alloced; /* number of allocated slot */ 31 | void **index; /* index to data */ 32 | }; 33 | typedef struct _vector *vector; 34 | 35 | #define VECTOR_MIN_SIZE 1 36 | 37 | /* (Sometimes) usefull macros. This macro convert index expression to 38 | array expression. */ 39 | /* Reference slot at given index, caller must ensure slot is active */ 40 | #define vector_slot(V,I) ((V)->index[(I)]) 41 | /* Number of active slots. 42 | * Note that this differs from vector_count() as it the count returned 43 | * will include any empty slots 44 | */ 45 | #define vector_active(V) ((V)->active) 46 | 47 | /* Prototypes. */ 48 | extern vector vector_init (unsigned int size); 49 | extern void vector_ensure (vector v, unsigned int num); 50 | extern int vector_empty_slot (vector v); 51 | extern int vector_set (vector v, void *val); 52 | extern int vector_set_index (vector v, unsigned int i, void *val); 53 | extern void vector_unset (vector v, unsigned int i); 54 | extern unsigned int vector_count (vector v); 55 | extern void vector_only_wrapper_free (vector v); 56 | extern void vector_only_index_free (void *index); 57 | extern void vector_free (vector v); 58 | extern vector vector_copy (vector v); 59 | 60 | extern void *vector_lookup (vector, unsigned int); 61 | extern void *vector_lookup_ensure (vector, unsigned int); 62 | 63 | #endif /* _ZEBRA_VECTOR_H */ 64 | -------------------------------------------------------------------------------- /tools/keepalived/keepalived/include/vrrp_arp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Soft: Keepalived is a failover program for the LVS project 3 | * . It monitor & manipulate 4 | * a loadbalanced server pool using multi-layer checks. 5 | * 6 | * Part: vrrp_arp.c include file. 7 | * 8 | * Author: Alexandre Cassen, 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | * 20 | * Copyright (C) 2001-2012 Alexandre Cassen, 21 | */ 22 | 23 | #ifndef _VRRP_ARP_H 24 | #define _VRRP_ARP_H 25 | 26 | /* system includes */ 27 | #include 28 | #include 29 | 30 | /* local includes */ 31 | #include "vrrp_ipaddress.h" 32 | 33 | #include "../libipvs-2.6/libipvs.h" 34 | 35 | /* local definitions */ 36 | #define ETHERNET_HW_LEN 6 37 | #define IPPROTO_ADDR_LEN 4 38 | 39 | /* types definition */ 40 | typedef struct _arphdr { 41 | unsigned short int ar_hrd; /* Format of hardware address. */ 42 | unsigned short int ar_pro; /* Format of protocol address. */ 43 | unsigned char ar_hln; /* Length of hardware address. */ 44 | unsigned char ar_pln; /* Length of protocol address. */ 45 | unsigned short int ar_op; /* ARP opcode (command). */ 46 | 47 | /* Ethernet looks like this : This bit is variable sized however... */ 48 | unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */ 49 | unsigned char __ar_sip[4]; /* Sender IP address. */ 50 | unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */ 51 | unsigned char __ar_tip[4]; /* Target IP address. */ 52 | } arphdr_t; 53 | 54 | /* Global vars exported */ 55 | extern char *garp_buffer; 56 | extern int garp_fd; 57 | 58 | /* prototypes */ 59 | extern void gratuitous_arp_init(void); 60 | extern void gratuitous_arp_close(void); 61 | extern int send_gratuitous_arp(ip_address_t *); 62 | 63 | #endif 64 | --------------------------------------------------------------------------------