summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/srv6-ad/test/vpp_srv6.py84
-rw-r--r--src/plugins/srv6-am/test/test_srv6.py45
2 files changed, 47 insertions, 82 deletions
diff --git a/src/plugins/srv6-ad/test/vpp_srv6.py b/src/plugins/srv6-ad/test/vpp_srv6.py
index b6dbc014207..80e771eea18 100644
--- a/src/plugins/srv6-ad/test/vpp_srv6.py
+++ b/src/plugins/srv6-ad/test/vpp_srv6.py
@@ -40,15 +40,12 @@ class VppSRv6LocalSID(VppObject):
SRv6 LocalSID
"""
- def __init__(self, test, localsid, behavior, nh_addr4, nh_addr6,
+ def __init__(self, test, localsid, behavior, nh_addr,
end_psp, sw_if_index, vlan_index, fib_table):
self._test = test
self.localsid = localsid
- # keep binary format in _localsid
- self.localsid["addr"] = inet_pton(AF_INET6, self.localsid["addr"])
self.behavior = behavior
- self.nh_addr4 = inet_pton(AF_INET, nh_addr4)
- self.nh_addr6 = inet_pton(AF_INET6, nh_addr6)
+ self.nh_addr = nh_addr
self.end_psp = end_psp
self.sw_if_index = sw_if_index
self.vlan_index = vlan_index
@@ -57,10 +54,9 @@ class VppSRv6LocalSID(VppObject):
def add_vpp_config(self):
self._test.vapi.sr_localsid_add_del(
- self.localsid,
- self.behavior,
- self.nh_addr4,
- self.nh_addr6,
+ localsid=self.localsid,
+ behavior=self.behavior,
+ nh_addr=self.nh_addr,
is_del=0,
end_psp=self.end_psp,
sw_if_index=self.sw_if_index,
@@ -70,10 +66,9 @@ class VppSRv6LocalSID(VppObject):
def remove_vpp_config(self):
self._test.vapi.sr_localsid_add_del(
- self.localsid,
- self.behavior,
- self.nh_addr4,
- self.nh_addr6,
+ localsid=self.localsid,
+ behavior=self.behavior,
+ nh_addr=self.nh_addr,
is_del=1,
end_psp=self.end_psp,
sw_if_index=self.sw_if_index,
@@ -103,17 +98,11 @@ class VppSRv6Policy(VppObject):
segments, source):
self._test = test
self.bsid = bsid
- # keep binary format in _bsid
- self._bsid = inet_pton(AF_INET6, bsid)
self.is_encap = is_encap
self.sr_type = sr_type
self.weight = weight
self.fib_table = fib_table
self.segments = segments
- # keep binary format in _segments
- self._segments = []
- for seg in segments:
- self._segments.extend(inet_pton(AF_INET6, seg))
self.n_segments = len(segments)
# source not passed to API
# self.source = inet_pton(AF_INET6, source)
@@ -122,18 +111,17 @@ class VppSRv6Policy(VppObject):
def add_vpp_config(self):
self._test.vapi.sr_policy_add(
- self._bsid,
- self.weight,
- self.is_encap,
- self.sr_type,
- self.fib_table,
- self.n_segments,
- self._segments)
+ bsid=self.bsid,
+ weight=self.weight,
+ is_encap=self.is_encap,
+ is_spray=self.sr_type,
+ fib_table=self.fib_table,
+ sids={'num_sids': self.n_segments, 'sids': self.segments})
self._configured = True
def remove_vpp_config(self):
self._test.vapi.sr_policy_del(
- self._bsid)
+ self.bsid)
self._configured = False
def query_vpp_config(self):
@@ -164,19 +152,7 @@ class VppSRv6Steering(VppObject):
sw_if_index):
self._test = test
self.bsid = bsid
- # keep binary format in _bsid
- self._bsid = inet_pton(AF_INET6, bsid)
self.prefix = prefix
- # keep binary format in _prefix
- if ':' in prefix:
- # IPv6
- self._prefix = inet_pton(AF_INET6, prefix)
- else:
- # IPv4
- # API expects 16 octets (128 bits)
- # last 4 octets are used for IPv4
- # --> prepend 12 octets
- self._prefix = ('\x00' * 12) + inet_pton(AF_INET, prefix)
self.mask_width = mask_width
self.traffic_type = traffic_type
self.sr_policy_index = sr_policy_index
@@ -186,26 +162,24 @@ class VppSRv6Steering(VppObject):
def add_vpp_config(self):
self._test.vapi.sr_steering_add_del(
- 0,
- self._bsid,
- self.sr_policy_index,
- self.table_id,
- self._prefix,
- self.mask_width,
- self.sw_if_index,
- self.traffic_type)
+ is_del=0,
+ bsid=self.bsid,
+ sr_policy_index=self.sr_policy_index,
+ table_id=self.table_id,
+ prefix={'address': self.prefix, 'len': self.mask_width},
+ sw_if_index=self.sw_if_index,
+ traffic_type=self.traffic_type)
self._configured = True
def remove_vpp_config(self):
self._test.vapi.sr_steering_add_del(
- 1,
- self._bsid,
- self.sr_policy_index,
- self.table_id,
- self._prefix,
- self.mask_width,
- self.sw_if_index,
- self.traffic_type)
+ is_del=1,
+ bsid=self.bsid,
+ sr_policy_index=self.sr_policy_index,
+ table_id=self.table_id,
+ prefix={'address': self.prefix, 'len': self.mask_width},
+ sw_if_index=self.sw_if_index,
+ traffic_type=self.traffic_type)
self._configured = False
def query_vpp_config(self):
diff --git a/src/plugins/srv6-am/test/test_srv6.py b/src/plugins/srv6-am/test/test_srv6.py
index 5a4a936b0cb..449ad59ac60 100644
--- a/src/plugins/srv6-am/test/test_srv6.py
+++ b/src/plugins/srv6-am/test/test_srv6.py
@@ -507,10 +507,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End without PSP behavior
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::0'},
+ self, localsid='A3::0',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_END,
- nh_addr4='0.0.0.0',
- nh_addr6='::',
+ nh_addr=0,
end_psp=0,
sw_if_index=0,
vlan_index=0,
@@ -586,10 +585,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End with PSP behavior
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::0'},
+ self, localsid='A3::0',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_END,
- nh_addr4='0.0.0.0',
- nh_addr6='::',
+ nh_addr=0,
end_psp=1,
sw_if_index=0,
vlan_index=0,
@@ -659,10 +657,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.X without PSP behavior
# End.X points to interface pg1
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_X,
- nh_addr4='0.0.0.0',
- nh_addr6=self.pg1.remote_ip6,
+ nh_addr=self.pg1.remote_ip6,
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -735,10 +732,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End with PSP behavior
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_X,
- nh_addr4='0.0.0.0',
- nh_addr6=self.pg1.remote_ip6,
+ nh_addr=self.pg1.remote_ip6,
end_psp=1,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -801,10 +797,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.DX6 behavior
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DX6,
- nh_addr4='0.0.0.0',
- nh_addr6=self.pg1.remote_ip6,
+ nh_addr=self.pg1.remote_ip6,
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -886,10 +881,9 @@ class TestSRv6(VppTestCase):
# fib_table: where the localsid is installed
# sw_if_index: in T-variants of localsid this is the vrf table_id
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DT6,
- nh_addr4='0.0.0.0',
- nh_addr6='::',
+ nh_addr=0,
end_psp=0,
sw_if_index=vrf_1,
vlan_index=0,
@@ -952,10 +946,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.DX4 behavior
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DX4,
- nh_addr4=self.pg1.remote_ip4,
- nh_addr6='::',
+ nh_addr=self.pg1.remote_ip4,
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -1039,10 +1032,9 @@ class TestSRv6(VppTestCase):
# fib_table: where the localsid is installed
# sw_if_index: in T-variants of localsid: vrf table_id
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DT4,
- nh_addr4='0.0.0.0',
- nh_addr6='::',
+ nh_addr=0,
end_psp=0,
sw_if_index=vrf_1,
vlan_index=0,
@@ -1104,10 +1096,9 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.DX2 behavior
localsid = VppSRv6LocalSID(
- self, localsid={'addr': 'A3::C4'},
+ self, localsid='A3::C4',
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DX2,
- nh_addr4='0.0.0.0',
- nh_addr6='::',
+ nh_addr=0,
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,