Skip to content

Commit

Permalink
Merge pull request loxilb-io#410 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - Do not select src if src is also dest endpoint
  • Loading branch information
UltraInstinct14 authored Oct 12, 2023
2 parents a9e268e + 7827ed2 commit 2a02ca8
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 68 deletions.
1 change: 1 addition & 0 deletions cicd/k8s-calico-incluster/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ done
vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/tcp_fullnat.yml' 2> /dev/null
vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/udp_fullnat.yml' 2> /dev/null
vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/sctp_fullnat.yml' 2> /dev/null
vagrant ssh master -c 'kubectl apply -f /vagrant/yaml/sctp.yml' 2> /dev/null
5 changes: 5 additions & 0 deletions cicd/k8s-calico-incluster/node_scripts/host.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
sudo su
sudo apt-get install -y lksctp-tools socat
wget https://github.com/loxilb-io/loxilb/raw/main/cicd/common/sctp_client
wget https://github.com/loxilb-io/loxilb/raw/main/cicd/common/udp_client
chmod 777 sctp_client
chmod 777 udp_client
echo "123.123.123.1 k8s-svc" >> /etc/hosts
ifconfig eth2 mtu 1450
ip route add 123.123.123.0/24 via 192.168.90.10
Expand Down
22 changes: 21 additions & 1 deletion cicd/k8s-calico-incluster/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,33 @@ else
code=1
fi

out=$(vagrant ssh host -c "timeout 5 /vagrant/tools/udp_client $extIP ${udp_port[i]}")
out=$(vagrant ssh host -c "timeout 5 ./udp_client $extIP ${udp_port[i]}")
if [[ ${out} == *"Client"* ]]; then
echo -e "K8s-calico-incluster UDP\t(${mode[i]})\t[OK]"
else
echo -e "K8s-calico-incluster UDP\t(${mode[i]})\t[FAILED]"
code=1
fi

out=$(vagrant ssh host -c "socat -T10 - SCTP:$extIP:${sctp_port[i]},bind=192.168.90.9")
if [[ ${out} == *"server"* ]]; then
echo -e "K8s-calico-incluster SCTP\t(${mode[i]})\t[OK]"
else
echo -e "K8s-calico-incluster SCTP\t(${mode[i]})\t[FAILED]"
code=1
fi
done

mode=( "default" )
sctp_port=( 55004 )
code=0

out=$(vagrant ssh host -c "socat -T10 - SCTP:$extIP:${sctp_port[0]},bind=192.168.90.9")
if [[ ${out} == *"server"* ]]; then
echo -e "K8s-calico-incluster SCTP\t(${mode[0]})\t[OK]"
else
echo -e "K8s-calico-incluster SCTP\t(${mode[0]})\t[FAILED]"
code=1
fi

exit $code
1 change: 1 addition & 0 deletions cicd/k8s-calico-incluster/yaml/loxilb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
containers:
- name: loxilb-app
image: "ghcr.io/loxilb-io/loxilb:latest"
imagePullPolicy: Always
command: [ "/root/loxilb-io/loxilb/loxilb", "--bgp", "--egr-hooks", "--blacklist=cali.|tunl.|vxlan[.]calico|veth." ]
ports:
- containerPort: 11111
Expand Down
11 changes: 10 additions & 1 deletion cicd/k8s-calico-incluster/yaml/sctp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: Service
metadata:
name: sctp-lb-default
annotations:
loxilb.io/liveness: "yes"
loxilb.io/lbmode: "default"
spec:
loadBalancerClass: loxilb.io/loxilb
Expand All @@ -23,6 +22,16 @@ metadata:
labels:
what: sctp-default-test
spec:
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: Exists
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/control-plane"
operator: Exists
containers:
- name: sctp-default-test
image: ghcr.io/loxilb-io/alpine-socat:latest
Expand Down
1 change: 1 addition & 0 deletions cicd/udplb/msg.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
)j��g�E;�J@@-�77f�77e�"e'�r V<�77f`�PU+
Hello World
Hello World
Hello World
Expand Down
13 changes: 13 additions & 0 deletions cicd/udplb/msg_short.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
)j��g�E;�J@@-�77f�77e�"e'�r V<�77f`�PU+
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Binary file modified cicd/udplb/udp_jumbo_app
Binary file not shown.
14 changes: 9 additions & 5 deletions cicd/udplb/udp_jumbo_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"errors"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -65,8 +64,10 @@ func main() {
//fmt.Print("-> ", string(buffer[:]))
count++
if count == 1 && !bytes.Equal(abuf, fbuffer) {
panic(errors.New("Fail match"))
fmt.Println("unexpected msg %v", abuf)
continue
}

_, err = connection.WriteToUDP(abuf, addr)
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -126,9 +127,12 @@ func UDPClient() {
os.Exit(1)
}

// Send a message to the server
fbuffer = []byte("hello")
buffer = []byte("hello")
// Send another message to the server
f, err = os.Open("./msg_short.txt")
Check(err)

_, err = f.Read(fbuffer)
Check(err)

_, err = conn.Write(fbuffer)
if err != nil {
Expand Down
Loading

0 comments on commit 2a02ca8

Please sign in to comment.