-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run shell scripts that start the br daemon, configure it and ensure that it works as expected. As a starting point, 2 tests are added: - basic configuration and cli commands that interact with the API - IP forwarding (with dynamic ARP resolution) using the net_tap driver and linux network namespaces. Signed-off-by: Robin Jarry <[email protected]>
- Loading branch information
Showing
6 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set -e | ||
|
||
cleanup() { | ||
set +e | ||
kill -INT %1 | ||
wait | ||
if [ -r $tmp/cleanup ]; then | ||
sh -x $tmp/cleanup | ||
fi | ||
rm -rf -- "$tmp" | ||
} | ||
|
||
tmp=$(mktemp -d) | ||
trap cleanup EXIT | ||
sock=$tmp/br.sock | ||
|
||
alias scapy="scapy -HCP" | ||
alias br="$1 -s $sock" | ||
alias br-cli="$2 -s $sock" | ||
|
||
set -x | ||
|
||
br -tv & | ||
socat FILE:/dev/null UNIX-CONNECT:$sock,retry=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
. $(dirname $0)/_init.sh | ||
|
||
br-cli -xe <<EOF | ||
add interface port p0 devargs net_null0 | ||
add interface port p1 devargs net_null1 | ||
add ip address 10.0.0.1/24 iface p0 | ||
add ip address 10.1.0.1/24 iface p1 | ||
add ip route 0.0.0.0/0 via 10.0.0.2 | ||
show interface all | ||
show ip route | ||
show ip nexthop | ||
show graph dot | ||
show stats software | ||
show stats hardware | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
. $(dirname $0)/_init.sh | ||
|
||
p0=brtap0 | ||
p1=brtap1 | ||
|
||
br-cli -xe <<EOF | ||
add interface port $p0 devargs net_tap0,iface=$p0 | ||
add interface port $p1 devargs net_tap1,iface=$p1 | ||
add ip address 10.0.0.1/24 iface $p0 | ||
add ip address 10.1.0.1/24 iface $p1 | ||
EOF | ||
|
||
for n in 0 1; do | ||
ip netns add brns$n | ||
echo ip netns del brns$n >> $tmp/cleanup | ||
ip link set brtap$n netns brns$n | ||
ip -n brns$n link set brtap$n up | ||
ip -n brns$n addr add 10.$n.0.2/24 dev brtap$n | ||
ip -n brns$n route add default via 10.$n.0.1 | ||
done | ||
|
||
ip netns exec brns0 ping -c3 10.1.0.2 | ||
ip netns exec brns1 ping -c3 10.0.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2024 Robin Jarry | ||
|
||
sudo = find_program('sudo') | ||
scapy = find_program('scapy') | ||
|
||
test_scripts = files( | ||
'config_test.sh', | ||
'ip_forward_test.sh', | ||
) | ||
|
||
foreach t : test_scripts | ||
name = fs.replace_suffix(t, '') | ||
test(name, sudo, args: [t, br_exe, br_cli_exe], suite: 'integration') | ||
endforeach |