aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/srv6-mobile/extra
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-26 19:02:15 +0200
committerOle Tr�an <otroan@employees.org>2022-05-10 18:52:08 +0000
commitd9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch)
tree4f786cfd8ebc2443cb11e11b74c8657204068898 /src/plugins/srv6-mobile/extra
parentf90348bcb4afd0af2611cefc43b17ef3042b511c (diff)
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/plugins/srv6-mobile/extra')
-rwxr-xr-xsrc/plugins/srv6-mobile/extra/runner.py824
1 files changed, 462 insertions, 362 deletions
diff --git a/src/plugins/srv6-mobile/extra/runner.py b/src/plugins/srv6-mobile/extra/runner.py
index b18fdc32766..eee89d7d41a 100755
--- a/src/plugins/srv6-mobile/extra/runner.py
+++ b/src/plugins/srv6-mobile/extra/runner.py
@@ -1,10 +1,8 @@
#!/usr/bin/env python3
-from os.path import dirname, realpath, split,\
- join, isdir, exists
+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 logging import getLogger, basicConfig, DEBUG, INFO, ERROR
from argparse import ArgumentParser
from atexit import register
from shutil import rmtree
@@ -18,10 +16,7 @@ from scapy.contrib.gtp import *
from scapy.all import *
-verbose_levels = {
- 'error': ERROR,
- 'debug': DEBUG,
- 'info': INFO}
+verbose_levels = {"error": ERROR, "debug": DEBUG, "info": INFO}
class ContainerStartupError(Exception):
@@ -87,10 +82,8 @@ class Container(object):
image=image,
name=name,
privileged=True,
- volumes={
- temp: {
- 'bind': '/mnt',
- 'mode': 'rw'}})
+ volumes={temp: {"bind": "/mnt", "mode": "rw"}},
+ )
obj = cls.get(client, name)
if not obj:
@@ -119,7 +112,7 @@ class Container(object):
def vppctl_exec(self, cmd):
ec, resp = self._ref.exec_run(cmd="{} {}".format(self.cmd, cmd))
- assert(ec == 0)
+ assert ec == 0
return resp
def setup_host_interface(self, name, ip):
@@ -134,8 +127,7 @@ class Container(object):
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 neighbor pg0 {} {}".format(remote_ip, remote_mac))
+ self.vppctl_exec("set ip 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):
@@ -158,24 +150,32 @@ class Container(object):
self.vppctl_exec("set ip neighbor pg0 {} {}".format(remote_ip, remote_mac))
self.vppctl_exec("set int state pg0 up")
- def pg_create_interface4_name(self, ifname, local_ip, remote_ip, local_mac, remote_mac):
+ def pg_create_interface4_name(
+ self, ifname, 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 {}".format(ifname))
self.vppctl_exec("set int mac address {} {}".format(ifname, local_mac))
self.vppctl_exec("set int ip addr {} {}".format(ifname, local_ip))
- self.vppctl_exec("set ip neighbor {} {} {}".format(ifname, remote_ip, remote_mac))
+ self.vppctl_exec(
+ "set ip neighbor {} {} {}".format(ifname, remote_ip, remote_mac)
+ )
self.vppctl_exec("set int state {} up".format(ifname))
- def pg_create_interface6_name(self, ifname, local_ip, remote_ip, local_mac, remote_mac):
+ def pg_create_interface6_name(
+ self, ifname, 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 {}".format(ifname))
self.vppctl_exec("set int mac address {} {}".format(ifname, local_mac))
self.vppctl_exec("set int ip addr {} {}".format(ifname, local_ip))
- self.vppctl_exec("set ip neighbor {} {} {}".format(ifname, remote_ip, remote_mac))
+ self.vppctl_exec(
+ "set ip neighbor {} {} {}".format(ifname, remote_ip, remote_mac)
+ )
self.vppctl_exec("set int state {} up".format(ifname))
def pg_enable(self):
@@ -186,55 +186,56 @@ class Container(object):
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))
+ "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))
+ "packet-generator capture pg0 pcap {}".format(self.pg_output_file_in)
+ )
def pg_start_capture_name(self, ifname):
if exists(self.pg_output_file):
remove(self.pg_output_file)
self.vppctl_exec(
- "packet-generator capture {} pcap {}".format(
- ifname, self.pg_output_file_in))
+ "packet-generator capture {} pcap {}".format(ifname, 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))
+ "ip route add {} via host-{} {}".format(subnet, out_if_name, next_hop_ip)
+ )
def set_ipv6_route2(self, out_if_name, next_hop_ip, subnet):
self.vppctl_exec(
- "ip route add {} via {} {}".format(
- subnet, out_if_name, next_hop_ip))
+ "ip route add {} via {} {}".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))
+ 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))
+ 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))
+ "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
@@ -247,37 +248,45 @@ class Containers(object):
register(lambda: remove(path))
def build(self, path, vpp_path):
- env = Environment(loader=FileSystemLoader(path),
- autoescape=True,
- 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)
+ env = Environment(
+ loader=FileSystemLoader(path), autoescape=True, 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),
- autoescape=True,
- 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)
+ env = Environment(
+ loader=FileSystemLoader(path), autoescape=True, 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):
@@ -299,7 +308,6 @@ class Containers(object):
class Network(object):
-
def __init__(self, ref, name):
self._name = name
self._ref = ref
@@ -310,8 +318,7 @@ class Network(object):
@classmethod
def new(cls, client, name):
- ref = client.networks.create(name, driver="bridge",
- check_duplicate=True)
+ ref = client.networks.create(name, driver="bridge", check_duplicate=True)
return cls(ref, name)
@classmethod
@@ -331,7 +338,6 @@ class Network(object):
class Networks(object):
-
def __init__(self, client):
self.client = client
@@ -352,14 +358,9 @@ class Program(object):
# for exmaple what the vpp is supposed to be
# in our topoloty overview
- instance_names = ["vpp-1",
- "vpp-2",
- "vpp-3",
- "vpp-4"]
+ instance_names = ["vpp-1", "vpp-2", "vpp-3", "vpp-4"]
- network_names = ["net-1",
- "net-2",
- "net-3"]
+ network_names = ["net-1", "net-2", "net-3"]
def __init__(self, image=None, prefix=None):
self.path = dirname(realpath(__file__))
@@ -469,15 +470,20 @@ class Program(object):
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")
+ 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")
+ 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())
+ 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()
@@ -516,16 +522,17 @@ class Program(object):
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")
+ 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")
+ 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 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")
@@ -539,8 +546,11 @@ class Program(object):
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())
+ 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()
@@ -561,7 +571,7 @@ class Program(object):
for p in c4.pg_read_packets():
p.show2()
- ''' T.Map is obsolete
+ """ T.Map is obsolete
def test_tmap(self):
# TESTS:
# trace add af-packet-input 10
@@ -844,7 +854,7 @@ class Program(object):
print("Receiving packet on {}:".format(c4.name))
for p in c4.pg_read_packets():
p.show2()
- '''
+ """
def test_gtp4(self):
# TESTS:
@@ -863,16 +873,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -880,8 +894,8 @@ class Program(object):
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")
+ "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")
@@ -889,17 +903,19 @@ class Program(object):
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())
+ 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()
- time.sleep(10)
+ time.sleep(10)
c1.enable_trace(10)
c4.enable_trace(10)
@@ -933,16 +949,20 @@ class Program(object):
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")
+ 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")
+ 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:1111:aaaa:bbbb::")
- c1.vppctl_exec("sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid prefix D2:1111:aaaa::/48 behavior end usid 16")
@@ -950,8 +970,8 @@ class Program(object):
c3.vppctl_exec("sr localsid prefix D2:1111:bbbb::/48 behavior end usid 16")
c4.vppctl_exec(
- "sr localsid prefix D4::/32 "
- "behavior end.m.gtp4.e v4src_position 64")
+ "sr localsid prefix D4::/32 " "behavior end.m.gtp4.e v4src_position 64"
+ )
c2.set_ipv6_route("eth2", "A2::2", "D2:1111:bbbb::/48")
c2.set_ipv6_route("eth1", "A1::1", "C::/120")
@@ -959,17 +979,19 @@ class Program(object):
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())
+ 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()
- time.sleep(10)
+ time.sleep(10)
c1.enable_trace(10)
c4.enable_trace(10)
@@ -1003,16 +1025,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1020,8 +1046,8 @@ class Program(object):
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")
+ "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")
@@ -1029,13 +1055,15 @@ class Program(object):
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())
+ 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()
@@ -1073,16 +1101,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1090,8 +1122,8 @@ class Program(object):
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")
+ "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")
@@ -1099,10 +1131,12 @@ class Program(object):
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", S=1, teid=200, seq=200))
+ 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", S=1, teid=200, seq=200)
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -1140,16 +1174,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1157,8 +1195,8 @@ class Program(object):
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")
+ "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")
@@ -1166,10 +1204,12 @@ class Program(object):
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_response", S=1, teid=200, seq=200))
+ 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_response", S=1, teid=200, seq=200)
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -1207,16 +1247,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64 nhtype ipv4"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1224,8 +1268,8 @@ class Program(object):
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")
+ "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")
@@ -1233,12 +1277,15 @@ class Program(object):
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="error_indication", S=1, teid=200, seq=200)/
- IE_TEIDI(TEIDI=65535)/IE_GSNAddress(address="1.1.1.1")/
- IE_PrivateExtension(extention_value="z"))
+ 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="error_indication", S=1, teid=200, seq=200)
+ / IE_TEIDI(TEIDI=65535)
+ / IE_GSNAddress(address="1.1.1.1")
+ / IE_PrivateExtension(extention_value="z")
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -1276,16 +1323,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1293,8 +1344,8 @@ class Program(object):
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")
+ "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")
@@ -1302,12 +1353,14 @@ class Program(object):
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())
+ 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()
@@ -1345,16 +1398,20 @@ class Program(object):
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")
+ 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")
+ 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 policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64")
+ c1.vppctl_exec(
+ "sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 v6src_prefix C1::/64"
+ )
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D5::")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1362,8 +1419,8 @@ class Program(object):
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")
+ "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")
@@ -1371,13 +1428,15 @@ class Program(object):
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())
+ 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()
@@ -1419,18 +1478,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1447,12 +1507,14 @@ class Program(object):
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())
+ 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()
@@ -1494,18 +1556,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1522,13 +1585,15 @@ class Program(object):
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())
+ 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()
@@ -1570,18 +1635,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1598,10 +1664,12 @@ class Program(object):
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", S=1, teid=200, seq=300))
+ 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", S=1, teid=200, seq=300)
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -1643,18 +1711,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1671,10 +1740,12 @@ class Program(object):
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_response", S=1, teid=200, seq=300))
+ 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_response", S=1, teid=200, seq=300)
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -1716,18 +1787,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1744,12 +1816,15 @@ class Program(object):
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="error_indication", S=1, teid=200, seq=300)/
- IE_TEIDI(TEIDI=65535)/IE_GSNAddress(address="1.1.1.1")/
- IE_PrivateExtension(extention_value="z"))
+ 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="error_indication", S=1, teid=200, seq=300)
+ / IE_TEIDI(TEIDI=65535)
+ / IE_GSNAddress(address="1.1.1.1")
+ / IE_PrivateExtension(extention_value="z")
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -1791,18 +1866,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1819,12 +1895,14 @@ class Program(object):
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())
+ 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()
@@ -1866,18 +1944,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ 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")
@@ -1894,13 +1973,15 @@ class Program(object):
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())
+ 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()
@@ -1942,18 +2023,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ c1.vppctl_exec("sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -1971,12 +2053,14 @@ class Program(object):
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())
+ 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()
@@ -2018,18 +2102,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ c1.vppctl_exec("sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -2047,13 +2132,15 @@ class Program(object):
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())
+ 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()
@@ -2095,18 +2182,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ c1.vppctl_exec("sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -2124,12 +2212,14 @@ class Program(object):
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())
+ 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()
@@ -2171,18 +2261,19 @@ class Program(object):
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")
+ 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")
+ 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")
+ c1.vppctl_exec("sr localsid prefix D::/64 behavior end.m.gtp6.d D4::/64")
c2.vppctl_exec("sr localsid address D2:: behavior end")
@@ -2200,13 +2291,15 @@ class Program(object):
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())
+ 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()
@@ -2246,19 +2339,22 @@ class Program(object):
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")
+ remote_mac="aa:bb:cc:dd:ee:02",
+ )
c1.pg_create_interface4_name(
ifname="pg1",
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")
+ remote_mac="aa:bb:cc:dd:ee:22",
+ )
c1.vppctl_exec("set sr encaps source addr A1::1")
c1.vppctl_exec(
- "sr localsid prefix D::/64 behavior end.m.gtp6.dt46 fib-table 0 local-fib-table 0")
+ "sr localsid prefix D::/64 behavior end.m.gtp6.dt46 fib-table 0 local-fib-table 0"
+ )
c1.vppctl_exec("set ip neighbor pg1 1.0.0.1 aa:bb:cc:dd:ee:22")
c1.set_ip_pgroute("pg1", "1.0.0.1", "172.200.0.1/32")
@@ -2266,12 +2362,14 @@ class Program(object):
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())
+ 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()
@@ -2310,14 +2408,16 @@ class Program(object):
local_ip="172.16.0.1/30",
remote_ip="172.16.0.2",
local_mac="aa:bb:cc:dd:ee:01",
- remote_mac="aa:bb:cc:dd:ee:02")
+ remote_mac="aa:bb:cc:dd:ee:02",
+ )
c1.pg_create_interface4_name(
ifname="pg1",
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")
+ 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 D5:: behavior t.m.gtp4.dt4 fib-table 0")
@@ -2329,12 +2429,14 @@ class Program(object):
print("Waiting...")
time.sleep(30)
- 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.100.0.1", dst="172.200.0.1") /
- ICMP())
+ 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.100.0.1", dst="172.200.0.1")
+ / ICMP()
+ )
print("Sending packet on {}:".format(c1.name))
p.show2()
@@ -2360,17 +2462,21 @@ class Program(object):
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(
+ "\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"))
+ print(
+ "\t[{}] {} - {}".format(
+ i, name, "running" if self.networks.get(name) else "missing"
+ )
+ )
def build_image(self):
print("VPP Path (build): {}".format(self.vpp_path))
@@ -2382,7 +2488,9 @@ class Program(object):
system(
"docker cp release-build:{}/vpp-package.tgz {}/".format(
- self.vpp_path, self.vpp_path))
+ self.vpp_path, self.vpp_path
+ )
+ )
instance.rem()
@@ -2408,39 +2516,30 @@ class Program(object):
def get_args():
parser = ArgumentParser()
- parser.add_argument("--verbose", choices=['error', 'debug', 'info'])
+ parser.add_argument("--verbose", choices=["error", "debug", "info"])
- parser.add_argument('--image', choices=['debug', 'release'])
+ parser.add_argument("--image", choices=["debug", "release"])
subparsers = parser.add_subparsers()
- p1 = subparsers.add_parser(
- "infra", help="Infrastructure related commands.")
+ p1 = subparsers.add_parser("infra", help="Infrastructure related commands.")
p1.add_argument(
- "op",
- choices=[
- 'stop',
- 'start',
- 'status',
- 'restart',
- 'build',
- 'release'])
+ "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("op", choices=["vppctl", "bash"])
p2.add_argument(
- "index",
- type=int,
- help="Container instance index. (./runner.py infra status)")
+ "index", type=int, help="Container instance index. (./runner.py infra status)"
+ )
- p2.add_argument(
- "--command", help="Only vppctl supports this optional argument.")
+ p2.add_argument("--command", help="Only vppctl supports this optional argument.")
p3 = subparsers.add_parser("test", help="Test related commands.")
@@ -2473,7 +2572,9 @@ def get_args():
"gtp6_ipv6",
"gtp6_ipv6_5g",
"gtp6_dt",
- "gtp4_dt"])
+ "gtp4_dt",
+ ],
+ )
args = parser.parse_args()
if not hasattr(args, "op") or not args.op:
@@ -2483,15 +2584,14 @@ def get_args():
return vars(args)
-def main(op=None, prefix=None, verbose=None,
- image=None, index=None, command=None):
+def main(op=None, prefix=None, verbose=None, image=None, index=None, command=None):
if verbose:
basicConfig(level=verbose_levels[verbose])
- if image == 'release':
+ if image == "release":
image = "srv6m-release-image"
- elif image == 'debug':
+ elif image == "debug":
image = "srv6m-image"
else:
image = "srv6m-image"
@@ -2501,23 +2601,23 @@ def main(op=None, prefix=None, verbose=None,
program = Program(image, prefix)
try:
- if op == 'build':
+ if op == "build":
program.build_image()
- elif op == 'release':
+ elif op == "release":
program.release_image()
- elif op == 'stop':
+ elif op == "stop":
program.stop_containers()
- elif op == 'start':
+ elif op == "start":
program.start_containers()
- elif op == 'status':
+ elif op == "status":
program.status_containers()
- elif op == 'vppctl':
+ elif op == "vppctl":
program.vppctl(index, command)
- elif op == 'bash':
+ elif op == "bash":
program.bash(index)
- elif op == 'ping':
+ elif op == "ping":
program.test_ping()
- elif op == 'srv6':
+ elif op == "srv6":
program.test_srv6()
# elif op == 'tmap':
# program.test_tmap()
@@ -2527,47 +2627,47 @@ def main(op=None, prefix=None, verbose=None,
# program.test_tmap_ipv6()
# elif op == 'tmap_ipv6_5g':
# program.test_tmap_ipv6_5g()
- elif op == 'gtp4':
+ elif op == "gtp4":
program.test_gtp4()
- elif op == 'gtp4_usid':
+ elif op == "gtp4_usid":
program.test_gtp4_usid()
- elif op == 'gtp4_5g':
+ elif op == "gtp4_5g":
program.test_gtp4_5g()
- elif op == 'gtp4_echo':
+ elif op == "gtp4_echo":
program.test_gtp4_echo()
- elif op == 'gtp4_reply':
+ elif op == "gtp4_reply":
program.test_gtp4_reply()
- elif op == 'gtp4_error':
+ elif op == "gtp4_error":
program.test_gtp4_error()
- elif op == 'gtp4_ipv6':
+ elif op == "gtp4_ipv6":
program.test_gtp4_ipv6()
- elif op == 'gtp4_ipv6_5g':
+ elif op == "gtp4_ipv6_5g":
program.test_gtp4_ipv6_5g()
- elif op == 'gtp6_drop_in':
+ elif op == "gtp6_drop_in":
program.test_gtp6_drop_in()
- elif op == 'gtp6_drop_in_5g':
+ elif op == "gtp6_drop_in_5g":
program.test_gtp6_drop_in_5g()
- elif op == 'gtp6_drop_in_echo':
+ elif op == "gtp6_drop_in_echo":
program.test_gtp6_drop_in_echo()
- elif op == 'gtp6_drop_in_reply':
+ elif op == "gtp6_drop_in_reply":
program.test_gtp6_drop_in_reply()
- elif op == 'gtp6_drop_in_error':
+ elif op == "gtp6_drop_in_error":
program.test_gtp6_drop_in_error()
- elif op == 'gtp6_drop_in_ipv6':
+ elif op == "gtp6_drop_in_ipv6":
program.test_gtp6_drop_in_ipv6()
- elif op == 'gtp6_drop_in_ipv6_5g':
+ elif op == "gtp6_drop_in_ipv6_5g":
program.test_gtp6_drop_in_ipv6_5g()
- elif op == 'gtp6':
+ elif op == "gtp6":
program.test_gtp6()
- elif op == 'gtp6_5g':
+ elif op == "gtp6_5g":
program.test_gtp6_5g()
- elif op == 'gtp6_ipv6':
+ elif op == "gtp6_ipv6":
program.test_gtp6_ipv6()
- elif op == 'gtp6_ipv6_5g':
+ elif op == "gtp6_ipv6_5g":
program.test_gtp6_ipv6_5g()
- elif op == 'gtp6_dt':
+ elif op == "gtp6_dt":
program.test_gtp6_dt()
- elif op == 'gtp4_dt':
+ elif op == "gtp4_dt":
program.test_gtp4_dt()
except Exception: