diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-10-10 07:22:51 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-11-07 12:00:10 +0000 |
commit | 93cc3ee3b3a9c9224a1446625882205f3282a949 (patch) | |
tree | 077421ee51238c22181a3b3f4871b648bb1299d3 /test/vpp_vxlan_gbp_tunnel.py | |
parent | c3df1e9a0ab79c1fe254394748ef441ffe224c43 (diff) |
GBP Endpoint Learning
Learning GBP endpoints over vxlan-gbp tunnels
Change-Id: I1db9fda5a16802d9ad8b4efd4e475614f3b21502
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'test/vpp_vxlan_gbp_tunnel.py')
-rw-r--r-- | test/vpp_vxlan_gbp_tunnel.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/vpp_vxlan_gbp_tunnel.py b/test/vpp_vxlan_gbp_tunnel.py new file mode 100644 index 00000000000..805d4c5f3e2 --- /dev/null +++ b/test/vpp_vxlan_gbp_tunnel.py @@ -0,0 +1,69 @@ + +from vpp_interface import VppInterface +from vpp_ip import VppIpAddress + + +INDEX_INVALID = 0xffffffff + + +def find_vxlan_gbp_tunnel(test, src, dst, vni): + vsrc = VppIpAddress(src) + vdst = VppIpAddress(dst) + + ts = test.vapi.vxlan_gbp_tunnel_dump(INDEX_INVALID) + for t in ts: + if vsrc == t.tunnel.src and \ + vdst == t.tunnel.dst and \ + t.tunnel.vni == vni: + return t.tunnel.sw_if_index + return INDEX_INVALID + + +class VppVxlanGbpTunnel(VppInterface): + """ + VPP VXLAN GBP interface + """ + + def __init__(self, test, src, dst, vni, mcast_itf=None): + """ Create VXLAN-GBP Tunnel interface """ + super(VppVxlanGbpTunnel, self).__init__(test) + self.src = VppIpAddress(src) + self.dst = VppIpAddress(dst) + self.vni = vni + self.mcast_itf = mcast_itf + + def add_vpp_config(self): + mcast_sw_if_index = INDEX_INVALID + if (self.mcast_itf): + mcast_sw_if_index = self.mcast_itf.sw_if_index + reply = self.test.vapi.vxlan_gbp_tunnel_add_del( + self.src.encode(), + self.dst.encode(), + vni=self.vni, + mcast_sw_if_index=mcast_sw_if_index) + self.set_sw_if_index(reply.sw_if_index) + self._test.registry.register(self, self._test.logger) + + def remove_vpp_config(self): + mcast_sw_if_index = INDEX_INVALID + if (self.mcast_itf): + mcast_sw_if_index = self.mcast_itf.sw_if_index + self.test.vapi.vxlan_gbp_tunnel_add_del( + self.src.encode(), + self.dst.encode(), + vni=self.vni, + is_add=0, + mcast_sw_if_index=mcast_sw_if_index) + + def query_vpp_config(self): + return (INDEX_INVALID != find_vxlan_gbp_tunnel(self._test, + self.src.address, + self.dst.address, + self.vni)) + + def __str__(self): + return self.object_id() + + def object_id(self): + return "vxlan-gbp-%d-%d-%s-%s" % (self.sw_if_index, self.vni, + self.src, self.dst) |