├── tools ├── 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 │ │ └── .gitkeep │ ├── VERSION │ ├── genhash │ │ ├── VERSION │ │ ├── AUTHOR │ │ ├── README │ │ ├── ChangeLog │ │ ├── ssl.h │ │ ├── sock.h │ │ ├── Makefile.in │ │ ├── sock.c │ │ ├── layer4.h │ │ └── 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 │ │ └── man │ │ │ └── man1 │ │ │ └── genhash.1 │ ├── keepalived │ │ ├── libipvs-2.4 │ │ │ ├── Makefile.in │ │ │ └── libipvs.h │ │ ├── libipvs-2.6 │ │ │ ├── Makefile.in │ │ │ ├── dp_vs.h │ │ │ └── sockopt.h │ │ ├── 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 │ │ ├── core │ │ │ └── Makefile.in │ │ └── vrrp │ │ │ └── vrrp_arp.c │ ├── CONTRIBUTORS │ ├── README │ ├── lib │ │ ├── logger.h │ │ ├── notify.h │ │ ├── Makefile.in │ │ ├── html.h │ │ ├── config.h.in │ │ ├── signals.h │ │ ├── logger.c │ │ └── timer.h │ ├── Makefile.in │ └── INSTALL ├── lbdebug │ └── Makefile ├── Makefile └── dpip │ ├── Makefile │ ├── utils.h │ └── dpip.h ├── pic └── hdslb.png ├── test ├── fdir │ └── main.c └── mempool │ └── mp_test.c ├── doc └── pics │ ├── icx-cps.png │ ├── fnat-two-arm.png │ └── forward-pps.png ├── include ├── lb │ ├── rr.h │ ├── conhash.h │ ├── laddr.h │ ├── wrr.h │ ├── wlc.h │ ├── sync_debug.h │ ├── igmp.h │ ├── redirect.h │ ├── ipv4.h │ ├── ipv6.h │ ├── ip.h │ ├── core.h │ ├── icmp.h │ ├── tcp.h │ ├── redirect_conn_hash_table.h │ ├── udp.h │ ├── sched.h │ ├── xmit.h │ └── pipeline.h ├── sys_time.h ├── icmp6.h ├── ipvs │ ├── proto_icmp.h │ ├── fo.h │ ├── rr.h │ ├── wlc.h │ ├── wrr.h │ ├── conhash.h │ ├── proto_udp.h │ ├── nat64.h │ ├── blklst.h │ ├── ipvs.h │ ├── laddr.h │ ├── sched.h │ └── redirect.h ├── cfgfile.h ├── route6_hlist.h ├── route6_lpm.h ├── icmp.h ├── global_conf.h ├── ndisc.h ├── ipv4_frag.h ├── pidfile.h ├── conf │ ├── ipv6.h │ ├── ipset.h │ ├── vlan.h │ ├── blklst.h │ ├── route6.h │ ├── laddr.h │ └── inetaddr.h ├── parser │ └── utils.h ├── log.h ├── ipset.h ├── laddr_multiply.h └── kni.h ├── src ├── ipvs │ ├── libconhash │ │ ├── README.md │ │ ├── configure.h │ │ ├── README │ │ ├── conhash_util.c │ │ ├── conhash_inter.h │ │ └── LICENSE │ └── ip_vs_fo.c ├── VERSION ├── sys_time.c ├── laddr_multiply.c ├── pidfile.c └── dpdk.mk ├── security.md ├── Makefile ├── CONTRIBUTING.md ├── patch ├── dpdk-stable-19.11 │ └── 0002-support-large_memory.patch ├── dpdk-20.08 │ └── 0002-support-large_memory.patch ├── dpdk-stable-17.05.2 │ └── 0002-net-support-variable-IP-header-len-for-checksum-API.patch └── dpdk-stable-17.11.2 │ └── 0002-net-support-variable-IP-header-len-for-checksum-API.patch └── scripts ├── setup.tc.sample.sh └── setup.snat-gre.sample.sh /tools/ipvsadm/VERSION: -------------------------------------------------------------------------------- 1 | 1.27 2 | -------------------------------------------------------------------------------- /tools/keepalived/bin/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/ipvsadm/debian/files: -------------------------------------------------------------------------------- 1 | ipvsadm_1.25-ipv6-1_i386.deb net optional 2 | -------------------------------------------------------------------------------- /tools/keepalived/genhash/AUTHOR: -------------------------------------------------------------------------------- 1 | Alexandre Cassen, 2 | -------------------------------------------------------------------------------- /pic/hdslb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/high-density-scalable-load-balancer/HEAD/pic/hdslb.png -------------------------------------------------------------------------------- /tools/ipvsadm/debian/ipvsadm.substvars: -------------------------------------------------------------------------------- 1 | shlibs:Depends=libpopt0 (>= 1.10), libnl1, libc6 (>= 2.4) 2 | -------------------------------------------------------------------------------- /test/fdir/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/high-density-scalable-load-balancer/HEAD/test/fdir/main.c -------------------------------------------------------------------------------- /doc/pics/icx-cps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/high-density-scalable-load-balancer/HEAD/doc/pics/icx-cps.png -------------------------------------------------------------------------------- /tools/ipvsadm/ipvsadm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/high-density-scalable-load-balancer/HEAD/tools/ipvsadm/ipvsadm.c -------------------------------------------------------------------------------- /doc/pics/fnat-two-arm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/high-density-scalable-load-balancer/HEAD/doc/pics/fnat-two-arm.png -------------------------------------------------------------------------------- /doc/pics/forward-pps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/high-density-scalable-load-balancer/HEAD/doc/pics/forward-pps.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/rr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_RR_H__ 6 | #define __LB_RR_H__ 7 | 8 | int lb_rr_init(void); 9 | int lb_rr_term(void); 10 | 11 | #endif -------------------------------------------------------------------------------- /src/ipvs/libconhash/README.md: -------------------------------------------------------------------------------- 1 | References: 2 | ----------- 3 | a, Consistent hashing library comes from libconhash 4 | 5 | License: 6 | -------- 7 | Under GUN License 8 | -------------------------------------------------------------------------------- /include/lb/conhash.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_CH_H__ 6 | #define __LB_CH_H__ 7 | 8 | int lb_conhash_init(void); 9 | int lb_conhash_term(void); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/lb/laddr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_LADDR_H__ 6 | #define __LB_LADDR_H__ 7 | 8 | #include 9 | 10 | int lb_laddr_init(void); 11 | void lb_laddr_uninit(void); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/wrr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_WRR_H__ 6 | #define __LB_WRR_H__ 7 | 8 | #include "lb/service.h" 9 | #include "lb/dest.h" 10 | #include "lb/sched.h" 11 | 12 | int lb_wrr_init(void); 13 | int lb_wrr_term(void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/lb/wlc.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_WLC_H__ 6 | #define __LB_WLC_H__ 7 | 8 | #include "ipvs/service.h" 9 | #include "ipvs/dest.h" 10 | #include "ipvs/sched.h" 11 | 12 | int lb_wlc_init(void); 13 | int lb_wlc_term(void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/ipvs/libconhash/configure.h: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (C) 2010. sparkling.liang@hotmail.com. All rights reserved. */ 3 | 4 | #ifndef __CONFIGURE_H_ 5 | #define __CONFIGURE_H_ 6 | #include "dpdk.h" 7 | 8 | typedef unsigned int u_int; 9 | typedef unsigned char u_char; 10 | typedef long util_long; 11 | 12 | #endif /* end __CONFIGURE_H_ */ 13 | -------------------------------------------------------------------------------- /src/VERSION: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | # program: dpvs 3 | # Oct 8, 2019 4 | # Commit: 3d8f47575bd18ebfda88d83d869b36a18d2f49c1 5 | # "route6: fix some problems" 6 | # Features: 7 | # 1. add dummy info and backtrace for dpvs timer crash problem 8 | # 2. fix some problems in route6 9 | 10 | export VERSION=0.1 11 | export RELEASE=0 12 | 13 | echo $VERSION-$RELEASE 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/sync_debug.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __SYNC_DEBUG_H__ 6 | #define __SYNC_DEBUG_H__ 7 | 8 | union lb_sync_conn; 9 | 10 | void lb_sync_disp_sync_conn(union lb_sync_conn* sync_conn); 11 | void lb_sync_lcore_new_conns(unsigned int count); 12 | void lb_sync_lcore_simple_new_conns(unsigned int count); 13 | 14 | #endif -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/sys_time.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_DPVS_TIME_H_ 2 | #define _SYS_DPVS_TIME_H_ 3 | #include 4 | #include 5 | #include "dpdk.h" 6 | 7 | #define SYS_TIME_STR_LEN (64) 8 | 9 | char* sys_localtime_str(char* stime, int len); 10 | char* cycles_to_stime(uint64_t cycles, char* stime, int len); 11 | time_t sys_current_time(void); 12 | void sys_start_time(void); 13 | 14 | #endif /* _SYS_DPVS_TIME_H_ */ 15 | -------------------------------------------------------------------------------- /security.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. 3 | 4 | ## Reporting a Vulnerability 5 | Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/igmp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __IGMP_H__ 6 | #define __IGMP_H__ 7 | 8 | struct netif_port; 9 | struct in_addr; 10 | struct rte_ether_addr; 11 | 12 | int igmp_join_group(struct netif_port *port 13 | , const struct in_addr *mc_addr 14 | , const struct in_addr *src_addr); 15 | 16 | int igmp_leave_group(struct netif_port* port 17 | , const struct in_addr* mc_addr 18 | , const struct in_addr* src_addr); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/lb/redirect.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_REDIRECT_H__ 6 | #define __LB_REDIRECT_H__ 7 | 8 | #include "common.h" 9 | #include "core.h" 10 | #include "list.h" 11 | #include "dpdk.h" 12 | #include "netif.h" 13 | 14 | int lb_redirect_pkt(struct rte_mbuf *mbuf, lcoreid_t peer_cid); 15 | void lb_redirect_ring_proc(struct netif_queue_conf *qconf, lcoreid_t cid); 16 | int lb_redirect_init(void); 17 | void lb_redirect_term(void); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/icmp6.h: -------------------------------------------------------------------------------- 1 | #ifndef __DPVS_ICMPV6_H__ 2 | #define __DPVS_ICMPV6_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define icmp6h_id(icmp6h) ((icmp6h)->icmp6_dataun.icmp6_un_data16[0]) 8 | void icmp6_send(struct rte_mbuf *imbuf, int type, int code, uint32_t info); 9 | uint16_t icmp6_csum(struct ip6_hdr *iph, struct icmp6_hdr *ich); 10 | void icmp6_send_csum(struct ip6_hdr *shdr, struct icmp6_hdr *ich); 11 | 12 | int icmpv6_init(void); 13 | int icmpv6_term(void); 14 | 15 | #endif /* __DPVS_ICMPV6_H__ */ 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/ipv4.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_IPV4_H__ 6 | #define __LB_IPV4_H__ 7 | 8 | void lb_flow_ipv4_in(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 9 | void lb_flow_nat_icmp_ipv4_in(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 10 | void lb_flow_ipv4_out(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 11 | void lb_flow_nat_ipv4_out(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 12 | void ipv4_conn_expire_sync_conn(struct lb_conn *conn); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/lb/ipv6.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_IPV6_H__ 6 | #define __LB_IPV6_H__ 7 | 8 | void lb_flow_ipv6_in(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 9 | void lb_flow_nat_icmp6_ipv6_in(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 10 | void lb_flow_ipv6_out(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 11 | void lb_flow_nat_ipv6_out(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 12 | void ipv6_conn_expire_sync_conn(struct lb_conn* conn); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/ip.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __IP_H__ 6 | #define __IP_H__ 7 | 8 | static inline uint16_t ip_compute_csum(const void* buf, size_t len) 9 | { 10 | uint16_t cksum; 11 | cksum = rte_raw_cksum(buf, len); 12 | return (cksum == 0xffff) ? cksum : ~cksum; 13 | } 14 | 15 | static inline void ip_eth_mc_map(uint32_t naddr, uint8_t* buf) 16 | { 17 | uint32_t addr = rte_be_to_cpu_32(naddr); 18 | buf[0] = 0x01; 19 | buf[1] = 0x00; 20 | buf[2] = 0x5e; 21 | buf[5] = addr & 0xFF; 22 | addr >>= 8; 23 | buf[4] = addr & 0xFF; 24 | addr >>= 8; 25 | buf[3] = addr & 0x7F; 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/ipvs/fo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public License 4 | * as published by the Free Software Foundation; either version 2 5 | * of the License, or (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * yangxingwu , Feb 2019, initial. 13 | * 14 | */ 15 | 16 | #ifndef __DPVS_FO_H__ 17 | #define __DPVS_FO_H__ 18 | 19 | #include "ipvs/service.h" 20 | #include "ipvs/dest.h" 21 | #include "ipvs/sched.h" 22 | 23 | int dp_vs_fo_init(void); 24 | int dp_vs_fo_term(void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /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/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/route6.h" 7 | #include "conf/inetaddr.h" 8 | #include "conf/laddr.h" 9 | #include "conf/blklst.h" 10 | #include "conf/conn.h" 11 | #include "conf/sync.h" 12 | #include "ip_tunnel.h" 13 | #include "ipvs/service.h" 14 | #include "ipvs/dest.h" 15 | 16 | enum{ 17 | DPVS_SO_SET_FLUSH = 200, 18 | DPVS_SO_SET_ZERO, 19 | DPVS_SO_SET_ADD, 20 | DPVS_SO_SET_EDIT, 21 | DPVS_SO_SET_DEL, 22 | DPVS_SO_SET_ADDDEST, 23 | DPVS_SO_SET_EDITDEST, 24 | DPVS_SO_SET_DELDEST, 25 | DPVS_SO_SET_GRATARP, 26 | }; 27 | 28 | enum{ 29 | DPVS_SO_GET_VERSION = 200, 30 | DPVS_SO_GET_INFO, 31 | DPVS_SO_GET_SERVICES, 32 | DPVS_SO_GET_SERVICE, 33 | DPVS_SO_GET_DESTS, 34 | DPVS_SO_GET_LB_DEBUG, 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/route6_hlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2018 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_ROUTE6_HLIST_H__ 19 | #define __DPVS_ROUTE6_HLIST_H__ 20 | 21 | int route6_hlist_init(void); 22 | int route6_hlist_term(void); 23 | 24 | #endif /* __DPVS_ROUTE6_HLIST_H__ */ 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/ipvs/conhash.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_CH_H__ 19 | #define __DPVS_CH_H__ 20 | 21 | #include "ipvs/service.h" 22 | #include "ipvs/dest.h" 23 | #include "ipvs/sched.h" 24 | 25 | int dp_vs_conhash_init(void); 26 | int dp_vs_conhash_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/route6_lpm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2018 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_ROUTE6_LPM_H__ 19 | #define __DPVS_ROUTE6_LPM_H__ 20 | 21 | int route6_lpm_init(void); 22 | int route6_lpm_term(void); 23 | 24 | void route6_lpm_keyword_value_init(void); 25 | void install_rt6_lpm_keywords(void); 26 | 27 | #endif /* __DPVS_ROUTE6_LPM_H__ */ 28 | -------------------------------------------------------------------------------- /src/ipvs/libconhash/README: -------------------------------------------------------------------------------- 1 | 2 | What is libconhash? 3 | libconhash is a consistent hashing libraray, which can be compiled both on Windows and Linux platform, with the following features: 4 | 5 | 1. High performance and easy to use, libconhash uses a red-black tree to manange all nodes to achieve high performance. 6 | 2. By default it uses MD5 algorithm, but it also supports user-defined hash function. 7 | 3. Easy to scale according to node's processing capacity. 8 | 9 | -------------------------------------------------------------------------------------- 10 | To build libconhash 11 | on Linux using 12 | make 13 | to build a debug version, using 14 | make CFLAG=DEBUG 15 | on Windows there are win32 projects, just build them 16 | 17 | -------------------------------------------------------------------------------------- 18 | To use libconhash 19 | Include headers libconhash.h and configure.h, and link the conhash binary library file. 20 | There is a sample in the project shows how to use the library. 21 | 22 | 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/core.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_CORE_H__ 6 | #define __LB_CORE_H__ 7 | 8 | #define LB_DEBUG_CMD_TIMER 0 9 | #define LB_DEBUG_CMD_LOOP_CYCLE 1 10 | #define LB_DEBUG_CMD_SNAT_POOL 2 11 | #define LB_DEBUG_CMD_MEMPOOL 3 12 | #define LB_DEBUG_CMD_NETIF_STAT 4 13 | 14 | #ifndef LB_INIT 15 | #define LB_INIT 16 | #define RTE_LOGTYPE_LB_INIT RTE_LOGTYPE_USER1 17 | #endif 18 | 19 | #ifndef LB_RUNNING 20 | #define LB_RUNNING 21 | #define RTE_LOGTYPE_LB_RUNNING RTE_LOGTYPE_USER1 22 | #endif 23 | 24 | 25 | struct lb_debug_timer_arg { 26 | uint64_t delay; 27 | }; 28 | 29 | struct lb_debug_loop_record { 30 | uint32_t percision; 31 | uint8_t clean; 32 | }; 33 | 34 | struct lb_debug_arg { 35 | uint8_t cmd; 36 | uint8_t cid; 37 | union { 38 | struct lb_debug_timer_arg timer_arg; 39 | struct lb_debug_loop_record loop_record_arg; 40 | }; 41 | }; 42 | 43 | 44 | int lb_core_init(void); 45 | void lb_core_uninit(void); 46 | void lb_debug_handler(const void *user, size_t len, void **out, size_t *outlen); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/ndisc.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_NDISC_H__ 19 | #define __DPVS_NDISC_H__ 20 | 21 | #include "neigh.h" 22 | 23 | int ndisc_rcv(struct rte_mbuf *mbuf, 24 | struct netif_port *dev); 25 | 26 | void ndisc_send_dad(struct netif_port *dev, 27 | const struct in6_addr* solicit); 28 | 29 | void ndisc_solicit(struct neighbour_entry *neigh, 30 | const struct in6_addr *saddr); 31 | 32 | #endif /* __DPVS_NDISC_H__ */ 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/icmp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_ICMP_H__ 6 | #define __LB_ICMP_H__ 7 | 8 | #include "common.h" 9 | #include "lb/dest.h" 10 | #include "lb/conn.h" 11 | #include "dpdk.h" 12 | 13 | int get_ipv4_icmp_addr_port(struct rte_mbuf *mbuf, int iphdrlen, union inet_addr *saddr, 14 | union inet_addr *daddr, uint16_t *sport, uint16_t *dport, int *icmp_pkt_type); 15 | int get_ipv6_icmp6_addr_port(struct rte_mbuf *mbuf, int iphdrlen, union inet_addr *saddr, 16 | union inet_addr *daddr, uint16_t *sport, uint16_t *dport, int *icmp_pkt_type); 17 | int lb_ipv4_icmp_nat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 18 | int lb_ipv4_icmp_nat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 19 | int lb_ipv6_icmp6_nat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 20 | int lb_ipv6_icmp6_nat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 21 | void icmp6_calculate_csum(struct rte_mbuf *mbuf); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /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 HDSLB_PIDFILE "/var/run/hdslb.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/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 | -------------------------------------------------------------------------------- /include/conf/ipv6.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 | * IPv6 protocol control plane. 20 | * 21 | * Lei Chen , initial, Jul 2018. 22 | */ 23 | #ifndef __DPVS_IPV6_CONF_H__ 24 | #define __DPVS_IPV6_CONF_H__ 25 | #include "inet.h" 26 | 27 | enum { 28 | /* set */ 29 | SOCKOPT_IP6_SET = 1100, 30 | /* get */ 31 | SOCKOPT_IP6_STATS, 32 | }; 33 | 34 | struct ip6_stats_param { 35 | struct inet_stats stats; 36 | struct inet_stats stats_cpus[DPVS_MAX_LCORE]; 37 | } __attribute__((__packed__)); 38 | 39 | #endif /* __DPVS_IPV6_CONF_H__ */ 40 | -------------------------------------------------------------------------------- /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 DPVS 20 | # 21 | MAKE = make 22 | CC = gcc 23 | LD = ld 24 | 25 | SUBDIRS = src tools 26 | 27 | INSDIR = $(PWD)/bin 28 | export INSDIR 29 | 30 | export KERNEL = $(shell /bin/uname -r) 31 | 32 | all: 33 | for i in $(SUBDIRS); do $(MAKE) -C $$i || exit 1; done 34 | 35 | clean: 36 | for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done 37 | 38 | distclean: 39 | $(MAKE) -C tools/keepalived distclean || exit 1 40 | 41 | install:all 42 | -mkdir -p $(INSDIR) 43 | for i in $(SUBDIRS); do $(MAKE) -C $$i install || exit 1; done 44 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | #include 22 | 23 | enum { 24 | DPVS_UDP_S_NORMAL = 0, 25 | DPVS_UDP_S_LAST 26 | }; 27 | 28 | extern int g_defence_udp_drop; 29 | 30 | void install_proto_udp_keywords(void); 31 | void udp_keyword_value_init(void); 32 | int udp_get_timeout(void); 33 | int udp_get_uoa_mode(void); 34 | int udp_get_max_trail(void); 35 | void udp4_send_csum(struct rte_ipv4_hdr *iph, struct rte_udp_hdr *uh); 36 | void udp6_send_csum(struct rte_ipv6_hdr *iph, struct rte_udp_hdr *uh); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/ipvs/libconhash/conhash_util.c: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (C) 2010. sparkling.liang@hotmail.com. All rights reserved. */ 3 | 4 | #include "conhash.h" 5 | #include "conhash_inter.h" 6 | 7 | 8 | void conhash_md5_digest(const u_char *instr, u_char digest[16]) 9 | { 10 | md5_state_t md5state; 11 | 12 | md5_init(&md5state); 13 | md5_append(&md5state, instr, strlen((const char*)instr)); 14 | md5_finish(&md5state, digest); 15 | } 16 | 17 | static void __get_vnodes(util_rbtree_node_t *node, void *data) 18 | { 19 | struct __get_vnodes_s *vnodes = (struct __get_vnodes_s *)data; 20 | if(vnodes->cur < vnodes->size) 21 | { 22 | vnodes->values[vnodes->cur++] = node->key; 23 | } 24 | } 25 | void conhash_get_vnodes(const struct conhash_s *conhash, long *values, int size) 26 | { 27 | struct __get_vnodes_s vnodes; 28 | if((conhash==NULL) || (values==NULL) || (size<=0)) 29 | { 30 | return; 31 | } 32 | vnodes.values = values; 33 | vnodes.size = size; 34 | vnodes.cur = 0; 35 | util_rbtree_mid_travel((util_rbtree_t *)&(conhash->vnode_tree), __get_vnodes, &vnodes); 36 | } 37 | 38 | u_int conhash_get_vnodes_num(const struct conhash_s *conhash) 39 | { 40 | if(conhash == NULL) 41 | { 42 | return 0; 43 | } 44 | return conhash->ivnodes; 45 | } 46 | -------------------------------------------------------------------------------- /tools/lbdebug/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/lbdebug 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 | LIBS = -lnuma 31 | DEFS = -D DPVS_MAX_LCORE=64 32 | 33 | CFLAGS += $(DEFS) 34 | 35 | OBJS = lbdebug.o ../../src/common.o \ 36 | ../keepalived/keepalived/libipvs-2.6/sockopt.o 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | -mkdir -p ./build/ 42 | gcc $(CFLAGS) -o $@ $^ $(LIBS) 43 | 44 | clean: 45 | rm -rf ./build/ *.o 46 | -------------------------------------------------------------------------------- /include/lb/tcp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_TCP_H__ 6 | #define __LB_TCP_H__ 7 | 8 | #include "dpdk.h" 9 | #include "lb/conn.h" 10 | 11 | void get_tcp_port(void *trans_head, uint16_t *sport, uint16_t *dport); 12 | void lb_set_tcp_timeouts(int *tcp_timeouts); 13 | int lb_ipv4_tcp_fnat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 14 | int lb_ipv4_tcp_fnat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 15 | int lb_ipv6_tcp_fnat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 16 | int lb_ipv6_tcp_fnat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 17 | int lb_ipv4_tcp_nat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 18 | int lb_ipv4_tcp_nat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 19 | int lb_ipv6_tcp_nat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 20 | int lb_ipv6_tcp_nat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 21 | int lb_tcp_state_trans(struct lb_conn *conn, struct rte_mbuf *mbuf, int iphdrlen, int dir); 22 | int lb_tcp_conn_expire(struct lb_conn *conn); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/lb/redirect_conn_hash_table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_NAT_CONN_HASH_TABLE_H__ 6 | #define __LB_NAT_CONN_HASH_TABLE_H__ 7 | 8 | #include "inet.h" 9 | #include "lb/conn.h" 10 | 11 | struct lb_conn_hash_elem *lb_redirect_conn_cache_get(int af, union inet_addr *saddr, uint16_t sport, uint32_t *hash); 12 | void lb_redirect_conn_get_free(int af, struct lb_conn_hash_elem *hash_elem_head, struct lb_conn_hash_elem_free *hash_elem_free, uint32_t hash); 13 | int64_t lb_redirect_conn_get_cid(struct lb_conn_hash_elem *hash_elem_head, 14 | int af, union inet_addr *saddr, uint16_t sport, uint8_t markid, uint32_t hash); 15 | int lb_redirect_conn_hash_table_init(void); 16 | void lb_redirect_conn_hold_free_tuple(struct lb_conn_hash_elem_free *hash_elem_free, int cid, int af, union inet_addr *saddr, uint16_t sport, uint8_t markid); 17 | void lb_redirect_conn_release_free_tuple(struct lb_conn *conn, struct lb_conn_hash_elem *conn_page_head, uint8_t free_bit_map_index); 18 | void lb_redirect_conn_use_free_tuple(struct lb_conn_hash_elem *conn_page_head, uint8_t free_bit_map_index, struct lb_conn *conn); 19 | void lb_redirect_conn_hash_free(struct lb_conn *conn); 20 | void lb_redirect_conn_expire(void *priv); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/ipvs/libconhash/conhash_inter.h: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (C) 2010. sparkling.liang@hotmail.com. All rights reserved. */ 3 | 4 | #ifndef __CONHASH_INTER_H_ 5 | #define __CONHASH_INTER_H_ 6 | 7 | #include "configure.h" 8 | #include "md5.h" 9 | #include "util_rbtree.h" 10 | 11 | 12 | /* virtual node structure */ 13 | struct virtual_node_s 14 | { 15 | unsigned long hash; 16 | struct node_s *node; /* pointer to node */ 17 | }; 18 | 19 | /* consistent hashing */ 20 | struct conhash_s 21 | { 22 | util_rbtree_t vnode_tree; /* rbtree of virtual nodes */ 23 | u_int ivnodes; /* virtual node number */ 24 | long (*cb_hashfunc)(const char *); 25 | }; 26 | 27 | struct __get_vnodes_s 28 | { 29 | long *values; 30 | long size, cur; 31 | }; 32 | 33 | 34 | int __conhash_vnode_cmp(const void *v1, const void *v2); 35 | 36 | void __conhash_node2string(const struct node_s *node, u_int replica_idx, char buf[128], u_int *len); 37 | unsigned long __conhash_hash_def(const char *instr); 38 | void __conhash_add_replicas(struct conhash_s *conhash, struct node_s *node); 39 | void __conhash_del_replicas(struct conhash_s *conhash, struct node_s *node); 40 | 41 | util_rbtree_node_t *__conhash_get_rbnode(struct node_s *node, long hash); 42 | void __conhash_del_rbnode(util_rbtree_node_t *rbnode); 43 | 44 | #endif /* end __CONHASH_INTER_H_ */ 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We are really glad you're reading this, because we need volunteer developers to enhance this open source project. Pls feel free to submit issues, bugfix or new features. We really appreciate any contributing work you made to the project. 4 | 5 | How to contribute the project? In general, we follow the "fork-and-pull" [Git workflow](https://nvie.com/posts/a-successful-git-branching-model/). Two main branches with infinite lifetime exist: **master** and **devel**. It is recommended that you should follow the workflow if you want to submit a patch to the project. 6 | 7 | * S1. **Fork** the repo on Github. 8 | * S2. **Clone** the project to your own machine. 9 | * S3. **Checkout** to `devel` branch of the project on your own machine. 10 | * S4. **Commit** changes on your own branch. 11 | * S5. **Push** your work back up to your fork. 12 | * S6. Submit a **Pull Request** so that we can review your changes. 13 | 14 | NOTE: Be sure to merge the latest from "upstream" before making a pull request! 15 | 16 | # Coding conventions 17 | 18 | Basically, codeing style should be consistent in the whole project. We recommend to use the [Linux kernel coding style](https://www.kernel.org/doc/html/v4.10/process/coding-style.html#). 19 | 20 | NOTE: As for indentations, we use 4-char indents, not 8-char indents. This is different from Linux kernel coding style. 21 | -------------------------------------------------------------------------------- /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/lb/udp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_UDP_H__ 6 | #define __LB_UDP_H__ 7 | 8 | #include "dpdk.h" 9 | #include "lb/dest.h" 10 | #include "lb/conn.h" 11 | 12 | void get_udp_port(void *trans_head, uint16_t *sport, uint16_t *dport); 13 | void lb_set_udp_timeout(int timeout); 14 | void lb_set_udp_uoa_mode(int uoa_mode); 15 | void lb_set_udp_uoa_max_trail(int uoa_max_trail); 16 | int lb_udp_state_trans(struct lb_conn *conn, struct rte_mbuf *mbuf, int iphdrlen, int dir); 17 | int lb_ipv4_udp_fnat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 18 | int lb_ipv4_udp_fnat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 19 | int lb_ipv6_udp_fnat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 20 | int lb_ipv6_udp_fnat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 21 | int lb_ipv4_udp_nat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 22 | int lb_ipv4_udp_nat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 23 | int lb_ipv6_udp_nat_in_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 24 | int lb_ipv6_udp_nat_out_handler(struct lb_dest *dest, struct lb_conn *conn, struct rte_mbuf *mbuf); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tools/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 tools 20 | # 21 | SUBDIRS = keepalived ipvsadm dpip lbdebug 22 | 23 | all: config 24 | for i in $(SUBDIRS); do $(MAKE) -C $$i || exit 1; done 25 | 26 | config: keepalived_conf 27 | 28 | keepalived_conf: 29 | if [ ! -f keepalived/Makefile ]; then \ 30 | cd keepalived && \ 31 | ./configure && \ 32 | cd -; \ 33 | fi 34 | 35 | clean: 36 | for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done 37 | 38 | install: 39 | install -m 744 keepalived/bin/keepalived $(INSDIR)/keepalived 40 | install -m 744 ipvsadm/ipvsadm $(INSDIR)/ipvsadm 41 | install -m 744 dpip/build/dpip $(INSDIR)/dpip 42 | install -m 744 lbdebug/build/lbdebug $(INSDIR)/lbdebug 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /patch/dpdk-stable-19.11/0002-support-large_memory.patch: -------------------------------------------------------------------------------- 1 | diff --git a/config/common_base b/config/common_base 2 | index 2e0c72598..37192e2a9 100644 3 | --- a/config/common_base 4 | +++ b/config/common_base 5 | @@ -84,18 +84,18 @@ CONFIG_RTE_MAX_HEAPS=32 6 | CONFIG_RTE_MAX_MEMSEG_LISTS=64 7 | # each memseg list will be limited to either RTE_MAX_MEMSEG_PER_LIST pages 8 | # or RTE_MAX_MEM_MB_PER_LIST megabytes worth of memory, whichever is smaller 9 | -CONFIG_RTE_MAX_MEMSEG_PER_LIST=8192 10 | -CONFIG_RTE_MAX_MEM_MB_PER_LIST=32768 11 | +CONFIG_RTE_MAX_MEMSEG_PER_LIST=32784 12 | +CONFIG_RTE_MAX_MEM_MB_PER_LIST=131072 13 | # a "type" is a combination of page size and NUMA node. total number of memseg 14 | # lists per type will be limited to either RTE_MAX_MEMSEG_PER_TYPE pages (split 15 | # over multiple lists of RTE_MAX_MEMSEG_PER_LIST pages), or 16 | # RTE_MAX_MEM_MB_PER_TYPE megabytes of memory (split over multiple lists of 17 | # RTE_MAX_MEM_MB_PER_LIST), whichever is smaller 18 | -CONFIG_RTE_MAX_MEMSEG_PER_TYPE=32768 19 | -CONFIG_RTE_MAX_MEM_MB_PER_TYPE=131072 20 | +CONFIG_RTE_MAX_MEMSEG_PER_TYPE=131072 21 | +CONFIG_RTE_MAX_MEM_MB_PER_TYPE=524288 22 | # global maximum usable amount of VA, in megabytes 23 | CONFIG_RTE_MAX_MEM_MB=524288 24 | -CONFIG_RTE_MAX_MEMZONE=2560 25 | +CONFIG_RTE_MAX_MEMZONE=10240 26 | CONFIG_RTE_MAX_TAILQ=32 27 | CONFIG_RTE_ENABLE_ASSERT=n 28 | CONFIG_RTE_LOG_DP_LEVEL=RTE_LOG_INFO 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | LIBS = -lnuma 31 | DEFS = -D DPVS_MAX_LCORE=64 32 | 33 | CFLAGS += $(DEFS) 34 | CFLAGS += -Wno-address-of-packed-member 35 | 36 | OBJS = dpip.o utils.o route.o addr.o neigh.o link.o vlan.o \ 37 | qsch.o cls.o tunnel.o ipset.o ipv6.o ../../src/common.o \ 38 | ../keepalived/keepalived/libipvs-2.6/sockopt.o 39 | 40 | all: $(TARGET) 41 | 42 | $(TARGET): $(OBJS) 43 | -mkdir -p ./build/ 44 | gcc $(CFLAGS) -o $@ $^ $(LIBS) 45 | 46 | clean: 47 | rm -rf ./build/ *.o 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/ipvs/libconhash/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010. sparkling.liang@hotmail.com. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR 18 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/conf/ipset.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_IPSET_CONF_H__ 23 | #define __DPVS_IPSET_CONF_H__ 24 | 25 | enum { 26 | /* set */ 27 | SOCKOPT_SET_IPSET_ADD = 3300, 28 | SOCKOPT_SET_IPSET_DEL, 29 | SOCKOPT_SET_IPSET_FLUSH, 30 | 31 | /* get */ 32 | SOCKOPT_GET_IPSET_SHOW, 33 | }; 34 | 35 | struct dp_vs_ipset_conf { 36 | int af; 37 | union inet_addr addr; 38 | }; 39 | 40 | struct dp_vs_multi_ipset_conf { 41 | int num; 42 | struct dp_vs_ipset_conf ipset_conf[0]; 43 | }; 44 | 45 | struct dp_vs_ipset_conf_array { 46 | int nipset; 47 | struct dp_vs_ipset_conf ips[0]; 48 | } __attribute__((__packed__)); 49 | 50 | #endif /* __DPVS_IPSET_CONF_H__ */ 51 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/log.h: -------------------------------------------------------------------------------- 1 | #ifndef _DPVS_LOG_H_ 2 | #define _DPVS_LOG_H_ 3 | 4 | #define DPVS_LOG_RING_SIZE_DEF 4096 5 | #define DPVS_LOG_RING_SIZE_MIN 256 6 | #define DPVS_LOG_RING_SIZE_MAX 524288 7 | 8 | 9 | #define TIMEZONE 0 10 | #define DAY (60*60*24) 11 | #define YEARFIRST 2001 12 | #define YEARSTART (365*(YEARFIRST-1970) + 8) 13 | #define YEAR400 (365*4*100 + (4*(100/4 - 1) + 1)) 14 | #define YEAR100 (365*100 + (100/4 - 1)) 15 | #define YEAR004 (365*4 + 1) 16 | #define YEAR001 365 17 | 18 | #define LOG_SYS_TIME_LEN 20 19 | 20 | #define LOG_INTERNAL_TIME 5 21 | 22 | #define LOG_SLOW_INTERNAL_TIME (60*10) 23 | 24 | #define DPVS_LOG_MAX_LINE_LEN 1024 25 | 26 | #define LOG_BUF_MAX_LEN 4096 27 | 28 | #define DPVS_LOG_POOL_SIZE_DEF 2097152 29 | #define DPVS_LOG_POOL_SIZE_MIN 65536 30 | #define DPVS_LOG_CACHE_SIZE_DEF 256 31 | 32 | 33 | struct dpvs_log { 34 | lcoreid_t cid; 35 | int log_level; 36 | int log_type; 37 | int log_len; 38 | char data[0]; 39 | }; 40 | 41 | typedef struct log_buf { 42 | char buf[LOG_BUF_MAX_LEN]; 43 | int pos; 44 | int level; 45 | uint64_t time; 46 | } log_buf_t; 47 | 48 | typedef struct log_stats{ 49 | int log_hash; 50 | uint64_t log_begin; 51 | int slow; 52 | uint64_t slow_begin; 53 | uint32_t missed; 54 | } log_stats_t; 55 | 56 | int dpvs_log(uint32_t level, uint32_t logtype, const char *func, int line, const char *format, ...); 57 | int log_slave_init(void); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /scripts/setup.tc.sample.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | # raychen, Jan 2018 3 | 4 | VIP="192.168.204.252" 5 | DIP="192.168.204.50" 6 | RSs="192.168.204.51 192.168.204.52 192.168.204.53 192.168.204.54" 7 | LIPs="192.168.204.200 192.168.204.201 192.168.204.202 192.168.204.203 192.168.204.204 192.168.204.205" 8 | LANIF=dpdk0 9 | 10 | # 0: root 11 | # oif=lan / 12 | # 1:0 (10m) 13 | # / \ 14 | # (2000p) 1:1 1:2 (4g) 15 | 16 | # 10m rate limit with tbf 17 | ./dpip qsch add dev ${LANIF} handle 1:0 parent 0: tbf rate 10m burst 1500000 latency 20 18 | # 2000 pfifo limit 19 | ./dpip qsch add dev ${LANIF} handle 1:1 parent 1: pfifo limit 2000 20 | # 4g rate limit with tbf 21 | ./dpip qsch add dev ${LANIF} handle 1:2 parent 1: tbf rate 4g burst 150000000 latency 20 22 | 23 | # check at 0:, goto 1: if packet sent by lan interface 24 | ./dpip cls add dev ${LANIF} qsch 0: match pattern "tcp,oif=${LANIF}" target 1: 25 | # check at 1:, goto 1:1 if packet is tcp,to=0.0.0.0:80 26 | ./dpip cls add dev ${LANIF} qsch 1: match pattern 'tcp,to=0.0.0.0:80' target 1:1 27 | # check at 1:, goto 1:2 if packet is tcp,from=0.0.0.0:80 28 | ./dpip cls add dev ${LANIF} qsch 1: match pattern 'tcp,from=0.0.0.0:80' target 1:2 29 | 30 | ./dpip addr add $DIP/24 dev ${LANIF} 31 | ./dpip addr add $VIP/24 dev ${LANIF} 32 | ./ipvsadm -A -t $VIP:80 -s rr 33 | 34 | for rs in $RSs; do 35 | ./ipvsadm -a -t $VIP:80 -r $rs -b 36 | done 37 | 38 | for lip in $LIPs; do 39 | ./ipvsadm --add-laddr -z $lip -t $VIP:80 -F ${LANIF} 40 | done 41 | -------------------------------------------------------------------------------- /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/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 | /* expand the macro before NEXTARG */ \ 29 | const char *__arg_str = (m); \ 30 | NEXTARG((c)); \ 31 | if ((c)->argc <= 0) { \ 32 | fprintf(stderr, "missing argument for `%s'\n", (__arg_str)); \ 33 | return -1; \ 34 | } \ 35 | } while (0) 36 | 37 | #define CURRARG(c) ((c)->argv[0]) 38 | 39 | const char *af_itoa(int af); 40 | 41 | bool inet_is_addr_any(int af, const union inet_addr *addr); 42 | int inet_pton_try(int *af, const char *src, union inet_addr *dst); 43 | 44 | #endif /* __DPIP_UTILS_H__ */ 45 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /include/lb/sched.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_SCHEDULER_H__ 6 | #define __LB_SCHEDULER_H__ 7 | 8 | #include "list.h" 9 | #include "dpdk.h" 10 | #include "common.h" 11 | #include "ctrl.h" 12 | #include "lb/service.h" 13 | 14 | enum lb_sched_type { 15 | LB_SCHED_RR, 16 | LB_SCHED_WRR, 17 | LB_SCHED_WLC, 18 | LB_SCHED_CONHASH, 19 | }; 20 | 21 | struct lb_scheduler { 22 | struct list_head n_list; 23 | char *name; 24 | enum lb_sched_type type; 25 | 26 | struct lb_dest * 27 | (*schedule_prefetch)(struct lb_service *lbs, 28 | const struct rte_mbuf *mbuf); 29 | void (*schedule_next)(struct lb_service *lbs, 30 | const struct rte_mbuf *mbuf); 31 | 32 | int (*init_service)(struct lb_service *lbs); 33 | int (*exit_service)(struct lb_service *lbs); 34 | int (*update_service)(struct lb_service *lbs, struct lb_dest *dest); 35 | } __rte_cache_aligned; 36 | 37 | int lb_sched_init(void); 38 | int lb_sched_term(void); 39 | 40 | struct lb_scheduler * 41 | lb_scheduler_get(const char *name); 42 | int lb_bind_scheduler(struct lb_service *lbs, 43 | struct lb_scheduler *scheduler); 44 | int lb_unbind_scheduler(struct lb_service *lbs); 45 | void lb_scheduler_put(struct lb_scheduler *scheduler); 46 | int register_lb_scheduler(struct lb_scheduler *scheduler); 47 | struct lb_dest *lb_scheduler_next(struct lb_dest *dest, struct lb_service *lbs, 48 | const struct rte_mbuf *mbuf); 49 | int unregister_lb_scheduler(struct lb_scheduler *scheduler); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/ipvs/nat64.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_NAT64_H__ 19 | #define __DPVS_NAT64_H__ 20 | 21 | #include "ipv4.h" 22 | #include "ipv6.h" 23 | 24 | static inline int mbuf_nat6to4_len(struct rte_mbuf *mbuf) 25 | { 26 | int offset = sizeof(struct ip6_hdr); 27 | uint8_t nexthdr = ip6_hdr(mbuf)->ip6_nxt; 28 | int len; 29 | 30 | offset = ip6_skip_exthdr(mbuf, offset, &nexthdr); 31 | len = mbuf->pkt_len - offset + sizeof(struct rte_ipv4_hdr); 32 | 33 | return len; 34 | } 35 | 36 | static inline int mbuf_nat4to6_len(struct rte_mbuf *mbuf) 37 | { 38 | return (mbuf->pkt_len - ip4_hdrlen(mbuf) + sizeof(struct ip6_hdr)); 39 | } 40 | 41 | int mbuf_6to4(struct rte_mbuf *mbuf, 42 | const struct in_addr *saddr, 43 | const struct in_addr *daddr); 44 | 45 | int mbuf_4to6(struct rte_mbuf *mbuf, 46 | const struct in6_addr *saddr, 47 | const struct in6_addr *daddr); 48 | 49 | #endif /* __DPVS_NAT64_H__ */ 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/ipset.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_IPSET_H__ 19 | #define __DPVS_IPSET_H__ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "list.h" 26 | #include "netif.h" 27 | #include "common.h" 28 | #include "flow.h" 29 | 30 | #define RTE_LOGTYPE_IPSET RTE_LOGTYPE_USER1 31 | 32 | #define IPSET_CFG_FILE_NAME "/etc/gfwip.conf" 33 | #define IPSET_CFG_MEMBERS "members:" 34 | 35 | struct ipset_addr { 36 | int af; 37 | union inet_addr addr; 38 | }; 39 | 40 | struct ipset_entry { 41 | struct list_head list; 42 | struct ipset_addr daddr; 43 | }; 44 | 45 | int ipset_init(void); 46 | int ipset_add(int af, union inet_addr *dest); 47 | int ipset_del(int af, union inet_addr *dest); 48 | int ipset_term(void); 49 | 50 | struct ipset_entry *ipset_addr_lookup(int af, union inet_addr *dest); 51 | 52 | #ifdef CONFIG_DPVS_IPSET_DEBUG 53 | int ipset_list(void); 54 | int ipset_test(void); 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/laddr_multiply.h: -------------------------------------------------------------------------------- 1 | #ifndef __LADDR_MULTIPLY_H__ 2 | #define __LADDR_MULTIPLY_H__ 3 | 4 | typedef int (*laddrhandler_t)(lcoreid_t cid, int af, union inet_addr *laddr, void *arg, int index); 5 | int laddr_multiply_process(int af, union inet_addr *base_laddr, 6 | laddrhandler_t laddr_cbfn, laddrhandler_t rollback_cbfn, void *arg); 7 | 8 | static inline int laddr_multiply_inc(int af, union inet_addr *laddr) 9 | { 10 | uint32_t laddr4; 11 | int i = 15; 12 | uint8_t *laddr6 = laddr->in6.__in6_u.__u6_addr8; 13 | //char v6_buf[128] = ""; 14 | 15 | if (af == AF_INET) { 16 | laddr4 = rte_be_to_cpu_32(laddr->in.s_addr) + 1; 17 | laddr->in.s_addr = rte_cpu_to_be_32(laddr4); 18 | return EDPVS_OK; 19 | } 20 | 21 | do { 22 | laddr6[i] += 1; 23 | } while (!laddr6[i] && --i); 24 | 25 | //inet_ntop(AF_INET6, laddr, v6_buf, 128); 26 | //printf("[%s,%d] out ipv6 addr: %s\n", __func__, __LINE__, v6_buf); 27 | 28 | return EDPVS_OK; 29 | } 30 | 31 | static inline uint16_t laddr_multiply_offset(int af, union inet_addr *laddr, union inet_addr *base_laddr) 32 | { 33 | int pos; 34 | uint16_t v6, base_v6; 35 | 36 | if (af == AF_INET) { 37 | pos = rte_be_to_cpu_32(laddr->in.s_addr) - rte_be_to_cpu_32(base_laddr->in.s_addr); 38 | } else { 39 | v6 = (laddr->in6.__in6_u.__u6_addr8[14] << 8) + laddr->in6.__in6_u.__u6_addr8[15]; 40 | base_v6 = (base_laddr->in6.__in6_u.__u6_addr8[14] << 8) + base_laddr->in6.__in6_u.__u6_addr8[15]; 41 | pos = v6 - base_v6; 42 | if (pos < 0) 43 | pos += DPVS_MAX_LADDR_PERCORE; 44 | } 45 | 46 | return pos; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/conf/route6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DPVS is a software load balancer (Virtual Server) based on DPDK. 3 | * 4 | * Copyright (C) 2018 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 | #ifndef __DPVS_ROUTE6_CONF_H__ 20 | #define __DPVS_ROUTE6_CONF_H__ 21 | 22 | #include "flow.h" 23 | 24 | enum { 25 | /* set */ 26 | SOCKOPT_SET_ROUTE6_ADD_DEL = 6300, 27 | SOCKOPT_SET_ROUTE6_FLUSH, 28 | 29 | /* get */ 30 | SOCKOPT_GET_ROUTE6_SHOW = 6300, 31 | }; 32 | 33 | enum { 34 | RT6_OPS_GET = 1, 35 | RT6_OPS_ADD, 36 | RT6_OPS_DEL, 37 | RT6_OPS_FLUSH, 38 | }; 39 | 40 | struct dp_vs_route6_conf { 41 | int ops; 42 | struct rt6_prefix dst; 43 | struct rt6_prefix src; 44 | struct rt6_prefix prefsrc; 45 | char ifname[IFNAMSIZ]; 46 | struct in6_addr gateway; 47 | uint32_t mtu; 48 | uint32_t flags; 49 | } __attribute__((__packed__)); 50 | 51 | struct dp_vs_route6_conf_array { 52 | int nroute; 53 | struct dp_vs_route6_conf routes[0]; 54 | } __attribute__((__packed__)); 55 | 56 | #endif /* __DPVS_ROUTE6_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 | -------------------------------------------------------------------------------- /patch/dpdk-20.08/0002-support-large_memory.patch: -------------------------------------------------------------------------------- 1 | diff --git a/config/common_base b/config/common_base 2 | index fbf0ee70c8..4bff635143 100644 3 | --- a/config/common_base 4 | +++ b/config/common_base 5 | @@ -84,18 +84,18 @@ CONFIG_RTE_MAX_HEAPS=32 6 | CONFIG_RTE_MAX_MEMSEG_LISTS=64 7 | # each memseg list will be limited to either RTE_MAX_MEMSEG_PER_LIST pages 8 | # or RTE_MAX_MEM_MB_PER_LIST megabytes worth of memory, whichever is smaller 9 | -CONFIG_RTE_MAX_MEMSEG_PER_LIST=8192 10 | -CONFIG_RTE_MAX_MEM_MB_PER_LIST=32768 11 | +CONFIG_RTE_MAX_MEMSEG_PER_LIST=32784 12 | +CONFIG_RTE_MAX_MEM_MB_PER_LIST=131072 13 | # a "type" is a combination of page size and NUMA node. total number of memseg 14 | # lists per type will be limited to either RTE_MAX_MEMSEG_PER_TYPE pages (split 15 | # over multiple lists of RTE_MAX_MEMSEG_PER_LIST pages), or 16 | # RTE_MAX_MEM_MB_PER_TYPE megabytes of memory (split over multiple lists of 17 | # RTE_MAX_MEM_MB_PER_LIST), whichever is smaller 18 | -CONFIG_RTE_MAX_MEMSEG_PER_TYPE=32768 19 | -CONFIG_RTE_MAX_MEM_MB_PER_TYPE=131072 20 | +CONFIG_RTE_MAX_MEMSEG_PER_TYPE=131072 21 | +CONFIG_RTE_MAX_MEM_MB_PER_TYPE=524288 22 | # global maximum usable amount of VA, in megabytes 23 | CONFIG_RTE_MAX_MEM_MB=524288 24 | -CONFIG_RTE_MAX_MEMZONE=2560 25 | +CONFIG_RTE_MAX_MEMZONE=10240 26 | CONFIG_RTE_MAX_TAILQ=32 27 | CONFIG_RTE_ENABLE_ASSERT=n 28 | CONFIG_RTE_LOG_DP_LEVEL=RTE_LOG_INFO 29 | @@ -1056,9 +1056,9 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n 30 | # 31 | # Compile librte_kni 32 | # 33 | -CONFIG_RTE_LIBRTE_KNI=n 34 | -CONFIG_RTE_LIBRTE_PMD_KNI=n 35 | -CONFIG_RTE_KNI_KMOD=n 36 | +CONFIG_RTE_LIBRTE_KNI=y 37 | +CONFIG_RTE_LIBRTE_PMD_KNI=y 38 | +CONFIG_RTE_KNI_KMOD=y 39 | CONFIG_RTE_KNI_PREEMPT_DEFAULT=y 40 | 41 | # 42 | -------------------------------------------------------------------------------- /include/lb/xmit.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_XMIT_H__ 6 | #define __LB_XMIT_H__ 7 | 8 | #include "dpdk.h" 9 | #include "lb/conn.h" 10 | #include "lb/dest.h" 11 | 12 | void lb_xmit_inbound(struct lb_conn *conn, struct rte_mbuf *mbuf); 13 | void lb_xmit_outbound(struct lb_conn *conn, struct rte_mbuf *mbuf); 14 | void lb_dest_tunnel_xmit4(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 15 | void lb_dest_tunnel_xmit6(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 16 | void lb_dest_tunnel_xmit6o4(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 17 | void lb_dest_dr_xmit4(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 18 | void lb_dest_dr_xmit6(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 19 | void lb_dest_fnat_xmit4_in(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 20 | void lb_dest_fnat_xmit4_out(void *outconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 21 | void lb_dest_fnat_xmit6_in(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 22 | void lb_dest_fnat_xmit6_out(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 23 | void lb_dest_fnat_xmit64_in(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 24 | void lb_dest_fnat_xmit46_out(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 25 | void lb_dest_nat_xmit4_in(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 26 | void lb_dest_nat_xmit4_out(void *outconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 27 | void lb_dest_nat_xmit6_in(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 28 | void lb_dest_nat_xmit6_out(void *inconn, struct rte_mbuf *mbuf, struct lb_dest *dest); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /scripts/setup.snat-gre.sample.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | # raychen, Jan. 2018 3 | 4 | WAN_IP="123.1.2.3" # WAN IP can access Internet. 5 | WAN_PREF=24 # WAN side network prefix length. 6 | GATEWAY="123.1.2.254" # WAN side gateway 7 | 8 | LAN_IP="192.168.204.50" 9 | LAN_PREF=24 10 | 11 | # host want to access Internet via SNAT-GRE. 12 | HOST_IP="192.168.204.55" 13 | 14 | WAN_IFACE=dpdk1 15 | LAN_IFACE=dpdk0 16 | GRE_IFACE=gre0 17 | 18 | GRE_IP="172.1.0.1" 19 | 20 | # add WAN-side IP with sapool 21 | # for SNAT must add sapool for WAN-side IP (the IP translated to) 22 | ./dpip addr add $WAN_IP/$WAN_PREF dev $WAN_IFACE sapool 23 | # add LAN-side IP as well as LAN route (generated) 24 | ./dpip addr add $LAN_IP/$LAN_PREF dev $LAN_IFACE 25 | 26 | # add GRE interface and related IP, route 27 | ./dpip tunnel add $GRE_IFACE mode gre local $LAN_IP remote $HOST_IP dev $LAN_IFACE 28 | ./dpip addr add $GRE_IP/30 dev $GRE_IFACE 29 | ./dpip route add $HOST_IP/32 src $LAN_IP dev $LAN_IFACE 30 | 31 | # add default route for WAN interface 32 | ./dpip route add default via $GATEWAY dev $WAN_IFACE 33 | 34 | # SNAT section 35 | # -H MATCH SNAT uses -H for "match" service instead of -t or -u 36 | # MATCH support "proto", "src-range", "oif" and "iif". 37 | # -r used to specify the WAN IP after SNAT translation, 38 | # the "port" part must be 0. 39 | # -J for "SNAT" forwarding mode. 40 | MATCH0="proto=tcp,src-range=172.1.0.0-172.1.255.255,oif=$WAN_IFACE" 41 | MATCH1="proto=icmp,src-range=172.1.0.0-172.1.255.255,oif=$WAN_IFACE" 42 | 43 | ./ipvsadm -A -s rr -H $MATCH0 44 | ./ipvsadm -a -H $MATCH0 -r $WAN_IP:0 -w 100 -J 45 | 46 | ./ipvsadm -A -s rr -H $MATCH1 47 | ./ipvsadm -a -H $MATCH1 -r $WAN_IP:0 -w 100 -J 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/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 | -------------------------------------------------------------------------------- /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 | uint16_t vport; 28 | uint8_t proto; 29 | union inet_addr blklst; 30 | }; 31 | 32 | struct blklst_entry *dp_vs_blklst_lookup(uint8_t proto, const union inet_addr *vaddr, 33 | uint16_t vport, const union inet_addr *blklst); 34 | void dp_vs_blklst_flush(struct dp_vs_service *svc); 35 | 36 | int dp_vs_blklst_init(void); 37 | int dp_vs_blklst_term(void); 38 | 39 | struct list_head *lb_get_blklst_table_head(uint8_t proto, union inet_addr *vaddr, 40 | uint16_t vport, union inet_addr *blklst); 41 | struct blklst_entry *lb_blklst_lookup(struct list_head *table_head, uint8_t proto, union inet_addr *vaddr, 42 | uint16_t vport, union inet_addr *blklst); 43 | 44 | #endif /* __DPVS_BLKLST_H__ */ 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/sys_time.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sys_time.h" 4 | #include "dpdk.h" 5 | 6 | /*Notice: 7 | * the time zone is the value compared with the server's; 8 | * default is 57(beijing),supposed the server is 0(Greenwich time) 9 | */ 10 | static time_t g_dpvs_timer = 0; 11 | static uint64_t g_start_cycles = 0; 12 | 13 | static void sys_time_to_str(time_t* ts, char* time_str, int str_len) 14 | { 15 | struct tm tm_time; 16 | 17 | localtime_r(ts, &tm_time); 18 | snprintf(time_str, str_len, "%04d-%02d-%02d %02d:%02d:%02d", 19 | tm_time.tm_year+1900, tm_time.tm_mon+1, tm_time.tm_mday, 20 | tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec); 21 | } 22 | 23 | char* cycles_to_stime(uint64_t cycles, char* stime, int len) 24 | { 25 | time_t ts; 26 | 27 | if (stime == NULL) 28 | return NULL; 29 | 30 | memset(stime, 0, len); 31 | ts = (cycles - g_start_cycles) / rte_get_timer_hz(); 32 | ts += g_dpvs_timer; 33 | sys_time_to_str(&ts, stime, len); 34 | 35 | return stime; 36 | } 37 | 38 | char* sys_localtime_str(char* stime, int len) 39 | { 40 | time_t now; 41 | 42 | if (stime == NULL) 43 | return NULL; 44 | 45 | memset(stime, 0, len); 46 | now = sys_current_time(); 47 | sys_time_to_str(&now, stime, len); 48 | 49 | return stime; 50 | } 51 | 52 | time_t sys_current_time(void) 53 | { 54 | time_t now; 55 | 56 | now = (rte_rdtsc() - g_start_cycles) / rte_get_timer_hz(); 57 | return now + g_dpvs_timer; 58 | } 59 | 60 | void sys_start_time(void) 61 | { 62 | struct timeval tv; 63 | struct timezone tz; 64 | 65 | time(&g_dpvs_timer); 66 | gettimeofday(&tv, &tz); 67 | g_dpvs_timer -= tz.tz_minuteswest*60; 68 | 69 | g_start_cycles = rte_rdtsc(); 70 | 71 | return; 72 | } 73 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /patch/dpdk-stable-17.05.2/0002-net-support-variable-IP-header-len-for-checksum-API.patch: -------------------------------------------------------------------------------- 1 | From c2dfa35bbd68b869f9069ca9b7474dd93e2097ef Mon Sep 17 00:00:00 2001 2 | From: Lei Chen 3 | Date: Tue, 6 Mar 2018 16:04:36 +0800 4 | Subject: [PATCH 2/2] net: support variable IP header len for checksum API. 5 | 6 | IPv4 checksum APIs use fixe IP header length, it will failed if there is 7 | any IP option. Now calculating header length by "ihl" field, so that we 8 | can support options. 9 | 10 | Signed-off-by: Lei Chen 11 | --- 12 | lib/librte_net/rte_ip.h | 6 +++--- 13 | 1 file changed, 3 insertions(+), 3 deletions(-) 14 | 15 | diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h 16 | index 4491b86..cfbc3bd 100644 17 | --- a/lib/librte_net/rte_ip.h 18 | +++ b/lib/librte_net/rte_ip.h 19 | @@ -314,7 +314,7 @@ static inline uint16_t 20 | rte_ipv4_cksum(const struct ipv4_hdr *ipv4_hdr) 21 | { 22 | uint16_t cksum; 23 | - cksum = rte_raw_cksum(ipv4_hdr, sizeof(struct ipv4_hdr)); 24 | + cksum = rte_raw_cksum(ipv4_hdr, (ipv4_hdr->version_ihl & 0xf) * 4); 25 | return (cksum == 0xffff) ? cksum : ~cksum; 26 | } 27 | 28 | @@ -356,7 +356,7 @@ rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr, uint64_t ol_flags) 29 | } else { 30 | psd_hdr.len = rte_cpu_to_be_16( 31 | (uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length) 32 | - - sizeof(struct ipv4_hdr))); 33 | + - (ipv4_hdr->version_ihl & 0xf) * 4)); 34 | } 35 | return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr)); 36 | } 37 | @@ -381,7 +381,7 @@ rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, const void *l4_hdr) 38 | uint32_t l4_len; 39 | 40 | l4_len = rte_be_to_cpu_16(ipv4_hdr->total_length) - 41 | - sizeof(struct ipv4_hdr); 42 | + (ipv4_hdr->version_ihl & 0xf) * 4; 43 | 44 | cksum = rte_raw_cksum(l4_hdr, l4_len); 45 | cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0); 46 | -- 47 | 2.7.4 48 | 49 | -------------------------------------------------------------------------------- /patch/dpdk-stable-17.11.2/0002-net-support-variable-IP-header-len-for-checksum-API.patch: -------------------------------------------------------------------------------- 1 | From c2dfa35bbd68b869f9069ca9b7474dd93e2097ef Mon Sep 17 00:00:00 2001 2 | From: Lei Chen 3 | Date: Tue, 6 Mar 2018 16:04:36 +0800 4 | Subject: [PATCH 2/2] net: support variable IP header len for checksum API. 5 | 6 | IPv4 checksum APIs use fixe IP header length, it will failed if there is 7 | any IP option. Now calculating header length by "ihl" field, so that we 8 | can support options. 9 | 10 | Signed-off-by: Lei Chen 11 | --- 12 | lib/librte_net/rte_ip.h | 6 +++--- 13 | 1 file changed, 3 insertions(+), 3 deletions(-) 14 | 15 | diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h 16 | index 4491b86..cfbc3bd 100644 17 | --- a/lib/librte_net/rte_ip.h 18 | +++ b/lib/librte_net/rte_ip.h 19 | @@ -314,7 +314,7 @@ static inline uint16_t 20 | rte_ipv4_cksum(const struct ipv4_hdr *ipv4_hdr) 21 | { 22 | uint16_t cksum; 23 | - cksum = rte_raw_cksum(ipv4_hdr, sizeof(struct ipv4_hdr)); 24 | + cksum = rte_raw_cksum(ipv4_hdr, (ipv4_hdr->version_ihl & 0xf) * 4); 25 | return (cksum == 0xffff) ? cksum : ~cksum; 26 | } 27 | 28 | @@ -356,7 +356,7 @@ rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr, uint64_t ol_flags) 29 | } else { 30 | psd_hdr.len = rte_cpu_to_be_16( 31 | (uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length) 32 | - - sizeof(struct ipv4_hdr))); 33 | + - (ipv4_hdr->version_ihl & 0xf) * 4)); 34 | } 35 | return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr)); 36 | } 37 | @@ -381,7 +381,7 @@ rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, const void *l4_hdr) 38 | uint32_t l4_len; 39 | 40 | l4_len = rte_be_to_cpu_16(ipv4_hdr->total_length) - 41 | - sizeof(struct ipv4_hdr); 42 | + (ipv4_hdr->version_ihl & 0xf) * 4; 43 | 44 | cksum = rte_raw_cksum(l4_hdr, l4_len); 45 | cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0); 46 | -- 47 | 2.7.4 48 | 49 | -------------------------------------------------------------------------------- /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/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 | void dp_vs_flow_udp_in(struct rte_mbuf *mbuf); 52 | 53 | struct dp_vs_service; 54 | 55 | struct dp_vs_conn *dp_vs_schedule(struct dp_vs_service *svc, 56 | const struct dp_vs_iphdr *iph, 57 | struct rte_mbuf *mbuf, 58 | bool is_synproxy_on, 59 | bool outwall); 60 | 61 | #endif /* __DPVS_IPVS_H__ */ 62 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/ipvs/ip_vs_fo.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public License 4 | * as published by the Free Software Foundation; either version 2 5 | * of the License, or (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * weighted fail over module 13 | * see net/netfilter/ipvs/ip_vs_fo.c for reference 14 | * 15 | * yangxingwu , Feb 2019, initial. 16 | * 17 | */ 18 | 19 | #include "ipvs/fo.h" 20 | 21 | /* weighted fail over scheduling */ 22 | static struct dp_vs_dest *dp_vs_fo_schedule(struct dp_vs_service *svc, 23 | const struct rte_mbuf *mbuf __rte_unused) 24 | { 25 | 26 | struct dp_vs_dest *dest, *hweight = NULL; 27 | int16_t hw = 0; /* track highest weight */ 28 | 29 | /* basic failover functionality 30 | * find virtual server with highest weight and send it traffic 31 | */ 32 | list_for_each_entry(dest, &svc->dests, n_list) { 33 | if (!(dest->flags & DPVS_DEST_F_OVERLOAD) && 34 | (dest->flags & DPVS_DEST_F_AVAILABLE) && 35 | (rte_atomic16_read(&dest->weight) > hw)) { 36 | hweight = dest; 37 | hw = rte_atomic16_read(&dest->weight); 38 | } 39 | } 40 | 41 | return hweight; 42 | } 43 | 44 | static struct dp_vs_scheduler dp_vs_fo_scheduler = { 45 | .name = "fo", 46 | .n_list = LIST_HEAD_INIT(dp_vs_fo_scheduler.n_list), 47 | .schedule = dp_vs_fo_schedule, 48 | }; 49 | 50 | int dp_vs_fo_init(void) 51 | { 52 | return register_dp_vs_scheduler(&dp_vs_fo_scheduler); 53 | } 54 | 55 | int dp_vs_fo_term(void) 56 | { 57 | return unregister_dp_vs_scheduler(&dp_vs_fo_scheduler); 58 | } 59 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | int af; 39 | union inet_addr addr; 40 | uint64_t nport_conflict; 41 | uint32_t nconns; 42 | }; 43 | 44 | struct dp_vs_laddr_conf { 45 | /* identify service */ 46 | int af_s; 47 | uint8_t proto; 48 | union inet_addr vaddr; 49 | uint16_t vport; 50 | uint32_t fwmark; 51 | char srange[256]; 52 | char drange[256]; 53 | char iifname[IFNAMSIZ]; 54 | char oifname[IFNAMSIZ]; 55 | 56 | /* for set */ 57 | int af_l; 58 | union inet_addr laddr; 59 | char ifname[IFNAMSIZ]; 60 | 61 | /* for get */ 62 | int nladdrs; 63 | struct dp_vs_laddr_entry laddrs[0]; 64 | }; 65 | 66 | #endif /* __DPVS_LADDR_CONF_H__ */ 67 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | struct dpvs_laddr_arg { 25 | struct dp_vs_service *svc; 26 | int af; 27 | union inet_addr *addr; 28 | struct netif_port *iface; 29 | }; 30 | 31 | struct dp_vs_laddr { 32 | int af; 33 | struct list_head list; /* svc->laddr_list elem */ 34 | union inet_addr addr; 35 | rte_atomic32_t refcnt; 36 | rte_atomic32_t conn_counts; 37 | 38 | struct netif_port *iface; 39 | 40 | uint32_t offset; // zhutao add for mark offset. 41 | }; 42 | 43 | int dp_vs_laddr_bind(struct dp_vs_conn *conn, struct dp_vs_service *svc); 44 | int dp_vs_laddr_unbind(struct dp_vs_conn *conn); 45 | 46 | int dp_vs_laddr_add(struct dp_vs_service *svc, int af, const union inet_addr *addr, 47 | const char *ifname); 48 | int dp_vs_laddr_del(struct dp_vs_service *svc, int af, const union inet_addr *addr, 49 | const char *ifname); 50 | int dp_vs_laddr_flush(struct dp_vs_service *svc); 51 | 52 | int dp_vs_laddr_init(void); 53 | int dp_vs_laddr_term(void); 54 | 55 | #endif /* __DPVS_LADDR_H__ */ 56 | -------------------------------------------------------------------------------- /src/laddr_multiply.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "common.h" 6 | #include "dpdk.h" 7 | #include "netif.h" 8 | #include "inetaddr.h" 9 | #include "netif_addr.h" 10 | #include "conf/inetaddr.h" 11 | 12 | #include "laddr_multiply.h" 13 | 14 | int laddr_multiply_process(int af, union inet_addr *base_laddr, 15 | laddrhandler_t laddr_cbfn, laddrhandler_t rollback_cbfn, void *arg) 16 | { 17 | int err, i; 18 | lcoreid_t cid; 19 | uint8_t nlcore; 20 | uint64_t lcore_mask; 21 | union inet_addr addr_tmp, addr_rollback; 22 | 23 | if (!base_laddr || !laddr_cbfn || (af != AF_INET && af != AF_INET6)) 24 | return EDPVS_INVAL; 25 | 26 | /* enabled lcore should not change after init */ 27 | netif_get_slave_lcores(&nlcore, &lcore_mask); 28 | 29 | memcpy(&addr_tmp, base_laddr, sizeof(addr_tmp)); 30 | for (cid=0; cid < RTE_MAX_LCORE; cid++) { 31 | if (cid > 64 || !(lcore_mask & (1L << cid))) 32 | continue; 33 | 34 | for (i=0; i 64 || !(lcore_mask & (1L << cid))) 54 | continue; 55 | 56 | for (i=0; i. 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 | -------------------------------------------------------------------------------- /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 "ctrl.h" 24 | #include "ipvs/service.h" 25 | 26 | 27 | struct dp_vs_scheduler { 28 | struct list_head n_list; 29 | char *name; 30 | // rte_atomic32_t refcnt; 31 | 32 | struct dp_vs_dest * 33 | (*schedule)(struct dp_vs_service *svc, 34 | const struct rte_mbuf *mbuf); 35 | 36 | int (*init_service)(struct dp_vs_service *svc); 37 | int (*exit_service)(struct dp_vs_service *svc); 38 | int (*update_service)(struct dp_vs_service *svc, struct dp_vs_dest *dest, 39 | sockoptid_t opt); 40 | } __rte_cache_aligned; 41 | 42 | int dp_vs_sched_init(void); 43 | int dp_vs_sched_term(void); 44 | 45 | struct dp_vs_scheduler * 46 | dp_vs_scheduler_get(const char *name); 47 | 48 | int dp_vs_bind_scheduler(struct dp_vs_service *svc, 49 | struct dp_vs_scheduler *scheduler); 50 | 51 | int dp_vs_unbind_scheduler(struct dp_vs_service *svc); 52 | 53 | void dp_vs_scheduler_put(struct dp_vs_scheduler *scheduler); 54 | 55 | int register_dp_vs_scheduler(struct dp_vs_scheduler *scheduler); 56 | 57 | int unregister_dp_vs_scheduler(struct dp_vs_scheduler *scheduler); 58 | 59 | #endif /* __DPVS_SCHED_H__ */ 60 | -------------------------------------------------------------------------------- /test/mempool/mp_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //#define DPVS_MEMPOOL_TEST_STEP 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | __rte_unused int i, err; 8 | void *ptr; 9 | __rte_unused int obj_sz1, obj_sz2, mem; 10 | 11 | struct dpvs_mempool *pool; 12 | 13 | err = rte_eal_init(argc, argv); 14 | if (err < 0) 15 | rte_exit(EXIT_FAILURE, "Fail to init eal!\n"); 16 | 17 | #ifdef DPVS_MEMPOOL_TEST_STEP 18 | pool = dpvs_mempool_create("dpvs_mp_test", 32, 65536, 1024); 19 | if (!pool) { 20 | fprintf(stderr, "dpvs_mempool_create failed!\n"); 21 | return 1; 22 | } 23 | 24 | ptr = dpvs_mempool_get(pool, 10); 25 | dpvs_mempool_put(pool, ptr); 26 | 27 | ptr = dpvs_mempool_get(pool, 100); 28 | dpvs_mempool_put(pool, ptr); 29 | 30 | ptr = dpvs_mempool_get(pool, 1000); 31 | dpvs_mempool_put(pool, ptr); 32 | 33 | ptr = dpvs_mempool_get(pool, 10000); 34 | dpvs_mempool_put(pool, ptr); 35 | 36 | ptr = dpvs_mempool_get(pool, 100000); 37 | dpvs_mempool_put(pool, ptr); 38 | 39 | dpvs_mempool_destroy(pool); 40 | #else 41 | for (obj_sz1=8, obj_sz2=1024, mem=100; obj_sz2 < 64000; obj_sz1 += 32, obj_sz2 += 256, mem += 20) { 42 | pool = dpvs_mempool_create("dpvs_mp_test", obj_sz1, obj_sz2, mem); 43 | if (!pool) { 44 | fprintf(stderr, "dpvs_mempool_create failed!\n"); 45 | return 1; 46 | } 47 | 48 | for (i = 0; i < 10000; i++) { 49 | ptr = dpvs_mempool_get(pool, 10); 50 | dpvs_mempool_put(pool, ptr); 51 | 52 | ptr = dpvs_mempool_get(pool, 100); 53 | dpvs_mempool_put(pool, ptr); 54 | 55 | ptr = dpvs_mempool_get(pool, 1000); 56 | dpvs_mempool_put(pool, ptr); 57 | 58 | ptr = dpvs_mempool_get(pool, 10000); 59 | dpvs_mempool_put(pool, ptr); 60 | } 61 | 62 | dpvs_mempool_destroy(pool); 63 | } 64 | #endif 65 | 66 | printf("Finished!\n"); 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /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 | fclose(pidfile); 58 | return false; 59 | } 60 | fclose(pidfile); 61 | 62 | /* remove pidfile if no process attached to it */ 63 | if (kill(pid, 0)) { 64 | syslog(LOG_INFO, "%s: Remove a zombie pid file %s\n", __func__, pid_file); 65 | pidfile_rm(pid_file); 66 | return false; 67 | } 68 | 69 | return true; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /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_common_iavf -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_ice \ 43 | -lrte_pmd_e1000 -lrte_pmd_bnxt -lrte_pmd_ring -lrte_pmd_bond -lrte_ethdev -lrte_ip_frag -lrte_telemetry \ 44 | -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lrte_eal -lrte_rcu \ 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 | -lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm \ 48 | -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto 49 | -------------------------------------------------------------------------------- /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/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 | int interval; 41 | int count; 42 | bool color; 43 | char *obj; 44 | dpip_cmd_t cmd; 45 | int argc; 46 | char **argv; 47 | }; 48 | 49 | struct dpip_obj { 50 | struct list_head list; 51 | char *name; 52 | void *param; 53 | 54 | void (*help)(void); 55 | /* @conf is used to passing general config like af, verbose, ... 56 | * we have obj.parse() to handle obj specific parameters. */ 57 | int (*do_cmd)(struct dpip_obj *obj, dpip_cmd_t cmd, 58 | struct dpip_conf *conf); 59 | /* the parser can be used to parse @conf into @param */ 60 | int (*parse)(struct dpip_obj *obj, struct dpip_conf *conf); 61 | int (*check)(const struct dpip_obj *obj, dpip_cmd_t cmd); 62 | }; 63 | 64 | void dpip_register_obj(struct dpip_obj *obj); 65 | void dpip_unregister_obj(struct dpip_obj *obj); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/ipvs/redirect.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_REDIRECT_H__ 19 | #define __DPVS_REDIRECT_H__ 20 | #include "common.h" 21 | #include "list.h" 22 | #include "dpdk.h" 23 | #include "netif.h" 24 | #include "ipvs/conn.h" 25 | #include "ipvs/dest.h" 26 | 27 | /* 28 | * The conneciton redirect tuple is only for the reverse tuple 29 | * (inside -> outside) in nat-mode. 30 | */ 31 | struct dp_vs_redirect { 32 | struct list_head list; 33 | 34 | uint8_t af; 35 | uint8_t proto; 36 | lcoreid_t cid; 37 | uint8_t padding; 38 | 39 | union inet_addr saddr; 40 | union inet_addr daddr; 41 | uint16_t sport; 42 | uint16_t dport; 43 | 44 | struct rte_mempool *redirect_pool; 45 | } __rte_cache_aligned; 46 | 47 | struct dp_vs_redirect *dp_vs_redirect_alloc(enum dpvs_fwd_mode fwdmode); 48 | void dp_vs_redirect_free(struct dp_vs_conn *conn); 49 | void dp_vs_redirect_hash(struct dp_vs_conn *conn); 50 | void dp_vs_redirect_unhash(struct dp_vs_conn *conn); 51 | struct dp_vs_redirect *dp_vs_redirect_get(int af, uint16_t proto, 52 | const union inet_addr *saddr, const union inet_addr *daddr, 53 | uint16_t sport, uint16_t dport); 54 | void dp_vs_redirect_init(struct dp_vs_conn *conn); 55 | int dp_vs_redirect_table_init(void); 56 | int dp_vs_redirect_pkt(struct rte_mbuf *mbuf, lcoreid_t peer_cid); 57 | void dp_vs_redirect_ring_proc(struct netif_queue_conf *qconf, lcoreid_t cid); 58 | int dp_vs_redirects_init(void); 59 | int dp_vs_redirects_term(void); 60 | 61 | #endif /* __DPVS_REDIRECT_H__ */ 62 | -------------------------------------------------------------------------------- /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 | #define IFA_F_SAPOOL_MULTIPLY 0x20000 /* if address with sockaddr pool */ 47 | 48 | struct inet_addr_param { 49 | int af; 50 | char ifname[IFNAMSIZ]; 51 | union inet_addr addr; 52 | uint8_t plen; 53 | union inet_addr bcast; 54 | uint32_t valid_lft; 55 | uint32_t prefered_lft; 56 | uint8_t scope; 57 | uint32_t flags; 58 | 59 | uint32_t sa_used; 60 | uint32_t sa_free; 61 | uint32_t sa_miss; 62 | } __attribute__((__packed__)); 63 | 64 | struct inet_addr_param_array { 65 | int naddr; 66 | struct inet_addr_param addrs[0]; 67 | }; 68 | 69 | #endif /* __DPVS_INETADDR_CONF_H__ */ 70 | -------------------------------------------------------------------------------- /include/lb/pipeline.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only 2 | * Copyright(c) 2020 Intel Corporation 3 | */ 4 | 5 | #ifndef __LB_PIPELINE_H__ 6 | #define __LB_PIPELINE_H__ 7 | 8 | #include "common.h" 9 | #include "dpdk.h" 10 | #include "lb/core.h" 11 | 12 | enum lb_pl_next { 13 | LB_PL_NEXT_LOOKUP = 0, 14 | LB_PL_NEXT_IN_NEW = 1, 15 | LB_PL_NEXT_NEW = 2, 16 | LB_PL_NEXT_NEW_FNAT = 3, 17 | LB_PL_NEXT_OUT = 4, 18 | }; 19 | 20 | enum lb_pl_stage { 21 | LB_PL_STAGE_INVALID = 0xFF, 22 | LB_PL_STAGE0 = 0, 23 | LB_PL_STAGE1 = 1, 24 | LB_PL_STAGE2 = 2, 25 | LB_PL_STAGE3 = 3, 26 | LB_PL_STAGE_IN_MAX = 4, 27 | LB_PL_STAGE_OUT_MAX = 4, 28 | LB_PL_STAGE_MAX = 4, 29 | }; 30 | 31 | struct lb_service; 32 | struct lb_pl_cache; 33 | typedef void (*lb_pl_cb_t)(struct lb_pl_cache *cache, struct lb_service *lbs); 34 | 35 | struct lb_pl_cache { 36 | struct rte_mbuf *mbuf; 37 | union { 38 | void *v1; 39 | uint32_t v1d; 40 | }; 41 | union { 42 | void *v2; 43 | uint32_t v2d; 44 | }; 45 | union { 46 | void *v3; 47 | uint32_t v3d; 48 | }; 49 | union { 50 | void *v4; 51 | uint32_t v4d; 52 | struct { 53 | uint16_t v4d_sport; 54 | uint16_t v4d_dport; 55 | }; 56 | }; 57 | struct lb_service *lbs; 58 | lb_pl_cb_t *pipe_cbs; 59 | uint8_t markid; 60 | uint8_t new_conn_bit_map_index; 61 | uint8_t nstages; 62 | uint8_t stage; 63 | uint8_t next; 64 | uint8_t tmp_value; 65 | } __rte_cache_aligned; 66 | 67 | #define LB_CACHE_DEPTH 2 68 | struct lb_pipeline { 69 | //uint8_t curr_id; 70 | struct lb_pl_cache cache[LB_CACHE_DEPTH]; 71 | } __rte_cache_aligned; 72 | 73 | typedef void (*lb_flow_cb_t)(struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 74 | 75 | void lb_flow_pipeline_run(lb_pl_cb_t *pipe_cbs, uint32_t nstages, 76 | struct rte_mbuf *mbuf, struct lb_service *lbs, uint8_t markid); 77 | 78 | static inline void lb_cache_invalid(struct rte_mbuf *mbuf, struct lb_pl_cache *cache, char *msg) 79 | { 80 | RTE_LOG(ERR, LB_RUNNING, "Drop invalid packet: %s\n", msg); 81 | rte_pktmbuf_free(mbuf); 82 | cache->stage = LB_PL_STAGE_INVALID; 83 | } 84 | 85 | int lb_init_pipe(void); 86 | 87 | #endif 88 | --------------------------------------------------------------------------------