def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None,
- tep=None, sclass=None):
+ tep=None, sclass=None, flags=None):
if ip:
vip = ip
if mac:
if sclass:
if ep.endpoint.sclass != sclass:
continue
+ if flags:
+ if flags != (flags & ep.endpoint.flags):
+ continue
if ip:
for eip in ep.endpoint.ips:
if vip == str(eip):
""" GBP Test Case """
@property
- def config_flags(self):
+ def nat_config_flags(self):
return VppEnum.vl_api_nat_config_flags_t
+ @property
+ def nat44_config_flags(self):
+ return VppEnum.vl_api_nat44_config_flags_t
+
@classmethod
def setUpClass(cls):
super(TestGBP, cls).setUpClass()
"10.0.2.1", "11.0.0.4",
"2001:10:2::1", "3001::4")]
+ self.vapi.nat44_plugin_enable_disable(enable=1)
+
#
# Config related to each of the EPGs
#
for epg in epgs:
# IP config on the BVI interfaces
if epg != epgs[1] and epg != epgs[4]:
- VppIpInterfaceBind(self, epg.bvi, epg.rd.t4).add_vpp_config()
- VppIpInterfaceBind(self, epg.bvi, epg.rd.t6).add_vpp_config()
+ b4 = VppIpInterfaceBind(self, epg.bvi,
+ epg.rd.t4).add_vpp_config()
+ b6 = VppIpInterfaceBind(self, epg.bvi,
+ epg.rd.t6).add_vpp_config()
epg.bvi.set_mac(self.router_mac)
# The BVIs are NAT inside interfaces
- flags = self.config_flags.NAT_IS_INSIDE
+ flags = self.nat_config_flags.NAT_IS_INSIDE
self.vapi.nat44_interface_add_del_feature(
sw_if_index=epg.bvi.sw_if_index,
flags=flags, is_add=1)
is_add=1, flags=flags,
sw_if_index=epg.bvi.sw_if_index)
- if_ip4 = VppIpInterfaceAddress(self, epg.bvi, epg.bvi_ip4, 32)
- if_ip6 = VppIpInterfaceAddress(self, epg.bvi, epg.bvi_ip6, 128)
- if_ip4.add_vpp_config()
- if_ip6.add_vpp_config()
+ if_ip4 = VppIpInterfaceAddress(self, epg.bvi,
+ epg.bvi_ip4, 32,
+ bind=b4).add_vpp_config()
+ if_ip6 = VppIpInterfaceAddress(self, epg.bvi,
+ epg.bvi_ip6, 128,
+ bind=b6).add_vpp_config()
# EPG uplink interfaces in the RD
VppIpInterfaceBind(self, epg.uplink, epg.rd.t4).add_vpp_config()
for (ip, fip) in zip(ep.ips, ep.fips):
# Add static mappings for each EP from the 10/8 to 11/8 network
if ip_address(ip).version == 4:
- flags = self.config_flags.NAT_IS_ADDR_ONLY
+ flags = self.nat_config_flags.NAT_IS_ADDR_ONLY
self.vapi.nat44_add_del_static_mapping(
is_add=1,
local_ip_address=ip,
#
# cleanup
#
+ self.vapi.nat44_plugin_enable_disable(enable=0)
+
for ep in eps:
# del static mappings for each EP from the 10/8 to 11/8 network
- flags = self.config_flags.NAT_IS_ADDR_ONLY
- self.vapi.nat44_add_del_static_mapping(
- is_add=0,
- local_ip_address=ep.ip4,
- external_ip_address=ep.fip4,
- external_sw_if_index=0xFFFFFFFF,
- vrf_id=0,
- flags=flags)
+ flags = self.nat_config_flags.NAT_IS_ADDR_ONLY
self.vapi.nat66_add_del_static_mapping(
local_ip_address=ep.ip6,
external_ip_address=ep.fip6,
for epg in epgs:
# IP config on the BVI interfaces
if epg != epgs[0] and epg != epgs[3]:
- flags = self.config_flags.NAT_IS_INSIDE
- self.vapi.nat44_interface_add_del_feature(
- sw_if_index=epg.bvi.sw_if_index,
- flags=flags,
- is_add=0)
+ flags = self.nat_config_flags.NAT_IS_INSIDE
self.vapi.nat66_add_del_interface(
- is_add=0, flags=flags,
- sw_if_index=epg.bvi.sw_if_index)
+ sw_if_index=epg.bvi.sw_if_index,
+ flags=flags, is_add=0)
for recirc in recircs:
- self.vapi.nat44_interface_add_del_feature(
- sw_if_index=recirc.recirc.sw_if_index,
- is_add=0)
self.vapi.nat66_add_del_interface(
- is_add=0,
- sw_if_index=recirc.recirc.sw_if_index)
+ sw_if_index=recirc.recirc.sw_if_index, is_add=0)
def wait_for_ep_timeout(self, sw_if_index=None, ip=None, mac=None,
tep=None, n_tries=100, s_time=1):
+ # only learnt EP can timeout
+ ep_flags = VppEnum.vl_api_gbp_endpoint_flags_t
+ flags = ep_flags.GBP_API_ENDPOINT_FLAG_LEARNT
while (n_tries):
- if not find_gbp_endpoint(self, sw_if_index, ip, mac, tep=tep):
+ if not find_gbp_endpoint(self, sw_if_index, ip, mac, tep=tep,
+ flags=flags):
return True
n_tries = n_tries - 1
self.sleep(s_time)
- self.assertFalse(find_gbp_endpoint(self, sw_if_index, ip, mac))
+ self.assertFalse(find_gbp_endpoint(self, sw_if_index, ip, mac, tep=tep,
+ flags=flags))
return False
def test_gbp_learn_l2(self):
None, self.loop0,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(4))
epg_220.add_vpp_config()
epg_330 = VppGbpEndpointGroup(self, 330, 113, rd1, gbd1,
None, self.loop1,
"10.0.1.128",
"2001:11::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(4))
epg_330.add_vpp_config()
#
for epg in epgs:
# IP config on the BVI interfaces
if epg != epgs[1]:
- VppIpInterfaceBind(self, epg.bvi, epg.rd.t4).add_vpp_config()
- VppIpInterfaceBind(self, epg.bvi, epg.rd.t6).add_vpp_config()
+ b4 = VppIpInterfaceBind(self, epg.bvi,
+ epg.rd.t4).add_vpp_config()
+ b6 = VppIpInterfaceBind(self, epg.bvi,
+ epg.rd.t6).add_vpp_config()
epg.bvi.set_mac(self.router_mac)
- if_ip4 = VppIpInterfaceAddress(self, epg.bvi, epg.bvi_ip4, 32)
- if_ip6 = VppIpInterfaceAddress(self, epg.bvi, epg.bvi_ip6, 128)
- if_ip4.add_vpp_config()
- if_ip6.add_vpp_config()
+ if_ip4 = VppIpInterfaceAddress(self, epg.bvi,
+ epg.bvi_ip4, 32,
+ bind=b4).add_vpp_config()
+ if_ip6 = VppIpInterfaceAddress(self, epg.bvi,
+ epg.bvi_ip6, 128,
+ bind=b6).add_vpp_config()
# add the BD ARP termination entry for BVI IP
epg.bd_arp_ip4 = VppBridgeDomainArpEntry(self, epg.bd.bd,
self.logger.info(self.vapi.cli("sh gbp bridge"))
# ... and has a /32 applied
- ip_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 32)
- ip_addr.add_vpp_config()
+ ip_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 32).add_vpp_config()
#
# The Endpoint-group
None, self.loop0,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(3))
epg_220.add_vpp_config()
ep = VppGbpEndpoint(self, self.pg0,
gbd1.add_vpp_config()
# ... and has a /32 applied
- ip_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 32)
- ip_addr.add_vpp_config()
+ ip_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 32).add_vpp_config()
#
# The Endpoint-group
self.logger.info(self.vapi.cli("sh gbp bridge"))
# ... and has a /32 applied
- ip_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 32)
- ip_addr.add_vpp_config()
+ ip_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 32).add_vpp_config()
#
# The Endpoint-group in which we are learning endpoints
None, self.loop0,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(4))
epg_220.add_vpp_config()
#
#
# Bind the BVI to the RD
#
- VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
+ b4 = VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
+ b6 = VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
#
# Pg2 hosts the vxlan tunnel
self.logger.info(self.vapi.cli("sh gbp route"))
# ... and has a /32 and /128 applied
- ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 32)
- ip4_addr.add_vpp_config()
- ip6_addr = VppIpInterfaceAddress(self, gbd1.bvi, "2001:10::128", 128)
- ip6_addr.add_vpp_config()
+ ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 32,
+ bind=b4).add_vpp_config()
+ ip6_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "2001:10::128", 128,
+ bind=b6).add_vpp_config()
#
# The Endpoint-group in which we are learning endpoints
None, self.loop0,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(4))
epg_220.add_vpp_config()
#
#
# Bind the BVI to the RD
#
- VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
+ b_ip4 = VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
+ b_ip6 = VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
#
# Pg7 hosts a BD's UU-fwd
gbd2.add_vpp_config()
# ... and has a /32 and /128 applied
- ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 32)
- ip4_addr.add_vpp_config()
- ip6_addr = VppIpInterfaceAddress(self, gbd1.bvi, "2001:10::128", 128)
- ip6_addr.add_vpp_config()
- ip4_addr = VppIpInterfaceAddress(self, gbd2.bvi, "10.0.1.128", 32)
- ip4_addr.add_vpp_config()
- ip6_addr = VppIpInterfaceAddress(self, gbd2.bvi, "2001:11::128", 128)
- ip6_addr.add_vpp_config()
+ ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 32,
+ bind=b_ip4).add_vpp_config()
+ ip6_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "2001:10::128", 128,
+ bind=b_ip6).add_vpp_config()
+ ip4_addr = VppIpInterfaceAddress(self, gbd2.bvi,
+ "10.0.1.128", 32).add_vpp_config()
+ ip6_addr = VppIpInterfaceAddress(self, gbd2.bvi,
+ "2001:11::128", 128).add_vpp_config()
#
# The Endpoint-groups in which we are learning endpoints
None, gbd1.bvi,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_220.add_vpp_config()
epg_221 = VppGbpEndpointGroup(self, 221, 441, rd1, gbd2,
None, gbd2.bvi,
"10.0.1.128",
"2001:11::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_221.add_vpp_config()
epg_222 = VppGbpEndpointGroup(self, 222, 442, rd1, gbd1,
None, gbd1.bvi,
"10.0.2.128",
"2001:12::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_222.add_vpp_config()
#
None, gbd1.bvi,
"12.0.0.128",
"4001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_320.add_vpp_config()
epg_321 = VppGbpEndpointGroup(self, 321, 551, rd1, gbd4,
None, gbd2.bvi,
"12.0.1.128",
"4001:11::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_321.add_vpp_config()
#
# add local l3out
# the external bd
self.loop4.set_mac(self.router_mac)
- VppIpInterfaceBind(self, self.loop4, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop4, t6).add_vpp_config()
+ b_lo4_ip4 = VppIpInterfaceBind(self, self.loop4, t4).add_vpp_config()
+ b_lo4_ip6 = VppIpInterfaceBind(self, self.loop4, t6).add_vpp_config()
ebd = VppBridgeDomain(self, 100)
ebd.add_vpp_config()
gebd = VppGbpBridgeDomain(self, ebd, rd1, self.loop4, None, None)
None, gebd.bvi,
"10.1.0.128",
"2001:10:1::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
eepg.add_vpp_config()
# add subnets to BVI
VppIpInterfaceAddress(
self,
gebd.bvi,
"10.1.0.128",
- 24).add_vpp_config()
+ 24, bind=b_lo4_ip4).add_vpp_config()
VppIpInterfaceAddress(
self,
gebd.bvi,
"2001:10:1::128",
- 64).add_vpp_config()
+ 64, bind=b_lo4_ip6).add_vpp_config()
# ... which are L3-out subnets
VppGbpSubnet(self, rd1, "10.1.0.0", 24,
VppEnum.vl_api_gbp_subnet_type_t.GBP_API_SUBNET_L3_OUT,
#
# Bind the BVI to the RD
#
- VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
- VppIpInterfaceBind(self, self.loop1, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop1, t6).add_vpp_config()
- VppIpInterfaceBind(self, self.loop2, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop2, t6).add_vpp_config()
+ b_lo0_ip4 = VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
+ b_lo0_ip6 = VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
+ b_lo1_ip4 = VppIpInterfaceBind(self, self.loop1, t4).add_vpp_config()
+ b_lo1_ip6 = VppIpInterfaceBind(self, self.loop1, t6).add_vpp_config()
+ b_lo2_ip4 = VppIpInterfaceBind(self, self.loop2, t4).add_vpp_config()
+ b_lo2_ip6 = VppIpInterfaceBind(self, self.loop2, t6).add_vpp_config()
#
# Pg7 hosts a BD's UU-fwd
gbd2.add_vpp_config()
# ... and has a /32 and /128 applied
- ip4_addr1 = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 32)
- ip4_addr1.add_vpp_config()
- ip6_addr1 = VppIpInterfaceAddress(self, gbd1.bvi, "2001:10::128", 128)
- ip6_addr1.add_vpp_config()
- ip4_addr2 = VppIpInterfaceAddress(self, gbd2.bvi, "10.0.1.128", 32)
- ip4_addr2.add_vpp_config()
- ip6_addr2 = VppIpInterfaceAddress(self, gbd2.bvi, "2001:11::128", 128)
- ip6_addr2.add_vpp_config()
+ ip4_addr1 = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 32,
+ bind=b_lo0_ip4).add_vpp_config()
+ ip6_addr1 = VppIpInterfaceAddress(self, gbd1.bvi,
+ "2001:10::128", 128,
+ bind=b_lo0_ip6).add_vpp_config()
+ ip4_addr2 = VppIpInterfaceAddress(self, gbd2.bvi,
+ "10.0.1.128", 32,
+ bind=b_lo1_ip4).add_vpp_config()
+ ip6_addr2 = VppIpInterfaceAddress(self, gbd2.bvi,
+ "2001:11::128", 128,
+ bind=b_lo1_ip6).add_vpp_config()
#
# The Endpoint-groups
None, gbd1.bvi,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_220.add_vpp_config()
epg_221 = VppGbpEndpointGroup(self, 221, 441, rd1, gbd2,
None, gbd2.bvi,
"10.0.1.128",
"2001:11::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_221.add_vpp_config()
#
bd_uu3, learn=False)
gbd3.add_vpp_config()
- ip4_addr3 = VppIpInterfaceAddress(self, gbd3.bvi, "12.0.0.128", 32)
- ip4_addr3.add_vpp_config()
- ip6_addr3 = VppIpInterfaceAddress(self, gbd3.bvi, "4001:10::128", 128)
- ip6_addr3.add_vpp_config()
+ ip4_addr3 = VppIpInterfaceAddress(self, gbd3.bvi,
+ "12.0.0.128", 32,
+ bind=b_lo2_ip4).add_vpp_config()
+ ip6_addr3 = VppIpInterfaceAddress(self, gbd3.bvi,
+ "4001:10::128", 128,
+ bind=b_lo2_ip6).add_vpp_config()
#
# self.logger.info(self.vapi.cli("show gbp bridge"))
None, gbd3.bvi,
"12.0.0.128",
"4001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(60))
epg_320.add_vpp_config()
#
#
# Bind the BVI to the RD
#
- VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
+ b_ip4 = VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
+ b_ip6 = VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
#
# Pg7 hosts a BD's BUM
None, gbd1.bvi,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(4))
epg_220.add_vpp_config()
# the BVIs have the subnets applied ...
- ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 24)
- ip4_addr.add_vpp_config()
- ip6_addr = VppIpInterfaceAddress(self, gbd1.bvi, "2001:10::128", 64)
- ip6_addr.add_vpp_config()
+ ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128",
+ 24, bind=b_ip4).add_vpp_config()
+ ip6_addr = VppIpInterfaceAddress(self, gbd1.bvi, "2001:10::128",
+ 64, bind=b_ip6).add_vpp_config()
# ... which are L3-out subnets
l3o_1 = VppGbpSubnet(
#
# Bind the BVI to the RD
#
- VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
- VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
+ bind_l0_ip4 = VppIpInterfaceBind(self, self.loop0, t4).add_vpp_config()
+ bind_l0_ip6 = VppIpInterfaceBind(self, self.loop0, t6).add_vpp_config()
#
# Pg7 hosts a BD's BUM
None, gbd1.bvi,
"10.0.0.128",
"2001:10::128",
- VppGbpEndpointRetention(2))
+ VppGbpEndpointRetention(4))
epg_220.add_vpp_config()
# the BVIs have the subnet applied ...
- ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi, "10.0.0.128", 24)
- ip4_addr.add_vpp_config()
+ ip4_addr = VppIpInterfaceAddress(self, gbd1.bvi,
+ "10.0.0.128", 24,
+ bind=bind_l0_ip4).add_vpp_config()
# ... which is an Anonymous L3-out subnets
l3o_1 = VppGbpSubnet(
self.vlan_101.set_vtr(L2_VTR_OP.L2_DISABLED)
self.vlan_100.set_vtr(L2_VTR_OP.L2_DISABLED)
self.pg7.unconfig_ip4()
+ # make sure the programmed EP is no longer learnt from DP
+ self.wait_for_ep_timeout(sw_if_index=rep.itf.sw_if_index, ip=rep.ip4)
if __name__ == '__main__':