From 1b81e6ef66cbce15ba1b05904732f92251d531cd Mon Sep 17 00:00:00 2001 From: Tetsuya Murakami Date: Wed, 6 Nov 2019 11:05:51 -0800 Subject: srv6-mobile Type: feature Plug-in for IPv6 Segment Routing Mobile This funcion was developed by Signed-off-by: Satoru Matsuchima Signed-off-by: Filip Varga Signed-off-by: Tetsuya Murakami Signed-off-by: Tetsuya Murakami Change-Id: Ie995adc73d8f8d444339aab71619c3599e69f12d Signed-off-by: Tetsuya Murakami --- src/plugins/srv6-mobile/extra/Dockerfile.j2 | 48 + .../srv6-mobile/extra/Dockerfile.j2.release | 37 + src/plugins/srv6-mobile/extra/README.md | 173 ++ src/plugins/srv6-mobile/extra/requirements.txt | 3 + src/plugins/srv6-mobile/extra/runner.py | 2046 ++++++++++++++++++++ src/plugins/srv6-mobile/extra/startup.conf.j2 | 14 + src/plugins/srv6-mobile/extra/topo-init.png | 0 src/plugins/srv6-mobile/extra/topo-test_gtp4d.png | 0 src/plugins/srv6-mobile/extra/topo-test_gtp6.png | 0 src/plugins/srv6-mobile/extra/topo-test_gtp6d.png | 0 .../srv6-mobile/extra/topo-test_gtp6ip6.png | 0 11 files changed, 2321 insertions(+) create mode 100644 src/plugins/srv6-mobile/extra/Dockerfile.j2 create mode 100644 src/plugins/srv6-mobile/extra/Dockerfile.j2.release create mode 100644 src/plugins/srv6-mobile/extra/README.md create mode 100644 src/plugins/srv6-mobile/extra/requirements.txt create mode 100755 src/plugins/srv6-mobile/extra/runner.py create mode 100644 src/plugins/srv6-mobile/extra/startup.conf.j2 create mode 100644 src/plugins/srv6-mobile/extra/topo-init.png create mode 100644 src/plugins/srv6-mobile/extra/topo-test_gtp4d.png create mode 100644 src/plugins/srv6-mobile/extra/topo-test_gtp6.png create mode 100644 src/plugins/srv6-mobile/extra/topo-test_gtp6d.png create mode 100644 src/plugins/srv6-mobile/extra/topo-test_gtp6ip6.png (limited to 'src/plugins/srv6-mobile/extra') diff --git a/src/plugins/srv6-mobile/extra/Dockerfile.j2 b/src/plugins/srv6-mobile/extra/Dockerfile.j2 new file mode 100644 index 00000000000..ac58fa36b64 --- /dev/null +++ b/src/plugins/srv6-mobile/extra/Dockerfile.j2 @@ -0,0 +1,48 @@ + +FROM ubuntu:18.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + inetutils-traceroute \ + ca-certificates \ + build-essential \ + git gdb sudo \ + iputils-ping \ + net-tools \ + iproute2 \ + tcpdump \ + python3-cffi \ + asciidoc \ + xmlto \ + netcat; \ + rm -rf /var/lib/apt/lists/*; \ + mv /usr/sbin/tcpdump /usr/bin/tcpdump + +RUN set -eux; \ + mkdir -p {{vpp_path}} + +COPY . / {{vpp_path}}/ + +WORKDIR {{vpp_path}} + +RUN set -eux; \ + make wipe; \ + export UNATTENDED=y; \ + echo "y" | make install-dep; \ + rm -rf /var/lib/apt/lists/* ; \ + make build; \ + make pkg-deb; \ + rm -rf .ccache; \ + find . -type f -name '*.o' -delete ; \ + cd {{vpp_path}}/build-root; \ + rm vpp-api-python_*.deb; \ + tar czf vpp-package.tgz *.deb; \ + mv vpp-package.tgz {{vpp_path}}/; \ + dpkg -i *.deb ; \ + cp {{vpp_path}}/startup.conf /etc/startup.conf + +WORKDIR / + +CMD vpp -c /etc/startup.conf + diff --git a/src/plugins/srv6-mobile/extra/Dockerfile.j2.release b/src/plugins/srv6-mobile/extra/Dockerfile.j2.release new file mode 100644 index 00000000000..851aef66197 --- /dev/null +++ b/src/plugins/srv6-mobile/extra/Dockerfile.j2.release @@ -0,0 +1,37 @@ + +FROM ubuntu:18.04 + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + inetutils-traceroute \ + ca-certificates \ + libmbedcrypto1 \ + libmbedtls10 \ + libmbedx509-0 \ + libnuma1 \ + sudo \ + iputils-ping \ + net-tools \ + iproute2 \ + tcpdump \ + python3-cffi \ + netcat; \ + rm -rf /var/lib/apt/lists/*; \ + mv /usr/sbin/tcpdump /usr/bin/tcpdump + +WORKDIR /tmp + +COPY startup.conf /etc/startup.conf + +COPY vpp-package.tgz /tmp + +RUN set -eux; \ + tar xzf vpp-package.tgz; \ + dpkg -i *.deb ; \ + rm -rf *.deb + +WORKDIR / + +CMD vpp -c /etc/startup.conf + diff --git a/src/plugins/srv6-mobile/extra/README.md b/src/plugins/srv6-mobile/extra/README.md new file mode 100644 index 00000000000..3b24dea6fd6 --- /dev/null +++ b/src/plugins/srv6-mobile/extra/README.md @@ -0,0 +1,173 @@ +# What's `runner.py` doing? + +## Common configurations + +### VPP1 +``` +create host-interface name eth1 +set int ip addr host-eth1 A1::1/120 +set int state host-eth1 up +ip route add ::/0 via host-eth1 A1::2 +``` + + +### VPP2 + +``` +create host-interface name eth1 +set int ip addr host-eth1 A1::2/120 +create host-interface name eth2 +set int ip addr host-eth2 A2::1/120 +set int state host-eth1 up +set int state host-eth2 up +ip route add ::/0 via host-eth2 A2::2 +``` + + +### VPP3 + +``` +create host-interface name eth1 +set int ip addr host-eth1 A2::2/120 +create host-interface name eth2 +set int ip addr host-eth2 A3::1/120 +set int state host-eth1 up +set int state host-eth2 up +ip route add ::/0 via host-eth1 A2::1 +``` + +### VPP4 + +``` +create host-interface name eth1 +set int ip addr host-eth1 A3::2/120 +set int state host-eth1 up +ip route add ::/0 via host-eth1 A3::1 +``` + + +## Drop-in for GTP-U over IPv4 + +What's happened when you run `test tmap`: + + $ ./runner.py test tmap + + +Setting up a virtual interface of packet generator: + +#### VPP1 + +``` +create packet-generator interface pg0 +set int mac address pg0 aa:bb:cc:dd:ee:01 +set int ip addr pg0 172.16.0.1/30 +set ip arp pg0 172.16.0.2/30 aa:bb:cc:dd:ee:02 +``` + +#### VPP4 + +``` +create packet-generator interface pg0 +set int mac address pg0 aa:bb:cc:dd:ee:11 +set int ip addr pg0 1.0.0.2/30 +set ip arp pg0 1.0.0.1 aa:bb:cc:dd:ee:22 +``` + +SRv6 and IP routing settings: + +#### VPP1 + +``` +sr policy add bsid D1:: next D2:: next D3:: gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64 +sr steer l3 172.20.0.1/32 via bsid D1:: + +``` + +#### VPP2 + +``` +sr localsid address D2:: behavior end +ip route add D3::/128 via host-eth2 A2::2 +``` + +#### VPP3 + +``` +sr localsid address D3:: behavior end +ip route add D4::/32 via host-eth2 A3::2 +``` + +#### VPP4 + +``` +sr localsid prefix D4::/32 behavior end.m.gtp4.e v4src_position 64 +ip route add 172.20.0.1/32 via pg0 1.0.0.1 +``` + + + + +## Packet generator and testing + + Example how to build custom SRv6 packet in scapy and ipaddress pkgs + + s = '\x11' * 4 + IPv4Address(u"192.168.192.10").packed + '\x11' * 8 + ip6 = IPv6Address(s) + IPv6(dst=ip6, src=ip6) + + +## end.m.gtp4.e + + First set behavior so our localsid node is called with the packet + matching C1::1 in fib table + sr localsid address C1::1 behavior end.m.gtp4.ess + + show sr localsids behaviors + show sr localsid + + We should send a well formated packet to C::1 destination address + that contains the correct spec as for end.m.gtp4.e with encapsulated + ipv4 src and dst address and teid with port for the conversion to + GTPU IPv4 packet + + +## additional commands + + gdb - breakpoint + + break sr_policy_rewrite.c:1620 + + break src/plugins/srv6-end/node.c:84 + + TMAP + Linux: + + ip link add tmp1 type veth peer name tmp2 + ip link set dev tmp1 up + ip link set dev tmp2 up + ip addr add 172.20.0.2/24 dev tmp2 + + create host-interface name tmp1 + set int mac address host-tmp1 02:fe:98:c6:c8:7b + set interface ip address host-tmp1 172.20.0.1/24 + set interface state host-tmp1 up + + VPP + set sr encaps source addr C1:: + sr policy add bsid D1::999:2 next D2:: next D3:: gtp4_removal sr-prefix fc34:5678::/64 local-prefix C1::/64 + sr steer l3 172.21.0.0/24 via bsid d1::999:2 + + END + Linux + create host-interface name tmp1 + set int mac address host-tmp1 02:fe:98:c6:c8:7b + set interface ip address host-tmp1 A1::1/64 + set interface state host-tmp1 up + + VPP + sr localsid address 1111:1111:c0a8:c00a:1122:1111:1111:1111 behavior end.m.gtp4.e + + trace add af-packet-input 10 + + sr localsid address C3:: behavior end.m.gtp4.e + sr localsid address 2001:200:0:1ce1:3000:757f:0:2 behavior end.m.gtp4.e diff --git a/src/plugins/srv6-mobile/extra/requirements.txt b/src/plugins/srv6-mobile/extra/requirements.txt new file mode 100644 index 00000000000..2938cddeceb --- /dev/null +++ b/src/plugins/srv6-mobile/extra/requirements.txt @@ -0,0 +1,3 @@ +docker +jinja2 +scapy diff --git a/src/plugins/srv6-mobile/extra/runner.py b/src/plugins/srv6-mobile/extra/runner.py new file mode 100755 index 00000000000..710252d5ce1 --- /dev/null +++ b/src/plugins/srv6-mobile/extra/runner.py @@ -0,0 +1,2046 @@ +#!/usr/bin/env python3 + +from os.path import dirname, realpath, split,\ + join, isdir, exists +from os import remove, system, mkdir +from logging import getLogger, basicConfig,\ + DEBUG, INFO, ERROR +from argparse import ArgumentParser +from atexit import register +from shutil import rmtree + +from jinja2 import Environment, FileSystemLoader + +from docker.errors import NotFound, APIError +from docker import from_env + +from scapy.contrib.gtp import * +from scapy.all import * + + +verbose_levels = { + 'error': ERROR, + 'debug': DEBUG, + 'info': INFO} + + +class ContainerStartupError(Exception): + pass + + +class Container(object): + + tmp = "/tmp" + cmd = "vppctl -s 0:5002" + cmd_bash = "/bin/bash" + + def __init__(self, ref, name): + self._name = name + self._ref = ref + + @property + def name(self): + return self._name + + @property + def temp(self): + return join(self.tmp, self.name) + + @property + def pg_input_file(self): + return join(self.temp, "pgi.pcap") + + @property + def pg_output_file(self): + return join(self.temp, "pgo.pcap") + + @property + def pg_input_file_in(self): + return join("/mnt", "pgi.pcap") + + @property + def pg_output_file_in(self): + return join("/mnt", "pgo.pcap") + + def disconnect_all(self): + status = False + for net in self._ref.client.networks.list(): + try: + net.disconnect(self._ref) + except APIError: + continue + status = True + return status + + @classmethod + def new(cls, client, image, name): + + temp = join(cls.tmp, name) + if isdir(temp): + rmtree(temp) + mkdir(temp) + + ref = client.containers.run( + detach=True, + remove=True, + auto_remove=True, + image=image, + name=name, + privileged=True, + volumes={ + temp: { + 'bind': '/mnt', + 'mode': 'rw'}}) + + obj = cls.get(client, name) + if not obj: + raise ContainerStartupError() + + obj.disconnect_all() + return obj + + @classmethod + def get(cls, client, name): + try: + ref = client.containers.get(name) + except NotFound: + pass + else: + return cls(ref, name) + + def rem(self): + self._ref.kill() + + def vppctl(self): + system("docker exec -it {} {}".format(self.name, self.cmd)) + + def bash(self): + system("docker exec -it {} {}".format(self.name, self.cmd_bash)) + + def vppctl_exec(self, cmd): + ec, resp = self._ref.exec_run(cmd="{} {}".format(self.cmd, cmd)) + assert(ec == 0) + return resp + + def setup_host_interface(self, name, ip): + self.vppctl_exec("create host-interface name {}".format(name)) + self.vppctl_exec("set int ip addr host-{} {}".format(name, ip)) + self.vppctl_exec("set int state host-{} up".format(name)) + + def pg_create_interface(self, local_ip, remote_ip, local_mac, remote_mac): + # remote_ip can't have subnet mask + + time.sleep(2) + self.vppctl_exec("create packet-generator interface pg0") + self.vppctl_exec("set int mac address pg0 {}".format(local_mac)) + self.vppctl_exec("set int ip addr pg0 {}".format(local_ip)) + self.vppctl_exec( + "set ip6 neighbor pg0 {} {}".format(remote_ip, remote_mac)) + self.vppctl_exec("set int state pg0 up") + + def pg_create_interface4(self, local_ip, remote_ip, local_mac, remote_mac): + # remote_ip can't have subnet mask + + time.sleep(2) + self.vppctl_exec("create packet-generator interface pg0") + self.vppctl_exec("set int mac address pg0 {}".format(local_mac)) + self.vppctl_exec("set int ip addr pg0 {}".format(local_ip)) + self.vppctl_exec("set ip arp pg0 {} {}".format(remote_ip, remote_mac)) + self.vppctl_exec("set int state pg0 up") + + def pg_create_interface6(self, local_ip, remote_ip, local_mac, remote_mac): + # remote_ip can't have subnet mask + + time.sleep(2) + self.vppctl_exec("create packet-generator interface pg0") + self.vppctl_exec("set int mac address pg0 {}".format(local_mac)) + self.vppctl_exec("set int ip6 addr pg0 {}".format(local_ip)) + self.vppctl_exec("set ip6 arp pg0 {} {}".format(remote_ip, remote_mac)) + self.vppctl_exec("set int state pg0 up") + + def pg_enable(self): + # start packet generator + self.vppctl_exec("packet-generator enable") + + def pg_create_stream(self, stream): + wrpcap(self.pg_input_file, stream) + self.vppctl_exec( + "packet-generator new name pg-stream " + "node ethernet-input pcap {}".format( + self.pg_input_file_in)) + + def pg_start_capture(self): + if exists(self.pg_output_file): + remove(self.pg_output_file) + self.vppctl_exec( + "packet-generator capture pg0 pcap {}".format( + self.pg_output_file_in)) + + def pg_read_packets(self): + return rdpcap(self.pg_output_file) + + def set_ipv6_route(self, out_if_name, next_hop_ip, subnet): + self.vppctl_exec( + "ip route add {} via host-{} {}".format( + subnet, out_if_name, next_hop_ip)) + + def set_ip_pgroute(self, out_if_name, next_hop_ip, subnet): + self.vppctl_exec("ip route add {} via {} {}".format( + subnet, out_if_name, next_hop_ip)) + + def set_ipv6_pgroute(self, out_if_name, next_hop_ip, subnet): + self.vppctl_exec("ip route add {} via {} {}".format( + subnet, out_if_name, next_hop_ip)) + + def set_ipv6_default_route(self, out_if_name, next_hop_ip): + self.vppctl_exec( + "ip route add ::/0 via host-{} {}".format( + out_if_name, next_hop_ip)) + + def enable_trace(self, count): + self.vppctl_exec("trace add af-packet-input {}".format(count)) + + +class Containers(object): + + def __init__(self, client, image): + self.client = client + self.image = image + + def tmp_render(self, path, template, kwargs): + + with open(path, "w") as fo: + fo.write(template.render(**kwargs)) + + register(lambda: remove(path)) + + def build(self, path, vpp_path): + env = Environment(loader=FileSystemLoader(path), + trim_blocks=True) + + self.tmp_render(join(vpp_path, "Dockerfile"), + env.get_template("Dockerfile.j2"), + {'vpp_path': vpp_path}) + + self.tmp_render(join(vpp_path, "startup.conf"), + env.get_template("startup.conf.j2"), + {'vpp_path': vpp_path}) + + ref, _ = self.client.images.build(path=vpp_path, + tag=self.image, rm=True) + return ref + + def release(self, path, vpp_path): + env = Environment(loader=FileSystemLoader(path), + trim_blocks=True) + + self.tmp_render(join(vpp_path, "Dockerfile"), + env.get_template("Dockerfile.j2.release"), + {'vpp_path': vpp_path}) + + self.tmp_render(join(vpp_path, "startup.conf"), + env.get_template("startup.conf.j2"), + {'vpp_path': vpp_path}) + + ref, _ = self.client.images.build(path=vpp_path, + tag="srv6m-release-image", rm=True) + return ref + + def new(self, name): + return Container.new(self.client, self.image, name) + + def get(self, name): + return Container.get(self.client, name) + + def vppctl(self, name, command=None): + container = self.get(name) + if not command: + container.vppctl() + else: + print(container.vppctl_exec(command).decode()) + + def bash(self, name): + container = self.get(name) + container.bash() + + +class Network(object): + + def __init__(self, ref, name): + self._name = name + self._ref = ref + + @property + def name(self): + return self._name + + @classmethod + def new(cls, client, name): + ref = client.networks.create(name, driver="bridge", + check_duplicate=True) + return cls(ref, name) + + @classmethod + def get(cls, client, name): + try: + ref = client.networks.get(name) + except NotFound: + pass + else: + return cls(ref, name) + + def rem(self): + self._ref.remove() + + def connect(self, c): + self._ref.connect(c.name) + + +class Networks(object): + + def __init__(self, client): + self.client = client + + def new(self, name): + return Network.new(self.client, name) + + def get(self, name): + return Network.get(self.client, name) + + +class Program(object): + + image = "srv6m-image" + + name_prefix = "hck" + + # TODO: add description to these instances + # for exmaple what the vpp is supposed to be + # in our topoloty overview + + instance_names = ["vpp-1", + "vpp-2", + "vpp-3", + "vpp-4"] + + network_names = ["net-1", + "net-2", + "net-3"] + + def __init__(self, image=None, prefix=None): + self.path = dirname(realpath(__file__)) + + if image: + self.image = image + if prefix is not None: + self.name_prefix = prefix + + client = from_env() + self.containers = Containers(client, self.image) + self.networks = Networks(client) + + self.logger = getLogger(__name__) + + @property + def vpp_path(self): + return self.path.rsplit("/", 4)[0] + + def get_name(self, name): + if not self.name_prefix: + return name + return "{}-{}".format(self.name_prefix, name) + + def stop_containers(self): + + for name in self.instance_names: + instance = self.containers.get(self.get_name(name)) + if instance: + instance.rem() + + for name in self.network_names: + network = self.networks.get(self.get_name(name)) + if network: + network.rem() + + def start_containers(self): + + self.stop_containers() + + networks = list() + + for name in self.network_names: + networks.append(self.networks.new(self.get_name(name))) + + n1, n2, n3 = networks + + instances = list() + + for name in self.instance_names: + instances.append(self.containers.new(self.get_name(name))) + + c1, c2, c3, c4 = instances + + # setup packet generator interfaces + # c1.pg_create_interface(local_ip="C::1/120", remote_ip="C::2", + # local_mac="aa:bb:cc:dd:ee:01", remote_mac="aa:bb:cc:dd:ee:02") + + # setup network between instances + n1.connect(c1) + n1.connect(c2) + + n2.connect(c2) + n2.connect(c3) + + n3.connect(c3) + n3.connect(c4) + + # c1 & c2 link + c1.setup_host_interface("eth1", "A1::1/120") + c2.setup_host_interface("eth1", "A1::2/120") + + # c2 & c3 link + c2.setup_host_interface("eth2", "A2::1/120") + c3.setup_host_interface("eth1", "A2::2/120") + + # c3 & c4 link + c3.setup_host_interface("eth2", "A3::1/120") + c4.setup_host_interface("eth1", "A3::2/120") + + # c1 > c2 default route + + c1.set_ipv6_default_route("eth1", "A1::2") + # c2 > c3 default route + c2.set_ipv6_default_route("eth2", "A2::2") + # c3 > c2 default route + c3.set_ipv6_default_route("eth1", "A2::1") + # c4 > c3 default route + c4.set_ipv6_default_route("eth1", "A3::1") + + # c3 > c4 static route for address B::1/128 + c3.set_ipv6_route("eth2", "A3::2", "B::1/128") + c3.set_ipv6_route("eth2", "A3::2", "B::2/128") + + def test_ping(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="B::2") / ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_srv6(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 C::1/120 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Sleeping") + time.sleep(30) + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr D1::") + c1.vppctl_exec( + "sr policy add bsid D1::999:1 next D2:: next D3:: next D4::") + c1.vppctl_exec("sr steer l3 B::/120 via bsid D1::999:1") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid address D4:: behavior end.dx6 pg0 B::2") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/128") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="B::2") / ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c2.enable_trace(10) + c3.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_tmap(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec( + "sr policy add bsid D1:: next D2:: next D3:: " + "gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64") + c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D1::") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IP(src="172.99.0.1", dst="172.99.0.2") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_tmap_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec( + "sr policy add bsid D1:: next D2:: next D3:: " + "gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64") + c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D1::") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(R=1, QFI=3) / + IP(src="172.99.0.1", dst="172.99.0.2") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_tmap_ipv6(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec( + "sr policy add bsid D1:: next D2:: next D3:: " + "gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64") + c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D1::") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_tmap_ipv6_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec( + "sr policy add bsid D1:: next D2:: next D3:: " + "gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64") + c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D1::") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(R=1, QFI=3) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp4(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + c1.vppctl_exec( + "sr localsid prefix 172.20.0.1/32 " + "behavior end.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IP(src="172.99.0.1", dst="172.99.0.2") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp4_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + c1.vppctl_exec( + "sr localsid prefix ::ffff:ac14:0001/128 " + "behavior end.m.gtp4.d D4::/32 v6src_prefix C1::/64 " + "nhtype ipv4") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(type=1, R=1, QFI=3) / + IP(src="172.99.0.1", dst="172.99.0.2") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp4_echo(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + c1.vppctl_exec( + "sr localsid prefix 172.20.0.1/32 " + "behavior end.m.gtp4.d D4::/32 v6src_prefix C1::/64 " + "nhtype ipv4") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="echo_request", teid=200)) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp4_ipv6(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + c1.vppctl_exec( + "sr localsid prefix ::ffff:ac14:0001/128 " + "behavior end.m.gtp4.d D4::/32 v6src_prefix C1::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp4_ipv6_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface4( + local_ip="172.16.0.1/30", + remote_ip="172.16.0.2/30", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + c1.vppctl_exec( + "sr localsid prefix ::ffff:ac14:0001/128 " + "behavior end.m.gtp4.d D4::/32 v6src_prefix C1::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec( + "sr localsid prefix D4::/32 " + "behavior end.m.gtp4.e v4src_position 64") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.20.0.1/32") + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IP(src="172.20.0.2", dst="172.20.0.1") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(R=1, QFI=3) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_drop_in(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d.di D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.m.gtp6.e") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "B::2", "D::2/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IP(src="172.99.0.1", dst="172.99.0.2") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_drop_in_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d.di D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.m.gtp6.e") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "B::2", "D::2/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(type=1, R=1, QFI=3) / + IP(src="172.99.0.1", dst="172.99.0.2") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_drop_in_echo(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d.di D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.m.gtp6.e") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "B::2", "D::2/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="echo_request", teid=200)) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_drop_in_ipv6(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d.di D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.m.gtp6.e") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "B::2", "D::2/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_drop_in_ipv6_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d.di D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.m.gtp6.e") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "B::2", "D::2/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(R=1, QFI=3) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.dt4 2") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.200.0.1/32") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IP(src="172.100.0.1", dst="172.200.0.1") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface4( + local_ip="1.0.0.2/30", + remote_ip="1.0.0.1", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.dt4 2") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ip_pgroute("pg0", "1.0.0.1", "172.200.0.1/32") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(R=1, QFI=3) / + IP(src="172.100.0.1", dst="172.200.0.1") / + ICMP()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_ipv6(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.dt6 2") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ipv6_pgroute("pg0", "B::2", "2002::1/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def test_gtp6_ipv6_5g(self): + # TESTS: + # trace add af-packet-input 10 + # pg interface on c1 172.20.0.1 + # pg interface on c4 B::1/120 + + self.start_containers() + + print("Deleting the old containers...") + time.sleep(30) + print("Starting the new containers...") + + c1 = self.containers.get(self.get_name(self.instance_names[0])) + c2 = self.containers.get(self.get_name(self.instance_names[1])) + c3 = self.containers.get(self.get_name(self.instance_names[2])) + c4 = self.containers.get(self.get_name(self.instance_names[-1])) + + c1.pg_create_interface( + local_ip="C::1/120", + remote_ip="C::2", + local_mac="aa:bb:cc:dd:ee:01", + remote_mac="aa:bb:cc:dd:ee:02") + c4.pg_create_interface( + local_ip="B::1/120", + remote_ip="B::2", + local_mac="aa:bb:cc:dd:ee:11", + remote_mac="aa:bb:cc:dd:ee:22") + + c1.vppctl_exec("set sr encaps source addr A1::1") + c1.vppctl_exec("sr policy add bsid D4:: next D2:: next D3::") + + c1.vppctl_exec( + "sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64") + + c2.vppctl_exec("sr localsid address D2:: behavior end") + + c3.vppctl_exec("sr localsid address D3:: behavior end") + + c4.vppctl_exec("sr localsid prefix D4::/64 behavior end.dt6 2") + + c2.set_ipv6_route("eth2", "A2::2", "D3::/128") + c2.set_ipv6_route("eth1", "A1::1", "C::/120") + c3.set_ipv6_route("eth2", "A3::2", "D4::/32") + c3.set_ipv6_route("eth1", "A2::1", "C::/120") + c4.set_ipv6_pgroute("pg0", "B::2", "2002::1/128") + + print("Waiting...") + time.sleep(30) + + p = (Ether(src="aa:bb:cc:dd:ee:02", dst="aa:bb:cc:dd:ee:01") / + IPv6(src="C::2", dst="D::2") / + UDP(sport=2152, dport=2152) / + GTP_U_Header(gtp_type="g_pdu", teid=200) / + GTPPDUSessionContainer(R=1, QFI=3) / + IPv6(src="2001::1", dst="2002::1") / + ICMPv6EchoRequest()) + + print("Sending packet on {}:".format(c1.name)) + p.show2() + + c1.enable_trace(10) + c4.enable_trace(10) + + c4.pg_start_capture() + + c1.pg_create_stream(p) + c1.pg_enable() + + # timeout (sleep) if needed + print("Sleeping") + time.sleep(5) + + print("Receiving packet on {}:".format(c4.name)) + for p in c4.pg_read_packets(): + p.show2() + + def status_containers(self): + + print("Instances:") + + for i, name in enumerate(self.instance_names): + name = self.get_name(name) + print("\t[{}] {} - {}".format( + i, name, + "running" if self.containers.get(name) else "missing")) + + print("Networks:") + + for i, name in enumerate(self.network_names): + name = self.get_name(name) + print("\t[{}] {} - {}".format( + i, name, + "running" if self.networks.get(name) else "missing")) + + def build_image(self): + # TODO: optimize build process for speed and image size + print("VPP Path (build): {}".format(self.vpp_path)) + self.containers.build(self.path, self.vpp_path) + + def release_image(self): + print("VPP Path (release): {}".format(self.vpp_path)) + instance = self.containers.new("release-build") + + system( + "docker cp release-build:{}/vpp-package.tgz {}/".format( + self.vpp_path, self.vpp_path)) + + instance.rem() + + self.containers.release(self.path, self.vpp_path) + + system("rm -rf {}/vpp-package.tgz".format(self.vpp_path)) + + def vppctl(self, index, command=None): + if index >= len(self.instance_names): + return + name = self.get_name(self.instance_names[index]) + self.logger.error("connecting to: {}".format(name)) + self.containers.vppctl(name, command) + + def bash(self, index): + if index >= len(self.instance_names): + return + name = self.get_name(self.instance_names[index]) + self.logger.error("connecting to: {}".format(name)) + self.containers.bash(name) + + +def get_args(): + parser = ArgumentParser() + + parser.add_argument("--verbose", choices=['error', 'debug', 'info']) + + parser.add_argument('--image', choices=['debug', 'release']) + + subparsers = parser.add_subparsers() + + p1 = subparsers.add_parser( + "infra", help="Infrastructure related commands.") + + p1.add_argument( + "op", + choices=[ + 'stop', + 'start', + 'status', + 'restart', + 'build', + 'release']) + + p1.add_argument("--prefix") + p1.add_argument("--image") + + p2 = subparsers.add_parser("cmd", help="Instance related commands.") + + p2.add_argument("op", choices=['vppctl', 'bash']) + + p2.add_argument( + "index", + type=int, + help="Container instance index. (./runner.py infra status)") + + p2.add_argument( + "--command", help="Only vppctl supports this optional argument.") + + p3 = subparsers.add_parser("test", help="Test related commands.") + + p3.add_argument( + "op", + choices=[ + "ping", + "srv6", + "tmap", + "tmap_5g", + "tmap_ipv6", + "tmap_ipv6_5g", + "gtp4", + "gtp4_5g", + "gtp4_echo", + "gtp4_ipv6", + "gtp4_ipv6_5g", + "gtp6_drop_in", + "gtp6_drop_in_5g", + "gtp6_drop_in_echo", + "gtp6_drop_in_ipv6", + "gtp6_drop_in_ipv6_5g", + "gtp6", + "gtp6_5g", + "gtp6_ipv6", + "gtp6_ipv6_5g"]) + + args = parser.parse_args() + if not hasattr(args, "op") or not args.op: + parser.print_help(sys.stderr) + sys.exit(1) + + return vars(args) + + +def main(op=None, prefix=None, verbose=None, + image=None, index=None, command=None): + + if verbose: + basicConfig(level=verbose_levels[verbose]) + + if image == 'release': + image = "srv6m-release-image" + elif image == 'debug': + image = "srv6m-image" + + print("Verified image: {}".format(image)) + + program = Program(image, prefix) + + try: + if op == 'build': + program.build_image() + elif op == 'release': + program.release_image() + elif op == 'stop': + program.stop_containers() + elif op == 'start': + program.start_containers() + elif op == 'status': + program.status_containers() + elif op == 'vppctl': + program.vppctl(index, command) + elif op == 'bash': + program.bash(index) + elif op == 'ping': + program.test_ping() + elif op == 'srv6': + program.test_srv6() + elif op == 'tmap': + program.test_tmap() + elif op == 'tmap_5g': + program.test_tmap_5g() + elif op == 'tmap_ipv6': + program.test_tmap_ipv6() + elif op == 'tmap_ipv6_5g': + program.test_tmap_ipv6_5g() + elif op == 'gtp4': + program.test_gtp4() + elif op == 'gtp4_5g': + program.test_gtp4_5g() + elif op == 'gtp4_echo': + program.test_gtp4_echo() + elif op == 'gtp4_ipv6': + program.test_gtp4_ipv6() + elif op == 'gtp4_ipv6_5g': + program.test_gtp4_ipv6_5g() + elif op == 'gtp6_drop_in': + program.test_gtp6_drop_in() + elif op == 'gtp6_drop_in_5g': + program.test_gtp6_drop_in_5g() + elif op == 'gtp6_drop_in_echo': + program.test_gtp6_drop_in_echo() + elif op == 'gtp6_drop_in_ipv6': + program.test_gtp6_drop_in_ipv6() + elif op == 'gtp6_drop_in_ipv6_5g': + program.test_gtp6_drop_in_ipv6_5g() + elif op == 'gtp6': + program.test_gtp6() + elif op == 'gtp6_5g': + program.test_gtp6_5g() + elif op == 'gtp6_ipv6': + program.test_gtp6_ipv6() + elif op == 'gtp6_ipv6_5g': + program.test_gtp6_ipv6_5g() + + except Exception: + program.logger.exception("") + rc = 1 + else: + rc = 0 + + return rc + + +if __name__ == "__main__": + sys.exit(main(**get_args())) diff --git a/src/plugins/srv6-mobile/extra/startup.conf.j2 b/src/plugins/srv6-mobile/extra/startup.conf.j2 new file mode 100644 index 00000000000..5a4a2ef103d --- /dev/null +++ b/src/plugins/srv6-mobile/extra/startup.conf.j2 @@ -0,0 +1,14 @@ +unix { + nodaemon + cli-no-pager + cli-listen 0.0.0.0:5002 +} +plugins { + plugin dpdk_plugin.so { + disable + } +} +cpu { + workers 2 +} + diff --git a/src/plugins/srv6-mobile/extra/topo-init.png b/src/plugins/srv6-mobile/extra/topo-init.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/plugins/srv6-mobile/extra/topo-test_gtp4d.png b/src/plugins/srv6-mobile/extra/topo-test_gtp4d.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/plugins/srv6-mobile/extra/topo-test_gtp6.png b/src/plugins/srv6-mobile/extra/topo-test_gtp6.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/plugins/srv6-mobile/extra/topo-test_gtp6d.png b/src/plugins/srv6-mobile/extra/topo-test_gtp6d.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/plugins/srv6-mobile/extra/topo-test_gtp6ip6.png b/src/plugins/srv6-mobile/extra/topo-test_gtp6ip6.png new file mode 100644 index 00000000000..e69de29bb2d -- cgit 1.2.3-korg