Skip to content

Commit

Permalink
Merge pull request #649 from nik-netlox/main
Browse files Browse the repository at this point in the history
SCTP MH CICD
  • Loading branch information
UltraInstinct14 authored Apr 23, 2024
2 parents d4a9c38 + bf13a57 commit eadc7c9
Show file tree
Hide file tree
Showing 9 changed files with 350 additions and 23 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/sctpmh-sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: SCTP-MH-LB-Sanity-CI

on:
push:
branches:
- main
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'SCTP MH LB Sanity'

jobs:
build:
name: sctpmh-lb-sanity
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
- uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- run: sudo apt-get update
- run: sudo apt-get -y install clang-10 llvm libelf-dev gcc-multilib libpcap-dev linux-tools-$(uname -r) elfutils dwarves git libbsd-dev bridge-utils unzip build-essential bison flex iperf iproute2 nodejs socat ethtool curl
- run: |
git clone --recurse-submodules https://github.com/loxilb-io/iproute2 iproute2-main
cd iproute2-main/libbpf/src/
sudo make install
mkdir build
DESTDIR=build OBJDIR=build make install
cd -
cd iproute2-main/
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:`pwd`/libbpf/src/ && LIBBPF_FORCE=on LIBBPF_DIR=`pwd`/libbpf/src/build ./configure && make && sudo cp -f tc/tc /usr/local/sbin/ntc && cd -
- run: loxilb-ebpf/utils/mkllb_bpffs.sh
- run: sudo -E env "PATH=$PATH" make
- run: sudo -E env "PATH=$PATH" make test
- run: docker pull ghcr.io/loxilb-io/loxilb:latest
- run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latest
- run: pwd && ls && sudo -E env "PATH=$PATH" make docker-cp
- run: docker exec -dit loxilb mkllb_bpffs
- run: id=`docker ps -f name=loxilb | cut -d " " -f 1 | grep -iv "CONTAINER"` && docker commit $id ghcr.io/loxilb-io/loxilb:latest
- run: docker stop loxilb && docker rm loxilb
- run: |
cd cicd/sctpmh/
./config.sh
./validation.sh
./rmconfig.sh
cd -
65 changes: 65 additions & 0 deletions cicd/sctpmh/check_ha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

master="llb1"
backup="llb2"

function check_ha() {
while : ; do
status1=$($hexec llb1 curl -sX 'GET' 'http://0.0.0.0:11111/netlox/v1/config/cistate/all' -H 'accept: application/json' | jq -r '.Attr[0].state')
status2=$($hexec llb2 curl -sX 'GET' 'http://0.0.0.0:11111/netlox/v1/config/cistate/all' -H 'accept: application/json' | jq -r '.Attr[0].state')
count=0
if [[ $status1 == "MASTER" && $status2 == "BACKUP" ]];
then
master="llb1"
backup="llb2"
break
elif [[ $status2 == "MASTER" && $status1 == "BACKUP" ]];
then
master="llb2"
backup="llb1"
break
else
count=$(( $count + 1 ))
if [[ $count -ge 20 ]]; then
echo "KA llb1-$status1, llb2-$status2 [NOK]" >&2
exit 1;
fi
sleep 5
fi
done
}

function checkSync() {
count=1
sync=0
while [[ $count -le 5 ]] ; do
echo -e "\nStatus at MASTER:$master\n" >&2
$dexec $master loxicmd get ct | grep est >&2

echo -e "\nStatus at BACKUP:$backup\n" >&2
$dexec $backup loxicmd get ct | grep est >&2

nres1=$($hexec $master curl -sX 'GET' 'http://0.0.0.0:11111/netlox/v1/config/conntrack/all' -H 'accept: application/json' | grep -ow "\"conntrackState\":\"est\"" | wc -l)
nres2=$($hexec $backup curl -sX 'GET' 'http://0.0.0.0:11111/netlox/v1/config/conntrack/all' -H 'accept: application/json' | grep -ow "\"conntrackState\":\"est\"" | wc -l)

if [[ $nres1 == 0 ]]; then
echo -e "No active connections in Master:$master. Exiting!" >&2
return 0
fi

if [[ $nres1 == $nres2 && $nres1 != 0 ]]; then
echo -e "\nConnections sync successful!!!\n" >&2
sync=1
break;
fi
echo -e "\nConnections sync pending.. Let's wait a little more..\n" >&2
count=$(( $count + 1 ))
sleep 2
done

if [[ $sync == 0 ]]; then
echo -e "\nConnection Sync failed\n" >&2
return 0
fi
echo "$sync"
}
40 changes: 33 additions & 7 deletions cicd/sctpmh/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ echo "#########################################"
echo "Spawning all hosts"
echo "#########################################"

spawn_docker_host --dock-type loxilb --dock-name llb1
spawn_docker_host --dock-type loxilb --dock-name llb1 --with-ka in
spawn_docker_host --dock-type loxilb --dock-name llb2 --with-ka in
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
Expand All @@ -25,17 +26,21 @@ connect_docker_hosts user r2
connect_docker_hosts r1 sw1
connect_docker_hosts r2 sw1
connect_docker_hosts sw1 llb1
connect_docker_hosts sw1 llb2
connect_docker_hosts llb1 sw2
connect_docker_hosts llb2 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 llb2
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 llb2
create_docker_host_cnbridge --host1 sw2 --host2 r3
create_docker_host_cnbridge --host1 sw2 --host2 r4

Expand All @@ -46,19 +51,23 @@ 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 llb2 --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 r1 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.253/24 --gw 11.11.11.11
config_docker_host --host1 r2 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.254/24 --gw 11.11.11.11
config_docker_host --host1 llb1 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.1/24
config_docker_host --host1 llb2 --host2 sw1 --ptype vlan --id 11 --addr 11.11.11.2/24

create_docker_host_vlan --host1 llb1 --host2 sw2 --id 10 --ptype untagged
create_docker_host_vlan --host1 llb2 --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 r3 --host2 sw2 --ptype vlan --id 10 --addr 10.10.10.253/24 --gw 10.10.10.10
config_docker_host --host1 r4 --host2 sw2 --ptype vlan --id 10 --addr 10.10.10.254/24 --gw 10.10.10.10
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 llb2 --host2 sw2 --ptype vlan --id 10 --addr 10.10.10.2/24

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
Expand All @@ -81,16 +90,33 @@ $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 llb2 ip route add 1.1.1.0/24 via 11.11.11.253
$hexec llb2 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
$hexec llb2 ip route add 31.31.31.0/24 via 10.10.10.253
$hexec llb2 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 llb1 123.123.123.1 --name=sctpmh1 --secips=124.124.124.1,125.125.125.1 --sctp=2020:9999 --endpoints=31.31.31.1:1 --mode=fullnat
create_lb_rule llb2 123.123.123.1 --name=sctpmh1 --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
create_lb_rule llb1 133.133.133.1 --name=sctpmh2 --secips=134.134.134.1,135.135.135.1 --sctp=2020:9999 --endpoints=1.1.1.1:1 --mode=fullnat
create_lb_rule llb2 133.133.133.1 --name=sctpmh2 --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
$dexec llb2 loxicmd create ep 1.1.1.1 --name=1.1.1.1_sctp_9999 --probetype=none
$dexec llb2 loxicmd create ep 31.31.31.1 --name=31.31.31.1_sctp_9999 --probetype=none


create_lb_rule llb1 11.11.11.11 --tcp=80:8080 --endpoints=31.31.31.1:1
create_lb_rule llb2 11.11.11.11 --tcp=80:8080 --endpoints=31.31.31.1:1
create_lb_rule llb1 10.10.10.10 --tcp=80:8080 --endpoints=31.31.31.1:1
create_lb_rule llb2 10.10.10.10 --tcp=80:8080 --endpoints=31.31.31.1:1

$dexec llb1 loxicmd save --all
$dexec llb2 loxicmd save --all
3 changes: 3 additions & 0 deletions cicd/sctpmh/rmconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ disconnect_docker_hosts user r2
disconnect_docker_hosts r1 sw1
disconnect_docker_hosts r2 sw1
disconnect_docker_hosts sw1 llb1
disconnect_docker_hosts sw1 llb2
disconnect_docker_hosts llb1 sw2
disconnect_docker_hosts llb2 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 llb2
delete_docker_host user
delete_docker_host r1
delete_docker_host r2
Expand Down
3 changes: 3 additions & 0 deletions cicd/sctpmh/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ echo -e "***********************************************************************
echo -e "\n\n\nSCTP Multihoming - Test case #4"
echo -e "*********************************************************************************"
./validation4.sh
echo -e "\n\n\nSCTP Multihoming - Test case #5"
echo -e "*********************************************************************************"
./validation5.sh
echo -e "\n\n\n*********************************************************************************"
21 changes: 16 additions & 5 deletions cicd/sctpmh/validation2.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/bash
source ../common.sh

source check_ha.sh
echo -e "sctpmh: SCTP Multihoming - Multipath Test, Client and LB Multihomed, EP is uni-homed\n"
extIP="123.123.123.1"
port=2020

check_ha

echo "SCTP Multihoming service sctp-lb(Multipath traffic) -> $extIP:$port"
echo -e "------------------------------------------------------------------------------------\n"

echo -e "\nHA state Master:$master BACKUP-$backup\n"

$hexec ep1 sctp_test -H 0.0.0.0 -P 9999 -l > ep1.out &
sleep 2

Expand All @@ -28,11 +32,11 @@ for((i=0;i<100;i++)) do
echo "sctp_test done."
break;
fi
$dexec llb1 loxicmd get ct
$dexec $master loxicmd get ct --servName=sctpmh1
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)
p1c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "123.123.123.1 | 1.1.1.1" | xargs | cut -d '|' -f 10)
p2c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "124.124.124.1 | 2.2.2.1" | xargs | cut -d '|' -f 10)
p3c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "125.125.125.1 | 1.1.1.1" | xargs | cut -d '|' -f 10)

echo "Counters: $p1c_new $p2c_new $p3c_new"

Expand Down Expand Up @@ -78,6 +82,8 @@ else
sudo ip netns exec r2 ip route
echo -e "\nllb1"
sudo ip netns exec llb1 ip route
echo -e "\nllb2"
sudo ip netns exec llb2 ip route
echo -e "\nr3"
sudo ip netns exec r3 ip route
echo -e "\nr4"
Expand All @@ -88,6 +94,11 @@ else
$dexec llb1 loxicmd get lb
echo "llb1 ep-info"
$dexec llb1 loxicmd get ep
echo "-----------------------------"
echo -e "\nllb2 lb-info"
$dexec llb2 loxicmd get lb
echo "llb2 ep-info"
$dexec llb2 loxicmd get ep
exit 1
fi
echo -e "------------------------------------------------------------------------------------\n\n\n"
22 changes: 17 additions & 5 deletions cicd/sctpmh/validation3.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/bash
source ../common.sh
source check_ha.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

check_ha

echo "SCTP Multihoming service sctp-lb(Multipath traffic) -> $extIP:$port"
echo -e "------------------------------------------------------------------------------------\n"

echo -e "\nHA state Master:$master BACKUP-$backup\n"

echo -e "\nTraffic Flow: User -> LB -> EP "

$hexec ep1 sctp_test -H 0.0.0.0 -P 9999 -l > ep1.out &
Expand All @@ -31,11 +36,11 @@ for((i=0;i<200;i++)) do
echo "sctp_test done."
break;
fi
$dexec llb1 loxicmd get ct
$dexec $master loxicmd get ct --servName=sctpmh1
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)
p1c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "123.123.123.1 | 1.1.1.1" | xargs | cut -d '|' -f 10)
p2c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "124.124.124.1 | 2.2.2.1" | xargs | cut -d '|' -f 10)
p3c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "125.125.125.1 | 1.1.1.1" | xargs | cut -d '|' -f 10)

echo "Counters: $p1c_new $p2c_new $p3c_new"

Expand All @@ -49,7 +54,7 @@ for((i=0;i<200;i++)) do
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)
p1c_new=$(sudo docker exec -i $master loxicmd get ct --servName=sctpmh1 | grep "123.123.123.1 | 1.1.1.1" | xargs | cut -d '|' -f 10)
else
if [[ $down == 1 ]]; then
p1dok=1
Expand Down Expand Up @@ -98,6 +103,8 @@ else
sudo ip netns exec r2 ip route
echo -e "\nllb1"
sudo ip netns exec llb1 ip route
echo -e "\nllb2"
sudo ip netns exec llb2 ip route
echo -e "\nr3"
sudo ip netns exec r3 ip route
echo -e "\nr4"
Expand All @@ -108,6 +115,11 @@ else
$dexec llb1 loxicmd get lb
echo "llb1 ep-info"
$dexec llb1 loxicmd get ep
echo -e "\nllb2 lb-info"
$dexec llb2 loxicmd get lb
echo "llb2 ep-info"
$dexec llb2 loxicmd get ep
echo "-----------------------------"
exit 1
fi
echo -e "------------------------------------------------------------------------------------\n\n\n"
Loading

0 comments on commit eadc7c9

Please sign in to comment.