X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_ip_route.py;h=ca0ae1ad47ddf8fb503a8bba71d2f0277f38c247;hb=31ed744;hp=e670230487a3b1e7dbb351cb2b61329aac61b32f;hpb=6f6311560380d0e992f710558e213df1b098ef94;p=vpp.git diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index e670230487a..ca0ae1ad47d 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -34,7 +34,13 @@ class DpoProto: DPO_PROTO_IP6 = 1 DPO_PROTO_MPLS = 2 DPO_PROTO_ETHERNET = 3 - DPO_PROTO_NSH = 4 + DPO_PROTO_BIER = 4 + DPO_PROTO_NSH = 5 + + +class MplsLspMode: + PIPE = 0 + UNIFORM = 1 def find_route(test, ip_addr, len, table_id=0, inet=AF_INET): @@ -94,6 +100,21 @@ class VppIpTable(VppObject): self.table_id)) +class VppMplsLabel(object): + def __init__(self, value, mode=MplsLspMode.PIPE, ttl=64, exp=0): + self.value = value + self.mode = mode + self.ttl = ttl + self.exp = exp + + def encode(self): + is_uniform = 0 if self.mode is MplsLspMode.PIPE else 1 + return {'label': self.value, + 'ttl': self.ttl, + 'exp': self.exp, + 'is_uniform': is_uniform} + + class VppRoutePath(object): def __init__( @@ -107,6 +128,10 @@ class VppRoutePath(object): is_interface_rx=0, is_resolve_host=0, is_resolve_attached=0, + is_source_lookup=0, + is_udp_encap=0, + is_dvr=0, + next_hop_id=0xffffffff, proto=DpoProto.DPO_PROTO_IP4): self.nh_itf = nh_sw_if_index self.nh_table_id = nh_table_id @@ -124,18 +149,37 @@ class VppRoutePath(object): self.is_resolve_host = is_resolve_host self.is_resolve_attached = is_resolve_attached self.is_interface_rx = is_interface_rx + self.is_source_lookup = is_source_lookup self.is_rpf_id = 0 if rpf_id != 0: self.is_rpf_id = 1 self.nh_itf = rpf_id + self.is_udp_encap = is_udp_encap + self.next_hop_id = next_hop_id + self.is_dvr = is_dvr + + def encode_labels(self): + lstack = [] + for l in self.nh_labels: + if type(l) == VppMplsLabel: + lstack.append(l.encode()) + else: + lstack.append({'label': l, + 'ttl': 255}) + return lstack class VppMRoutePath(VppRoutePath): - def __init__(self, nh_sw_if_index, flags): - super(VppMRoutePath, self).__init__("0.0.0.0", - nh_sw_if_index) + def __init__(self, nh_sw_if_index, flags, + proto=DpoProto.DPO_PROTO_IP4, + bier_imp=0): + super(VppMRoutePath, self).__init__( + "::" if proto is DpoProto.DPO_PROTO_IP6 else "0.0.0.0", + nh_sw_if_index, + proto=proto) self.nh_i_flags = flags + self.bier_imp = bier_imp class VppIpRoute(VppObject): @@ -181,22 +225,25 @@ class VppIpRoute(VppObject): is_ipv6=self.is_ip6) else: for path in self.paths: + lstack = path.encode_labels() + self._test.vapi.ip_add_del_route( self.dest_addr, self.dest_addr_len, path.nh_addr, path.nh_itf, table_id=self.table_id, - next_hop_out_label_stack=path.nh_labels, - next_hop_n_out_labels=len( - path.nh_labels), + next_hop_out_label_stack=lstack, + next_hop_n_out_labels=len(lstack), next_hop_via_label=path.nh_via_label, next_hop_table_id=path.nh_table_id, + next_hop_id=path.next_hop_id, is_ipv6=self.is_ip6, - is_l2_bridged=1 - if path.proto == DpoProto.DPO_PROTO_ETHERNET else 0, + is_dvr=path.is_dvr, is_resolve_host=path.is_resolve_host, is_resolve_attached=path.is_resolve_attached, + is_source_lookup=path.is_source_lookup, + is_udp_encap=path.is_udp_encap, is_multipath=1 if len(self.paths) > 1 else 0) self._test.registry.register(self, self._test.logger) @@ -223,8 +270,11 @@ class VppIpRoute(VppObject): table_id=self.table_id, next_hop_table_id=path.nh_table_id, next_hop_via_label=path.nh_via_label, + next_hop_id=path.next_hop_id, is_add=0, - is_ipv6=self.is_ip6) + is_udp_encap=path.is_udp_encap, + is_ipv6=self.is_ip6, + is_dvr=path.is_dvr) def query_vpp_config(self): return find_route(self._test, @@ -272,8 +322,10 @@ class VppIpMRoute(VppObject): self.grp_addr, self.grp_addr_len, self.e_flags, + path.proto, path.nh_itf, path.nh_i_flags, + bier_imp=path.bier_imp, rpf_id=self.rpf_id, table_id=self.table_id, is_ipv6=self.is_ip6) @@ -285,9 +337,11 @@ class VppIpMRoute(VppObject): self.grp_addr, self.grp_addr_len, self.e_flags, + path.proto, path.nh_itf, path.nh_i_flags, table_id=self.table_id, + bier_imp=path.bier_imp, is_add=0, is_ipv6=self.is_ip6) @@ -297,6 +351,7 @@ class VppIpMRoute(VppObject): self.grp_addr, self.grp_addr_len, self.e_flags, + 0, 0xffffffff, 0, table_id=self.table_id, @@ -308,6 +363,7 @@ class VppIpMRoute(VppObject): self.grp_addr, self.grp_addr_len, self.e_flags, + 0, 0xffffffff, 0, rpf_id=self.rpf_id, @@ -323,16 +379,21 @@ class VppIpMRoute(VppObject): self.grp_addr, self.grp_addr_len, self.e_flags, + path.proto, path.nh_itf, path.nh_i_flags, table_id=self.table_id, is_ipv6=self.is_ip6) def query_vpp_config(self): - dump = self._test.vapi.ip_fib_dump() + if self.is_ip6: + dump = self._test.vapi.ip6_mfib_dump() + else: + dump = self._test.vapi.ip_mfib_dump() for e in dump: - if self.grp_addr == e.address \ + if self.grp_addr == e.grp_address \ and self.grp_addr_len == e.address_length \ + and self.src_addr == e.src_address \ and self.table_id == e.table_id: return True return False @@ -483,6 +544,8 @@ class VppMplsRoute(VppObject): def add_vpp_config(self): is_multipath = len(self.paths) > 1 for path in self.paths: + lstack = path.encode_labels() + self._test.vapi.mpls_route_add_del( self.local_label, self.eos_bit, @@ -494,9 +557,8 @@ class VppMplsRoute(VppObject): table_id=self.table_id, is_interface_rx=path.is_interface_rx, is_rpf_id=path.is_rpf_id, - next_hop_out_label_stack=path.nh_labels, - next_hop_n_out_labels=len( - path.nh_labels), + next_hop_out_label_stack=lstack, + next_hop_n_out_labels=len(lstack), next_hop_via_label=path.nh_via_label, next_hop_table_id=path.nh_table_id) self._test.registry.register(self, self._test.logger)