diff --git a/cicd/common/sctp_client b/cicd/common/sctp_client index a663bf075..69610a86a 100755 Binary files a/cicd/common/sctp_client and b/cicd/common/sctp_client differ diff --git a/cicd/common/sctp_client.c b/cicd/common/sctp_client.c index 1db1b4196..bf69c90e5 100644 --- a/cicd/common/sctp_client.c +++ b/cicd/common/sctp_client.c @@ -16,10 +16,10 @@ int main(int argc, char* argv[]) { struct sockaddr_in servaddr = {0}; - struct sockaddr_in laddr = {0}; - int sockfd, in, flags; - char *saddr; - int sport, lport, error = 0, secs = 0; + struct sockaddr_in laddr[10] = {0}; + int sockfd, in, flags, count = 1; + char *saddr, *laddrs, *addr; + int sport, lport, error = 0, secs = 0, i = 0; struct sctp_status status = {0}; struct sctp_sndrcvinfo sndrcvinfo = {0}; struct sctp_event_subscribe events = {0}; @@ -29,13 +29,35 @@ int main(int argc, char* argv[]) socklen_t opt_len; socklen_t slen = (socklen_t) sizeof(struct sockaddr_in); - + if (argc < 5) { + printf("Usage: %s localaddr1<,localaddr2..> localport serverIP serverport \n", argv[0]); + exit(1); + } sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); lport = atoi(argv[2]); - - laddr.sin_family = AF_INET; - laddr.sin_addr.s_addr = inet_addr(argv[1]); - laddr.sin_port = lport?htons(lport):0; + laddrs = argv[1]; + memset(laddr, 0, sizeof(laddr)); + if (strstr(laddrs, ",")) { + i = 0; + addr = strtok(laddrs, ",\n"); + laddr[0].sin_family = AF_INET; + laddr[0].sin_port = lport?htons(lport):0; + laddr[0].sin_addr.s_addr = inet_addr(addr); + //printf("%s\n", addr); + addr = strtok(NULL, ",\n"); + while(addr != NULL) { + i++; + //printf("%s\n", addr); + laddr[i].sin_family = AF_INET; + laddr[i].sin_port = lport?htons(lport):0; + laddr[i].sin_addr.s_addr = inet_addr(addr); + addr = strtok(NULL, ",\n"); + } + } else { + laddr[0].sin_family = AF_INET; + laddr[0].sin_addr.s_addr = inet_addr(argv[1]); + laddr[0].sin_port = lport?htons(lport):0; + } //bind to local address error = bind(sockfd, (struct sockaddr *)&laddr, sizeof(struct sockaddr_in)); @@ -45,15 +67,31 @@ int main(int argc, char* argv[]) exit(1); } + int j = 1; + while(j <= i) { + error = sctp_bindx(sockfd,(struct sockaddr*) &laddr[j], j, SCTP_BINDX_ADD_ADDR); + if (error != 0) { + printf("\n\n\t\t***r: error adding addrs:" + " %s. ***\n", strerror(errno)); + exit(1); + } else { + //printf("Bind OK\n"); + } + j++; + } + //set the association options initmsg.sinit_num_ostreams = 1; setsockopt( sockfd, IPPROTO_SCTP, SCTP_INITMSG, &initmsg,sizeof(initmsg)); saddr = argv[3]; sport = atoi(argv[4]); - if (argv[5]) { + if (argc >=6 ) { /* Delay before exit */ secs = atoi(argv[5]); } + if (argc == 7) { /* count for sending 1pps*/ + count = atoi(argv[6]); + } bzero( (void *)&servaddr, sizeof(servaddr) ); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(sport); @@ -65,11 +103,25 @@ int main(int argc, char* argv[]) opt_len = (socklen_t) sizeof(struct sctp_status); getsockopt(sockfd, IPPROTO_SCTP, SCTP_STATUS, &status, &opt_len); - while(1) + fd_set fds; // will be checked for being ready to read + FD_ZERO(&fds); + FD_SET(sockfd, &fds); + struct timeval tv = { 0 }; + tv.tv_sec = 1; + tv.tv_usec = 0; + + while(count) { strncpy (msg, "hello", strlen("hello")); - //printf("Sending msg to server: %s", msg); sctp_sendmsg(sockfd, (const void *)msg, strlen(msg), NULL, 0,htonl(PPID), 0, 0 , 0, 0); + //printf("Sending msg to server: %s", msg); + // + int ret = select( sockfd + 1, &fds, NULL, NULL, &tv ); + if (ret <= 0) { + printf("Timeout\n"); + count--; + sleep(1); + } else if (FD_ISSET( sockfd, &fds )) { in = sctp_recvmsg(sockfd, (void*)buff, RECVBUFSIZE, (struct sockaddr *)&servaddr, @@ -79,7 +131,17 @@ int main(int argc, char* argv[]) buff[in] = 0; printf("%s",buff); fflush(stdout); - break; + count--; + if(!count) + break; + else { + printf("\n"); + fflush(stdout); + sleep(1); + } + } + } else { + break; } } if(secs) sleep(secs); diff --git a/cicd/common/sctp_server b/cicd/common/sctp_server index 6c37dd75f..7f6a07b15 100755 Binary files a/cicd/common/sctp_server and b/cicd/common/sctp_server differ diff --git a/cicd/common/sctp_server.c b/cicd/common/sctp_server.c index af3a49b0b..941ebc068 100644 --- a/cicd/common/sctp_server.c +++ b/cicd/common/sctp_server.c @@ -44,7 +44,6 @@ int main(int argc, char* argv[]) { if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) perror("setsockopt(SO_REUSEADDR) failed"); - i = 1; if (strstr(saddrs, ",")) { saddr = strtok(saddrs, ",\n"); laddr[0].sin_family = AF_INET; @@ -52,6 +51,7 @@ int main(int argc, char* argv[]) { laddr[0].sin_addr.s_addr = inet_addr(saddr); printf("%s\n", saddr); saddr = strtok(NULL, ",\n"); + i = 1; while(saddr != NULL) { printf("%s\n", saddr); laddr[i].sin_family = AF_INET; @@ -77,14 +77,15 @@ int main(int argc, char* argv[]) { " %s. ***\n", strerror(errno)); exit(1); } - - if (i > 1) { - error = sctp_bindx(sockfd,(struct sockaddr*) &laddr[1], i - 1, SCTP_BINDX_ADD_ADDR); + int j = 1; + while(j <= i) { + error = sctp_bindx(sockfd,(struct sockaddr*) &laddr[j], j - 1, SCTP_BINDX_ADD_ADDR); if (error != 0) { printf("\n\n\t\t***r: error adding addrs:" " %s. ***\n", strerror(errno)); exit(1); } + j++; } listen(sockfd, 1); diff --git a/cicd/k3s-flannel-multus/multus/multus-sctp-pod.yml b/cicd/k3s-flannel-multus/multus/multus-sctp-pod.yml new file mode 100644 index 000000000..2b33d895f --- /dev/null +++ b/cicd/k3s-flannel-multus/multus/multus-sctp-pod.yml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Pod +metadata: + name: sctp-pod-01 + labels: + app: sctp-pod-01 + annotations: + k8s.v1.cni.cncf.io/networks: '[{ + "name": "macvlan1", + "default-route": ["4.0.6.149"] + }]' +spec: + containers: + - name: sctp-test + image: loxilbio/sctp-darn:latest + imagePullPolicy: Always + #command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 6 ; done"] + command: ["sctp_darn","-H", "0.0.0.0","-P", "9999", "-l"] + ports: + - containerPort: 9999 diff --git a/cicd/k3s-flannel-multus/multus/multus-sctp-service.yml b/cicd/k3s-flannel-multus/multus/multus-sctp-service.yml new file mode 100644 index 000000000..93f14ca9f --- /dev/null +++ b/cicd/k3s-flannel-multus/multus/multus-sctp-service.yml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: multus-sctp-service + annotations: + loxilb.io/num-secondary-networks: "2" + loxilb.io/multus-nets: macvlan1,macvlan2 + loxilb.io/lbmode: "fullnat" +spec: + externalTrafficPolicy: Local + loadBalancerClass: loxilb.io/loxilb + selector: + app: sctp-pod-01 + ports: + - port: 55002 + protocol: SCTP + targetPort: 9999 + type: LoadBalancer diff --git a/cicd/k3s-sctpmh/config.sh b/cicd/k3s-sctpmh/config.sh index dc5b7c815..9f04a35a9 100755 --- a/cicd/k3s-sctpmh/config.sh +++ b/cicd/k3s-sctpmh/config.sh @@ -101,6 +101,8 @@ $hexec r1 ip route add 20.20.20.1/32 via 11.11.11.11 # Route back to user sudo ip route add 11.11.11.0/24 via 14.14.14.1 sudo ip route add 123.123.123.0/24 via 14.14.14.1 +sudo ip route add 124.124.124.0/24 via 14.14.14.1 +sudo ip route add 125.125.125.0/24 via 14.14.14.1 # Change default route in llb1 $hexec llb1 ip route del default @@ -132,7 +134,9 @@ else echo "Start K3s installation" # Install k3s without external cloud-manager and disabled servicelb - curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.22.9+k3s1 INSTALL_K3S_EXEC="server --disable traefik --disable servicelb --disable-cloud-controller --kubelet-arg cloud-provider=external" K3S_KUBECONFIG_MODE="644" sh - + sudo apt install ipset ipvsadm + curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik,metrics-server,servicelb" K3S_KUBECONFIG_MODE="644" sh -s - server --kube-proxy-arg proxy-mode=ipvs + #curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.22.9+k3s1 INSTALL_K3S_EXEC="server --disable traefik --disable servicelb --disable-cloud-controller --kubelet-arg cloud-provider=external" K3S_KUBECONFIG_MODE="644" sh - #curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --disable traefik --disable servicelb --disable-cloud-controller --kubelet-arg cloud-provider=external" K3S_KUBECONFIG_MODE="644" sh - sleep 10 diff --git a/cicd/k3s-sctpmh/rmconfig.sh b/cicd/k3s-sctpmh/rmconfig.sh index 3aed216b0..79d14bd5e 100755 --- a/cicd/k3s-sctpmh/rmconfig.sh +++ b/cicd/k3s-sctpmh/rmconfig.sh @@ -44,7 +44,7 @@ if [[ -f "/usr/local/bin/k3s-uninstall.sh" ]]; then /usr/local/bin/k3s-uninstall.sh fi -sudo apt-get remove bird2 --yes +sudo apt-get remove bird2 ipvsadm ipset --yes docker image rm loxilb-io/sctp-server docker images -a | grep "loxilb-io" | awk '{print $3}' | xargs docker rmi echo "#########################################" diff --git a/cicd/k8s-calico-ipvs2-ha-ka-sync/rmconfig.sh b/cicd/k8s-calico-ipvs2-ha-ka-sync/rmconfig.sh index 6cadc7e4e..4c990e5e0 100755 --- a/cicd/k8s-calico-ipvs2-ha-ka-sync/rmconfig.sh +++ b/cicd/k8s-calico-ipvs2-ha-ka-sync/rmconfig.sh @@ -4,3 +4,4 @@ vagrant destroy -f worker1 vagrant destroy -f master vagrant destroy -f llb1 vagrant destroy -f llb2 +vagrant destroy -f host diff --git a/cicd/sctpmh/config.sh b/cicd/sctpmh/config.sh new file mode 100755 index 000000000..4f2f519ac --- /dev/null +++ b/cicd/sctpmh/config.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +source ../common.sh + +echo "#########################################" +echo "Spawning all hosts" +echo "#########################################" + +spawn_docker_host --dock-type loxilb --dock-name llb1 +spawn_docker_host --dock-type host --dock-name ep1 +spawn_docker_host --dock-type host --dock-name r1 +spawn_docker_host --dock-type host --dock-name r2 +spawn_docker_host --dock-type host --dock-name r3 +spawn_docker_host --dock-type host --dock-name r4 +spawn_docker_host --dock-type host --dock-name sw1 +spawn_docker_host --dock-type host --dock-name sw2 +spawn_docker_host --dock-type host --dock-name user + +echo "#########################################" +echo "Connecting and configuring hosts" +echo "#########################################" + +connect_docker_hosts user r1 +connect_docker_hosts user r2 +connect_docker_hosts r1 sw1 +connect_docker_hosts r2 sw1 +connect_docker_hosts sw1 llb1 +connect_docker_hosts llb1 sw2 +connect_docker_hosts sw2 r3 +connect_docker_hosts sw2 r4 +connect_docker_hosts r3 ep1 +connect_docker_hosts r4 ep1 + +create_docker_host_cnbridge --host1 sw1 --host2 llb1 +create_docker_host_cnbridge --host1 sw1 --host2 r1 +create_docker_host_cnbridge --host1 sw1 --host2 r2 + +create_docker_host_cnbridge --host1 sw2 --host2 llb1 +create_docker_host_cnbridge --host1 sw2 --host2 r3 +create_docker_host_cnbridge --host1 sw2 --host2 r4 + +#node1 config +config_docker_host --host1 user --host2 r1 --ptype phy --addr 1.1.1.1/24 --gw 1.1.1.254 +config_docker_host --host1 user --host2 r2 --ptype phy --addr 2.2.2.1/24 +config_docker_host --host1 r1 --host2 user --ptype phy --addr 1.1.1.254/24 +config_docker_host --host1 r2 --host2 user --ptype phy --addr 2.2.2.254/24 + +create_docker_host_vlan --host1 llb1 --host2 sw1 --id 11 --ptype untagged +create_docker_host_vlan --host1 r1 --host2 sw1 --id 11 --ptype untagged +create_docker_host_vlan --host1 r2 --host2 sw1 --id 11 --ptype untagged +config_docker_host --host1 r1 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.253/24 --gw 11.11.11.1 +config_docker_host --host1 r2 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.254/24 --gw 11.11.11.1 +config_docker_host --host1 llb1 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.1/24 + +create_docker_host_vlan --host1 llb1 --host2 sw2 --id 10 --ptype untagged +create_docker_host_vlan --host1 r3 --host2 sw2 --id 10 --ptype untagged +create_docker_host_vlan --host1 r4 --host2 sw2 --id 10 --ptype untagged + +config_docker_host --host1 llb1 --host2 sw2 --ptype vlan --id 10 --addr 10.10.10.1/24 +config_docker_host --host1 r3 --host2 sw2 --ptype vlan --id 10 --addr 10.10.10.253/24 --gw 10.10.10.1 +config_docker_host --host1 r4 --host2 sw2 --ptype vlan --id 10 --addr 10.10.10.254/24 --gw 10.10.10.1 + +config_docker_host --host1 ep1 --host2 r3 --ptype phy --addr 31.31.31.1/24 --gw 31.31.31.254 +config_docker_host --host1 ep1 --host2 r4 --ptype phy --addr 32.32.32.1/24 +config_docker_host --host1 r3 --host2 ep1 --ptype phy --addr 31.31.31.254/24 +config_docker_host --host1 r4 --host2 ep1 --ptype phy --addr 32.32.32.254/24 + +$hexec user ip route change default via 1.1.1.254 +$hexec ep1 ip route change default via 31.31.31.254 + +# Backup paths in user +$hexec user ip route add 124.124.124.1/32 via 2.2.2.254 +$hexec user ip route add 125.125.125.1/32 via 2.2.2.254 +$hexec user ip route add 134.134.134.1/32 via 2.2.2.254 +$hexec user ip route add 135.135.135.1/32 via 2.2.2.254 + +$hexec ep1 ip route add 124.124.124.1/32 via 32.32.32.254 +$hexec ep1 ip route add 125.125.125.1/32 via 32.32.32.254 +$hexec ep1 ip route add 134.134.134.1/32 via 32.32.32.254 +$hexec ep1 ip route add 135.135.135.1/32 via 32.32.32.254 + +$hexec llb1 ip route add 1.1.1.0/24 via 11.11.11.253 +$hexec llb1 ip route add 2.2.2.0/24 via 11.11.11.254 + +$hexec llb1 ip route add 31.31.31.0/24 via 10.10.10.253 +$hexec llb1 ip route add 32.32.32.0/24 via 10.10.10.254 + +sleep 20 +##Create LB rule user->ep1 +create_lb_rule llb1 123.123.123.1 --secips=124.124.124.1,125.125.125.1 --sctp=2020:9999 --endpoints=31.31.31.1:1 --mode=fullnat + +##Create LB rule ep1->user +create_lb_rule llb1 133.133.133.1 --secips=134.134.134.1,135.135.135.1 --sctp=2020:9999 --endpoints=1.1.1.1:1 --mode=fullnat + +$dexec llb1 loxicmd create ep 1.1.1.1 --name=1.1.1.1_sctp_9999 --probetype=none +$dexec llb1 loxicmd create ep 31.31.31.1 --name=31.31.31.1_sctp_9999 --probetype=none diff --git a/cicd/sctpmh/input b/cicd/sctpmh/input new file mode 100644 index 000000000..6fb66a5e2 --- /dev/null +++ b/cicd/sctpmh/input @@ -0,0 +1,6 @@ + + + + + + diff --git a/cicd/sctpmh/rmconfig.sh b/cicd/sctpmh/rmconfig.sh new file mode 100755 index 000000000..dd68b07eb --- /dev/null +++ b/cicd/sctpmh/rmconfig.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +echo "#########################################" +echo "Removing testbed" +echo "#########################################" + +source ../common.sh + +disconnect_docker_hosts user r1 +disconnect_docker_hosts user r2 +disconnect_docker_hosts r1 sw1 +disconnect_docker_hosts r2 sw1 +disconnect_docker_hosts sw1 llb1 +disconnect_docker_hosts llb1 sw2 +disconnect_docker_hosts sw2 r3 +disconnect_docker_hosts sw2 r4 +disconnect_docker_hosts r3 ep1 +disconnect_docker_hosts r4 ep1 + +delete_docker_host llb1 +delete_docker_host user +delete_docker_host r1 +delete_docker_host r2 +delete_docker_host r3 +delete_docker_host r4 +delete_docker_host sw1 +delete_docker_host sw2 +delete_docker_host ep1 + +echo "#########################################" +echo "Removed testbed" +echo "#########################################" diff --git a/cicd/sctpmh/validation.sh b/cicd/sctpmh/validation.sh new file mode 100755 index 000000000..9e3fec23b --- /dev/null +++ b/cicd/sctpmh/validation.sh @@ -0,0 +1,14 @@ +#!/bin/bash +echo "SCTP Multihoming - Test case #1" +echo -e "*********************************************************************************" +./validation1.sh +echo -e "\n\n\nSCTP Multihoming - Test case #2" +echo -e "*********************************************************************************" +./validation2.sh +echo -e "\n\n\nSCTP Multihoming - Test case #3" +echo -e "*********************************************************************************" +./validation3.sh +echo -e "\n\n\nSCTP Multihoming - Test case #4" +echo -e "*********************************************************************************" +./validation4.sh +echo -e "\n\n\n*********************************************************************************" diff --git a/cicd/sctpmh/validation1.sh b/cicd/sctpmh/validation1.sh new file mode 100755 index 000000000..6043bf114 --- /dev/null +++ b/cicd/sctpmh/validation1.sh @@ -0,0 +1,61 @@ +#!/bin/bash +source ../common.sh + +echo -e "sctpmh: SCTP Multihoming Basic Test - Client & EP Uni-homed and LB is Multi-homed\n" +extIP="123.123.123.1" +port=2020 + +echo "SCTP Multihoming service sctp-lb -> $extIP:$port" +echo -e "------------------------------------------------------------------------------------\n" + +$hexec ep1 sctp_darn -H 0.0.0.0 -P 9999 -l 2>&1> /dev/null & + +sleep 10 +$hexec user stdbuf -oL sctp_darn -H 1.1.1.1 -h $extIP -p $port -s < input > user.out +sleep 3 + +exp="New connection, peer addresses +123.123.123.1:2020 +124.124.124.1:2020 +125.125.125.1:2020" + +res=`cat user.out | grep -A 3 "New connection, peer addresses"` +sudo rm -rf user.out +sudo pkill sctp_darn + +if [[ "$res" == "$exp" ]]; then + echo $res + echo -e "\nsctpmh SCTP Multihoming service Basic Test [OK]\n" +else + echo "sctpmh SCTP Multihoming service Basic Test [NOK]" + echo "Expected : $exp" + echo "Received : $res" + ## Dump some debug info + echo "system route-info" + echo -e "\nuser" + sudo ip netns exec user ip route + echo -e "\nr1" + sudo ip netns exec r1 ip route + echo -e "\nr2" + sudo ip netns exec r2 ip route + echo -e "\nllb1" + sudo ip netns exec llb1 ip route + echo -e "\nr3" + sudo ip netns exec r3 ip route + echo -e "\nr4" + sudo ip netns exec r4 ip route + echo "-----------------------------" + + echo -e "\nllb1 lb-info" + $dexec llb1 loxicmd get lb + echo "llb1 ep-info" + $dexec llb1 loxicmd get ep + echo "llb1 bpf-info" + $dexec llb1 ntc filter show dev eth0 ingress + echo "BFP trace -- " + sudo timeout 5 cat /sys/kernel/debug/tracing/trace_pipe + sudo killall -9 cat + echo "BFP trace -- " + exit 1 +fi +echo -e "------------------------------------------------------------------------------------\n\n\n" diff --git a/cicd/sctpmh/validation2.sh b/cicd/sctpmh/validation2.sh new file mode 100755 index 000000000..8b92fef37 --- /dev/null +++ b/cicd/sctpmh/validation2.sh @@ -0,0 +1,93 @@ +#!/bin/bash +source ../common.sh + +echo -e "sctpmh: SCTP Multihoming - Multipath Test, Client and LB Multihomed, EP is uni-homed\n" +extIP="123.123.123.1" +port=2020 + +echo "SCTP Multihoming service sctp-lb(Multipath traffic) -> $extIP:$port" +echo -e "------------------------------------------------------------------------------------\n" + +$hexec ep1 sctp_test -H 0.0.0.0 -P 9999 -l > ep1.out & +sleep 2 + +$hexec user stdbuf -oL sctp_test -H 1.1.1.1 -B 2.2.2.1 -P 20000 -h $extIP -p $port -s -m 100 -x 100000 > user.out & +sleep 1 +#Path counters +p1c_old=0 +p1c_new=0 +p2c_old=0 +p2c_new=0 +p3c_old=0 +p3c_new=0 + +for((i=0;i<100;i++)) do + fin=`tail -n 100 user.out | grep "Client: Sending packets.(100000/100000)"` + if [[ ! -z $fin ]]; then + fin=1 + echo "sctp_test done." + break; + fi + $dexec llb1 loxicmd get ct + echo -e "\n" + p1c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "123.123.123.1 | 1.1.1.1" | xargs | cut -d '|' -f 10) + p2c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "124.124.124.1 | 2.2.2.1" | xargs | cut -d '|' -f 10) + p3c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "125.125.125.1 | 1.1.1.1" | xargs | cut -d '|' -f 10) + + echo "Counters: $p1c_new $p2c_new $p3c_new" + + if [[ $p1c_new -gt $p1c_old ]]; then + echo "Path 1: 1.1.1.1 -> 123.123.123.1 [ACTIVE]" + p1=1 + else + echo "Path 1: 1.1.1.1 -> 123.123.123.1 [NOT ACTIVE]" + fi + + if [[ $p2c_new -gt $p2c_old ]]; then + echo "Path 2: 2.2.2.1 -> 124.124.124.1 [ACTIVE]" + p2=1 + else + echo "Path 2: 2.2.2.1 -> 124.124.124.1 [NOT ACTIVE]" + fi + + if [[ $p3c_new -gt $p3c_old ]]; then + echo "Path 3: 1.1.1.1 -> 125.125.125.1 [ACTIVE]" + p3=1 + else + echo "Path 3: 1.1.1.1 -> 125.125.125.1 [NOT ACTIVE]" + fi + p1c_old=$p1c_new + p2c_old=$p1c_new + p2c_old=$p1c_new + echo -e "\n" + sleep 5 +done + +#sudo rm -rf user.out +sudo pkill sctp_test +sudo rm *.out +if [[ $fin == 1 && $p1 == 1 && $p2 == 1 && $p3 == 1 ]]; then + echo "sctpmh SCTP Multihoming Multipath [OK]" +else + echo "sctpmh SCTP Multihoming Multipath [NOK]" + echo -e "\nuser" + sudo ip netns exec user ip route + echo -e "\nr1" + sudo ip netns exec r1 ip route + echo -e "\nr2" + sudo ip netns exec r2 ip route + echo -e "\nllb1" + sudo ip netns exec llb1 ip route + echo -e "\nr3" + sudo ip netns exec r3 ip route + echo -e "\nr4" + sudo ip netns exec r4 ip route + echo "-----------------------------" + + echo -e "\nllb1 lb-info" + $dexec llb1 loxicmd get lb + echo "llb1 ep-info" + $dexec llb1 loxicmd get ep + exit 1 +fi +echo -e "------------------------------------------------------------------------------------\n\n\n" diff --git a/cicd/sctpmh/validation3.sh b/cicd/sctpmh/validation3.sh new file mode 100755 index 000000000..fa3b308e4 --- /dev/null +++ b/cicd/sctpmh/validation3.sh @@ -0,0 +1,113 @@ +#!/bin/bash +source ../common.sh + +echo -e "sctpmh: SCTP Multihoming - Multipath Failover Test. Client and LB Multihomed, EP is uni-homed\n" +extIP="123.123.123.1" +port=2020 + +echo "SCTP Multihoming service sctp-lb(Multipath traffic) -> $extIP:$port" +echo -e "------------------------------------------------------------------------------------\n" + +echo -e "\nTraffic Flow: User -> LB -> EP " + +$hexec ep1 sctp_test -H 0.0.0.0 -P 9999 -l > ep1.out & +sleep 2 + +$hexec user stdbuf -oL sctp_test -H 1.1.1.1 -B 2.2.2.1 -P 20000 -h $extIP -p $port -s -m 100 -x 100000 > user.out & +sleep 5 +#Path counters +p1c_old=0 +p1c_new=0 +p2c_old=0 +p2c_new=0 +p3c_old=0 +p3c_new=0 +down=0 +code=0 +for((i=0;i<200;i++)) do + fin=`tail -n 100 user.out | grep "Client: Sending packets.(100000/100000)"` + if [[ ! -z $fin ]]; then + fin=1 + echo "sctp_test done." + break; + fi + $dexec llb1 loxicmd get ct + echo -e "\n" + p1c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "123.123.123.1 | 1.1.1.1" | xargs | cut -d '|' -f 10) + p2c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "124.124.124.1 | 2.2.2.1" | xargs | cut -d '|' -f 10) + p3c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "125.125.125.1 | 1.1.1.1" | xargs | cut -d '|' -f 10) + + echo "Counters: $p1c_new $p2c_new $p3c_new" + + if [[ $p1c_new -gt $p1c_old ]]; then + echo "Path 1: 1.1.1.1 -> 123.123.123.1 [ACTIVE]" + p1=1 + if [[ $down == 1 ]]; then + echo "This path shouldn't be ACTIVE" + code=1 + fi + echo "Turning off this path from User->LB" + $hexec user ip link set euserr1 down; + down=1 + p1c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "123.123.123.1 | 1.1.1.1" | xargs | cut -d '|' -f 10) + else + if [[ $down == 1 ]]; then + p1dok=1 + echo "Path 1: 1.1.1.1 -> 123.123.123.1 NOT ACTIVE - [OK]" + else + echo "Path 1: 1.1.1.1 -> 123.123.123.1 [NOT ACTIVE]" + fi + fi + + if [[ $p2c_new -gt $p2c_old ]]; then + echo "Path 2: 2.2.2.1 -> 124.124.124.1 [ACTIVE]" + p2=1 + else + echo "Path 2: 2.2.2.1 -> 124.124.124.1 [NOT ACTIVE]" + fi + + if [[ $p3c_new -gt $p3c_old ]]; then + echo "Path 3: 1.1.1.1 -> 125.125.125.1 [ACTIVE]" + p3=1 + else + echo "Path 3: 1.1.1.1 -> 125.125.125.1 [NOT ACTIVE]" + fi + p1c_old=$p1c_new + p2c_old=$p1c_new + p2c_old=$p1c_new + echo -e "\n" + sleep 5 +done + +sudo rm -rf *.out +sudo pkill sctp_test + +#Restore +$hexec user ip link set euserr1 up +$hexec user ip route add default via 1.1.1.254 + +if [[ $fin == 1 && $p1 == 1 && $p2 == 1 && $p3 == 1 && $p1dok == 1 && $code == 0 ]]; then + echo "sctpmh SCTP Multihoming Multipath Failover [OK]" +else + echo "sctpmh SCTP Multihoming Multipath Failover [NOK]" + echo -e "\nuser" + sudo ip netns exec user ip route + echo -e "\nr1" + sudo ip netns exec r1 ip route + echo -e "\nr2" + sudo ip netns exec r2 ip route + echo -e "\nllb1" + sudo ip netns exec llb1 ip route + echo -e "\nr3" + sudo ip netns exec r3 ip route + echo -e "\nr4" + sudo ip netns exec r4 ip route + echo "-----------------------------" + + echo -e "\nllb1 lb-info" + $dexec llb1 loxicmd get lb + echo "llb1 ep-info" + $dexec llb1 loxicmd get ep + exit 1 +fi +echo -e "------------------------------------------------------------------------------------\n\n\n" diff --git a/cicd/sctpmh/validation4.sh b/cicd/sctpmh/validation4.sh new file mode 100755 index 000000000..aef8b4c01 --- /dev/null +++ b/cicd/sctpmh/validation4.sh @@ -0,0 +1,113 @@ +#!/bin/bash +source ../common.sh + +echo -e "sctpmh: SCTP Multihoming - Multipath Failover Test. Client, LB and EP all Multihomed\n" +extIP="133.133.133.1" +port=2020 + +echo "SCTP Multihoming service sctp-lb(Multipath traffic) -> $extIP:$port" +echo -e "------------------------------------------------------------------------------------\n" + +echo -e "\nTraffic Flow: EP ---> LB ---> User" + +$hexec user sctp_test -H 1.1.1.1 -B 2.2.2.1 -P 9999 -l > user.out & +sleep 2 + +$hexec ep1 stdbuf -oL sctp_test -H 31.31.31.1 -B 32.32.32.1 -P 20000 -h $extIP -p $port -s -m 100 -x 100000 > ep1.out & +sleep 5 +#Path counters +p1c_old=0 +p1c_new=0 +p2c_old=0 +p2c_new=0 +p3c_old=0 +p3c_new=0 +down=0 +code=0 +for((i=0;i<200;i++)) do + fin=`tail -n 100 ep1.out | grep "Client: Sending packets.(100000/100000)"` + if [[ ! -z $fin ]]; then + fin=1 + echo "sctp_test done." + break; + fi + $dexec llb1 loxicmd get ct + echo -e "\n" + p1c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "133.133.133.1 | 31.31.31.1" | xargs | cut -d '|' -f 10) + p2c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "134.134.134.1 | 32.32.32.1" | xargs | cut -d '|' -f 10) + p3c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "135.135.135.1 | 31.31.31.1" | xargs | cut -d '|' -f 10) + + echo "Counters: $p1c_new $p2c_new $p3c_new" + + if [[ $p1c_new -gt $p1c_old ]]; then + echo "Path 1: 31.31.31.1 -> 133.133.133.1 -> 1.1.1.1 [ACTIVE]" + p1=1 + if [[ $down == 1 ]]; then + echo "This path shouldn't be ACTIVE" + code=1 + fi + echo -e "Turning off this path at User.\nEP----->LB--x-->User" + $hexec user ip link set euserr1 down; + down=1 + p1c_new=$(sudo docker exec -i llb1 loxicmd get ct | grep "133.133.133.1 | 31.31.31.1" | xargs | cut -d '|' -f 10) + else + if [[ $down == 1 ]]; then + p1dok=1 + echo "Path 1: 31.31.31.1 -> 133.133.133.1 -> 1.1.1.1 NOT ACTIVE - [OK]" + else + echo "Path 1: 31.31.31.1 -> 133.133.133.1 -> 1.1.1.1 [NOT ACTIVE]" + fi + fi + + if [[ $p2c_new -gt $p2c_old ]]; then + echo "Path 2: 32.32.32.1 -> 134.134.134.1 -> 2.2.2.1 [ACTIVE]" + p2=1 + else + echo "Path 2: 32.32.32.1 -> 134.134.134.1 -> 2.2.2.1 [NOT ACTIVE]" + fi + + if [[ $p3c_new -gt $p3c_old ]]; then + echo "Path 3: 31.31.31.1 -> 135.135.135.1 -> 1.1.1.1 [ACTIVE]" + p3=1 + else + echo "Path 3: 31.31.31.1 -> 135.135.135.1 -> 1.1.1.1 [NOT ACTIVE]" + fi + p1c_old=$p1c_new + p2c_old=$p1c_new + p2c_old=$p1c_new + echo -e "\n" + sleep 5 +done + +sudo rm -rf *.out +sudo pkill sctp_test + +#Restore +$hexec user ip link set euserr1 up +$hexec user ip route add default via 1.1.1.254 + +if [[ $fin == 1 && $p1 == 1 && $p2 == 1 && $p3 == 1 && $p1dok == 1 && $code == 0 ]]; then + echo "sctpmh SCTP Multihoming E2E Multipath Failover [OK]" +else + echo "sctpmh SCTP Multihoming E2E Multipath Failover [NOK]" + echo -e "\nuser" + sudo ip netns exec user ip route + echo -e "\nr1" + sudo ip netns exec r1 ip route + echo -e "\nr2" + sudo ip netns exec r2 ip route + echo -e "\nllb1" + sudo ip netns exec llb1 ip route + echo -e "\nr3" + sudo ip netns exec r3 ip route + echo -e "\nr4" + sudo ip netns exec r4 ip route + echo "-----------------------------" + + echo -e "\nllb1 lb-info" + $dexec llb1 loxicmd get lb + echo "llb1 ep-info" + $dexec llb1 loxicmd get ep + exit 1 +fi +echo -e "------------------------------------------------------------------------------------\n\n\n" diff --git a/pkg/loxinet/cluster.go b/pkg/loxinet/cluster.go index 9561a0799..486bd4c3f 100644 --- a/pkg/loxinet/cluster.go +++ b/pkg/loxinet/cluster.go @@ -283,17 +283,17 @@ func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) { return -1, errors.New("cluster instance not found") } - ip := net.ParseIP(string(bm.RemoteIP)) + ip := net.ParseIP(bm.RemoteIP.String()) if ip == nil { return -1, errors.New("remoteIP address malformed") } - myIP := net.ParseIP(string(bm.SourceIP)) - if myIP == nil { - return -1, errors.New("source address malformed") - } - if !h.SpawnKa { + myIP := net.ParseIP(bm.SourceIP.String()) + if myIP == nil { + return -1, errors.New("source address malformed") + } + tk.LogIt(tk.LogInfo, "[CLUSTER] Cluster Instance %s starting BFD..\n", bm.Instance) h.SpawnKa = true