Skip to content

gh-28 Initial support for NAT64/46 #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/advanced-lb-sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Adv-LB-Sanity-CI

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

jobs:
build:
name: advanced-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.17.0'
- run: sudo apt-get update
- run: sudo apt -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
- run: |
git clone https://github.com/loxilb-io/iproute2 iproute2-main
cd iproute2-main/libbpf/src/
sudo make install
mkdir build
DESTDIR=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: 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/onearml2/
./config.sh
./validation.sh
./rmconfig.sh
cd -
cd cicd/lbtimeout/
./config.sh
./validation.sh
./rmconfig.sh
cd -
cd cicd/sctpfullnat/
./config.sh
./validation.sh
./rmconfig.sh
cd -
15 changes: 0 additions & 15 deletions .github/workflows/advanced-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,3 @@ jobs:
./validation.sh
./rmconfig.sh
cd -
cd cicd/scenario11/
./config.sh
./validation.sh
./rmconfig.sh
cd -
cd cicd/scenario12/
./config.sh
./validation.sh
./rmconfig.sh
cd -
cd cicd/sctp-fullnat/
./config.sh
./validation.sh
./rmconfig.sh
cd -
32 changes: 17 additions & 15 deletions api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ func AddAddr(addr nlp.Addr, link nlp.Link) int {
name := attrs.Name
ipStr := (addr.IPNet).String()

ret, err := hooks.NetIpv4AddrAdd(&cmn.Ipv4AddrMod{Dev: name, IP: ipStr})
ret, err := hooks.NetAddrAdd(&cmn.IpAddrMod{Dev: name, IP: ipStr})
if err != nil {
tk.LogIt(tk.LogError, "[NLP] IPv4 Address %v Port %v failed %v\n", ipStr, name, err)
ret = -1
Expand Down Expand Up @@ -861,8 +861,9 @@ func AddNeigh(neigh nlp.Neigh, link nlp.Link) int {
}
copy(mac[:], neigh.HardwareAddr[:6])

if neigh.Family == unix.AF_INET {
ret, err = hooks.NetNeighv4Add(&cmn.Neighv4Mod{IP: neigh.IP, LinkIndex: neigh.LinkIndex,
if neigh.Family == unix.AF_INET ||
neigh.Family == unix.AF_INET6 {
ret, err = hooks.NetNeighAdd(&cmn.NeighMod{IP: neigh.IP, LinkIndex: neigh.LinkIndex,
State: neigh.State,
HardwareAddr: neigh.HardwareAddr})
if err != nil {
Expand Down Expand Up @@ -944,9 +945,10 @@ func DelNeigh(neigh nlp.Neigh, link nlp.Link) int {
attrs := link.Attrs()
name := attrs.Name

if neigh.Family == unix.AF_INET {
if neigh.Family == unix.AF_INET ||
neigh.Family == unix.AF_INET6 {

ret, err = hooks.NetNeighv4Del(&cmn.Neighv4Mod{IP: neigh.IP})
ret, err = hooks.NetNeighDel(&cmn.NeighMod{IP: neigh.IP})
if err != nil {
tk.LogIt(tk.LogError, "[NLP] NH %v %v del failed\n", neigh.IP.String(), name)
ret = -1
Expand Down Expand Up @@ -1023,7 +1025,7 @@ func AddRoute(route nlp.Route) int {
} else {
ipNet = *route.Dst
}
ret, err := hooks.NetRoutev4Add(&cmn.Routev4Mod{Protocol: int(route.Protocol), Flags: route.Flags,
ret, err := hooks.NetRouteAdd(&cmn.RouteMod{Protocol: int(route.Protocol), Flags: route.Flags,
Gw: route.Gw, LinkIndex: route.LinkIndex, Dst: ipNet})
if err != nil {
if route.Gw != nil {
Expand Down Expand Up @@ -1087,7 +1089,7 @@ func DelRoute(route nlp.Route) int {
} else {
ipNet = *route.Dst
}
ret, err := hooks.NetRoutev4Del(&cmn.Routev4Mod{Dst: ipNet})
ret, err := hooks.NetRouteDel(&cmn.RouteMod{Dst: ipNet})
if err != nil {
if route.Gw != nil {
tk.LogIt(tk.LogError, "[NLP] RT %s via %s delete failed-%s\n", ipNet.String(),
Expand Down Expand Up @@ -1123,21 +1125,21 @@ func AUWorkSingle(m nlp.AddrUpdate) int {
attrs := link.Attrs()
name := attrs.Name
if m.NewAddr {
_, err := hooks.NetIpv4AddrAdd(&cmn.Ipv4AddrMod{Dev: name, IP: m.LinkAddress.String()})
_, err := hooks.NetAddrAdd(&cmn.IpAddrMod{Dev: name, IP: m.LinkAddress.String()})
if err != nil {
tk.LogIt(tk.LogInfo, "[NLP] IPv4 Address %v Port %v add failed\n", m.LinkAddress.String(), name)
tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v add failed\n", m.LinkAddress.String(), name)
fmt.Println(err)
} else {
tk.LogIt(tk.LogInfo, "[NLP] IPv4 Address %v Port %v added\n", m.LinkAddress.String(), name)
tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v added\n", m.LinkAddress.String(), name)
}

} else {
_, err := hooks.NetIpv4AddrDel(&cmn.Ipv4AddrMod{Dev: name, IP: m.LinkAddress.String()})
_, err := hooks.NetAddrDel(&cmn.IpAddrMod{Dev: name, IP: m.LinkAddress.String()})
if err != nil {
tk.LogIt(tk.LogInfo, "[NLP] IPv4 Address %v Port %v delete failed\n", m.LinkAddress.String(), name)
tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v delete failed\n", m.LinkAddress.String(), name)
fmt.Println(err)
} else {
tk.LogIt(tk.LogInfo, "[NLP] IPv4 Address %v Port %v deleted\n", m.LinkAddress.String(), name)
tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v deleted\n", m.LinkAddress.String(), name)
}
}

Expand Down Expand Up @@ -1287,7 +1289,7 @@ func NlpGet(ch chan bool) int {
}
}

addrs, err := nlp.AddrList(link, nlp.FAMILY_V4)
addrs, err := nlp.AddrList(link, nlp.FAMILY_ALL)
if err != nil {
tk.LogIt(tk.LogError, "[NLP] Error getting address list %v for intf %s\n",
err, link.Attrs().Name)
Expand Down Expand Up @@ -1316,7 +1318,7 @@ func NlpGet(ch chan bool) int {
}

/* Get Routes */
routes, err := nlp.RouteList(link, nlp.FAMILY_V4)
routes, err := nlp.RouteList(link, nlp.FAMILY_ALL)
if err != nil {
tk.LogIt(tk.LogError, "[NLP] Error getting route list %v\n", err)
}
Expand Down
2 changes: 1 addition & 1 deletion api/restapi/handler/ipv4address.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ConfigDeleteIPv4Address(params operations.DeleteConfigIpv4addressIPAddressM

func ConfigGetIPv4Address(params operations.GetConfigIpv4addressAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
res, _ := ApiHooks.NetIpv4AddrGet()
res, _ := ApiHooks.NetAddrGet()
var result []*models.IPV4AddressGetEntry
result = make([]*models.IPV4AddressGetEntry, 0)
for _, ipaddrs := range res {
Expand Down
2 changes: 1 addition & 1 deletion api/restapi/handler/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func ConfigDeleteNeighbor(params operations.DeleteConfigNeighborIPAddressDevIfNa

func ConfigGetNeighbor(params operations.GetConfigNeighborAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
res, _ := ApiHooks.NetNeighv4Get()
res, _ := ApiHooks.NetNeighGet()
var result []*models.NeighborEntry
result = make([]*models.NeighborEntry, 0)
for _, neighbor := range res {
Expand Down
2 changes: 1 addition & 1 deletion api/restapi/handler/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ConfigDeleteRoute(params operations.DeleteConfigRouteDestinationIPNetIPAddr

func ConfigGetRoute(params operations.GetConfigRouteAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
res, _ := ApiHooks.NetRoutev4Get()
res, _ := ApiHooks.NetRouteGet()
var result []*models.RouteGetEntry
result = make([]*models.RouteGetEntry, 0)
for _, route := range res {
Expand Down
4 changes: 0 additions & 4 deletions cicd/README
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ Scenario8 - TCP Load Balancing after VxLAN Decap
Scenario9 - 3GPP GTP-ULCL SCTP LB Scenario

Scenario10 - SCTP Load Balancing after VxLAN Decap

Scenario11 - One-ARM Mode TCP Load Balancing

Scenario12 - Test reset establised TCP LB connection after inactivity
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
source ../common.sh
echo SCENARIO-12
echo LB-TIMEOUT
$hexec l3ep1 node ./server1.js &
$hexec l3ep2 node ./server2.js &
$hexec l3ep3 node ./server3.js &
Expand All @@ -25,7 +25,7 @@ do
if [[ $waitCount == 10 ]];
then
echo "All Servers are not UP"
echo SCENARIO-12[FAILED]
echo LB-TIMEOUT[FAILED]
exit 1
fi
fi
Expand Down Expand Up @@ -56,10 +56,10 @@ sleep 100
code=0
if pgrep -x "$SERVICE" >/dev/null
then
echo SCENARIO-12 [FAILED]
echo LB-TIMEOUT [FAILED]
code=1
else
echo SCENARIO-12 [OK]
echo LB-TIMEOUT [OK]
code=0
fi
sudo killall -9 iperf >> /dev/null 2>&1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions cicd/scenario11/validation.sh → cicd/onearml2/validation.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
source ../common.sh
echo SCENARIO-11
echo ONEARM-L2
$hexec l2ep1 node ./server1.js &
$hexec l2ep2 node ./server2.js &
$hexec l2ep3 node ./server3.js &
Expand All @@ -25,7 +25,7 @@ do
if [[ $waitCount == 10 ]];
then
echo "All Servers are not UP"
echo SCENARIO-11 [FAILED]
echo ONEARM-L2 [FAILED]
exit 1
fi
fi
Expand All @@ -47,11 +47,10 @@ done
done
if [[ $code == 0 ]]
then
echo ONEARM-L2 [OK]
else
$dexec llb1 loxicmd get ct
$dexec llb1 loxicmd get port
echo SCENARIO-11 [OK]
else
echo SCENARIO-11 [FAILED]
echo ONEARM-L2 [FAILED]
fi
exit $code

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 19 additions & 19 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,16 @@ type FdbMod struct {
Type int
}

// Ipv4AddrMod - Info about an ip address
type Ipv4AddrMod struct {
// IpAddrMod - Info about an ip address
type IpAddrMod struct {
// Dev - name of the related device
Dev string
// IP - Actual IP address
IP string
}

// Neighv4Mod - Info about an neighbor
type Neighv4Mod struct {
// NeighMod - Info about an neighbor
type NeighMod struct {
// IP - The IP address
IP net.IP
// LinkIndex - OS allocated index
Expand All @@ -298,8 +298,8 @@ type Neighv4Mod struct {
HardwareAddr net.HardwareAddr
}

// Ipv4AddrGet - Info about an ip addresses
type Ipv4AddrGet struct {
// IpAddrGet - Info about an ip addresses
type IpAddrGet struct {
// Dev - name of the related device
Dev string
// IP - Actual IP address
Expand All @@ -316,8 +316,8 @@ type RouteGetEntryStatistic struct {
Packets int
}

// Routev4Get - Info about an route
type Routev4Get struct {
// RouteGet - Info about an route
type RouteGet struct {
// Protocol - Protocol type
Protocol int
// Flags - flag type
Expand All @@ -336,8 +336,8 @@ type Routev4Get struct {
Sync DpStatusT
}

// Routev4Mod - Info about a route
type Routev4Mod struct {
// RouteMod - Info about a route
type RouteMod struct {
// Protocol - Protocol type
Protocol int
// Flags - flag type
Expand Down Expand Up @@ -687,15 +687,15 @@ type NetHookInterface interface {
NetVlanPortDel(*VlanPortMod) (int, error)
NetFdbAdd(*FdbMod) (int, error)
NetFdbDel(*FdbMod) (int, error)
NetIpv4AddrGet() ([]Ipv4AddrGet, error)
NetIpv4AddrAdd(*Ipv4AddrMod) (int, error)
NetIpv4AddrDel(*Ipv4AddrMod) (int, error)
NetNeighv4Get() ([]Neighv4Mod, error)
NetNeighv4Add(*Neighv4Mod) (int, error)
NetNeighv4Del(*Neighv4Mod) (int, error)
NetRoutev4Get() ([]Routev4Get, error)
NetRoutev4Add(*Routev4Mod) (int, error)
NetRoutev4Del(*Routev4Mod) (int, error)
NetAddrGet() ([]IpAddrGet, error)
NetAddrAdd(*IpAddrMod) (int, error)
NetAddrDel(*IpAddrMod) (int, error)
NetNeighGet() ([]NeighMod, error)
NetNeighAdd(*NeighMod) (int, error)
NetNeighDel(*NeighMod) (int, error)
NetRouteGet() ([]RouteGet, error)
NetRouteAdd(*RouteMod) (int, error)
NetRouteDel(*RouteMod) (int, error)
NetLbRuleAdd(*LbRuleMod) (int, error)
NetLbRuleDel(*LbRuleMod) (int, error)
NetLbRuleGet() ([]LbRuleMod, error)
Expand Down
Loading