osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38340?usp=email )


Change subject: ggsn: testenv: replace dummy netdev with bridge
......................................................................

ggsn: testenv: replace dummy netdev with bridge

Replace the dummy netdev that was used as network device reachable
through the GTP tunnel that can answer ICMP, with a bridge device. The
bridge device fulfils the same purpose, plus it can be used in a future
patch to connect osmo-ggsn when it is running in QEMU with the
testsuite.

Change-Id: I102d5b9ed0b3cafc263ad489ed4d4652f5e6dac8
---
M _testenv/data/podman/Dockerfile
A _testenv/data/scripts/add_remove_testenv0_bridge.sh
M _testenv/testenv/requirements.py
M ggsn_tests/open5gs/testenv.sh
M ggsn_tests/osmo-ggsn/testenv.sh
5 files changed, 53 insertions(+), 38 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/40/38340/1

diff --git a/_testenv/data/podman/Dockerfile b/_testenv/data/podman/Dockerfile
index 294ea82..13412a2 100644
--- a/_testenv/data/podman/Dockerfile
+++ b/_testenv/data/podman/Dockerfile
@@ -17,6 +17,7 @@
                autoconf \
                automake \
                bison \
+               bridge-utils \
                build-essential \
                ca-certificates \
                ccache \
diff --git a/_testenv/data/scripts/add_remove_testenv0_bridge.sh 
b/_testenv/data/scripts/add_remove_testenv0_bridge.sh
new file mode 100755
index 0000000..cb1b6a3
--- /dev/null
+++ b/_testenv/data/scripts/add_remove_testenv0_bridge.sh
@@ -0,0 +1,41 @@
+#!/bin/sh -e
+# Call this as or from within a clean= script to add and remove a testenv0
+# bridge device, which can be used to talk to a SUT running in QEMU.
+# Set env var EXTRA_IPS to add additional IP addresses to the device.
+DEV="testenv0"
+IP4="172.18.3.201/24"
+IP6="fd02:db8:3::201/128"
+set -x
+
+add_bridge() {
+       local ip
+
+       sudo brctl addbr "$DEV"
+       sudo ip link set "$DEV" up
+
+       for ip in $IP4 $IP6 $EXTRA_IPS; do
+               sudo ip addr add "$ip" dev "$DEV"
+       done
+}
+
+del_bridge() {
+       if ip link ls dev "$DEV" >/dev/null 2>&1; then
+               sudo ip link set "$DEV" down
+               sudo brctl delbr "$DEV"
+       fi
+}
+
+case "$TESTENV_CLEAN_REASON" in
+       prepare)
+               del_bridge
+               add_bridge
+               ;;
+       crashed|finished)
+               del_bridge
+               ;;
+       *)
+               set +x
+               echo "ERROR: unexpected TESTENV_CLEAN_REASON: 
$TESTENV_CLEAN_REASON"
+               exit 1
+               ;;
+esac
diff --git a/_testenv/testenv/requirements.py b/_testenv/testenv/requirements.py
index d65e436..7c39a7c 100644
--- a/_testenv/testenv/requirements.py
+++ b/_testenv/testenv/requirements.py
@@ -24,6 +24,7 @@
         programs += [
             "autoconf",
             "automake",
+            "brctl",
             "ccache",
             "dumpcap",
             "g++",
diff --git a/ggsn_tests/open5gs/testenv.sh b/ggsn_tests/open5gs/testenv.sh
index 9cc1c70..e06d771 100755
--- a/ggsn_tests/open5gs/testenv.sh
+++ b/ggsn_tests/open5gs/testenv.sh
@@ -1,5 +1,4 @@
 #!/bin/sh -ex
-DEV=ggsn_dummy

 check_usage() {
        if [ -z "$TESTENV_CLEAN_REASON" ]; then
@@ -65,34 +64,21 @@
        del_tun "ogstun46"
 }

-add_dummy_netdev() {
-       # Add a network device reachable through the GTP tunnel that can answer 
ICMP
-       # pings (for e.g. TC_pdp4_act_deact_gtpu_access)
-       sudo ip link add "$DEV" type dummy
-       sudo ip addr add "172.18.3.201" dev "$DEV"
-       sudo ip addr add "fd02:db8:3::201" dev "$DEV"
-       sudo ip link set "$DEV" up
-}
-
-del_dummy_netdev() {
-       if ip link ls dev "$DEV" >/dev/null 2>&1; then
-               sudo ip link del "$DEV"
-       fi
-}
-
 check_usage

+# Add a bridge reachable through the GTP tunnel that can answer ICMP
+# pings (for e.g. TC_pdp4_act_deact_gtpu_access). The bridge is also used to
+# connect the SUT when it runs in QEMU.
+add_remove_testenv0_bridge.sh
+
 case "$TESTENV_CLEAN_REASON" in
        prepare)
                setcap_open5gs_upfd
                adjust_ttcn3_config
-               del_dummy_netdev
                del_tun_all
-               add_dummy_netdev
                add_tun_all
                ;;
        crashed|finished)
-               del_dummy_netdev
                del_tun_all
                ;;
        *)
diff --git a/ggsn_tests/osmo-ggsn/testenv.sh b/ggsn_tests/osmo-ggsn/testenv.sh
index d797d44..0275ad2 100755
--- a/ggsn_tests/osmo-ggsn/testenv.sh
+++ b/ggsn_tests/osmo-ggsn/testenv.sh
@@ -1,6 +1,5 @@
 #!/bin/sh -ex
 CONFIG="$1"  # all, v4_only, etc.
-DEV=ggsn_dummy

 check_usage() {
        local valid="all|v4_only|v6_only|v4v6_only"
@@ -41,21 +40,6 @@
        sudo setcap CAP_NET_ADMIN=+eip $(which osmo-ggsn)
 }

-add_dummy_netdev() {
-       # Add a network device reachable through the GTP tunnel that can answer 
ICMP
-       # pings (for e.g. TC_pdp4_act_deact_gtpu_access)
-       sudo ip link add "$DEV" type dummy
-       sudo ip addr add "172.18.3.201" dev "$DEV"
-       sudo ip addr add "fd02:db8:3::201" dev "$DEV"
-       sudo ip link set "$DEV" up
-}
-
-del_dummy_netdev() {
-       if ip link ls dev "$DEV" >/dev/null 2>&1; then
-               sudo ip link del "$DEV"
-       fi
-}
-
 rename_junit_xml_classname() {
        if [ "$CONFIG" != "all" ]; then
                ( cd ../testsuite
@@ -65,16 +49,18 @@

 check_usage

+# Add a bridge reachable through the GTP tunnel that can answer ICMP
+# pings (for e.g. TC_pdp4_act_deact_gtpu_access). The bridge is also used to
+# connect the SUT when it runs in QEMU.
+add_remove_testenv0_bridge.sh
+
 case "$TESTENV_CLEAN_REASON" in
        prepare)
                adjust_osmo_ggsn_config
                adjust_ttcn3_config
                setcap_osmo_ggsn
-               del_dummy_netdev
-               add_dummy_netdev
                ;;
        crashed|finished)
-               del_dummy_netdev
                rename_junit_xml_classname
                ;;
        *)

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38340?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I102d5b9ed0b3cafc263ad489ed4d4652f5e6dac8
Gerrit-Change-Number: 38340
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>

Reply via email to