Skip to content

Commit 2025935

Browse files
authored
fix route flap script issue on dual tor (#6551)
1 parent 86fd140 commit 2025935

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

tests/route/test_route_flap.py

+31-6
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ def check_route(duthost, route, dev_port, operation):
9494
pytest_assert(dev_port in result, "Route {} was not announced {}".format(route, result))
9595

9696

97-
def send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, dst_mac, src_ip, dst_ip):
98-
pkt = testutils.simple_icmp_packet(eth_dst = dst_mac, ip_src = src_ip, ip_dst = dst_ip, icmp_type=8, icmp_data="")
97+
def send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, dst_mac, exp_src_mac, src_ip, dst_ip):
98+
# use ptf sender interface mac for easy identify testing packets
99+
src_mac = ptfadapter.dataplane.get_mac(0, ptf_send_port)
100+
pkt = testutils.simple_icmp_packet(eth_dst = dst_mac, eth_src = src_mac, ip_src = src_ip, ip_dst = dst_ip, icmp_type=8, icmp_code=0)
99101

100102
ext_pkt = pkt.copy()
101-
ext_pkt['Ether'].src = dst_mac
103+
ext_pkt['Ether'].src = exp_src_mac
102104

103105
masked_exp_pkt = Mask(ext_pkt)
104106
masked_exp_pkt.set_do_not_care_scapy(scapy.Ether,"dst")
@@ -131,13 +133,36 @@ def get_exabgp_port(duthost, tbinfo, dev_port):
131133
tor1_exabgp_port = EXABGP_BASE_PORT + tor1_offset
132134
return tor1_exabgp_port
133135

136+
def is_dualtor(tbinfo):
137+
"""Check if the testbed is dualtor."""
138+
return "dualtor" in tbinfo["topo"]["name"]
134139

135140
def test_route_flap(duthost, tbinfo, ptfhost, ptfadapter,
136141
get_function_conpleteness_level, announce_default_routes):
137142
ptf_ip = tbinfo['ptf_ip']
138143
common_config = tbinfo['topo']['properties']['configuration_properties'].get('common', {})
139144
nexthop = common_config.get('nhipv4', NHIPV4)
145+
146+
# On dual-tor, unicast upstream l3 packet destination mac should be vlan mac
147+
# After routing, output packet source mac will be replaced with port-channel mac (same as dut_mac)
148+
# On dual-tor, vlan mac is different with dut_mac. U0/L0 use same vlan mac for AR response
149+
# On single tor, vlan mac (if exists) is same as dut_mac
140150
dut_mac = duthost.facts['router_mac']
151+
vlan_mac = ""
152+
if is_dualtor(tbinfo):
153+
# Just let it crash if missing vlan configs on dual-tor
154+
vlan_cfgs = tbinfo['topo']['properties']['topology']['DUT']['vlan_configs']
155+
156+
if vlan_cfgs and 'default_vlan_config' in vlan_cfgs:
157+
default_vlan_name = vlan_cfgs['default_vlan_config']
158+
if default_vlan_name:
159+
for vlan in vlan_cfgs[default_vlan_name].values():
160+
if 'mac' in vlan and vlan['mac']:
161+
vlan_mac = vlan['mac']
162+
break
163+
pytest_assert(vlan_mac, 'dual-tor without vlan mac !!!')
164+
else:
165+
vlan_mac = dut_mac
141166

142167
#get dst_prefix_list and aspath
143168
routes = namedtuple('routes', ['route', 'aspath'])
@@ -182,21 +207,21 @@ def test_route_flap(duthost, tbinfo, ptfhost, ptfadapter,
182207
aspath = dst_prefix_list[route_index].aspath
183208

184209
#test link status
185-
send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, dut_mac, ptf_ip, ping_ip)
210+
send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, vlan_mac, dut_mac, ptf_ip, ping_ip)
186211

187212
withdraw_route(ptf_ip, dst_prefix, nexthop, exabgp_port, aspath)
188213
# Check if route is withdraw with first 3 routes
189214
if route_index < 4:
190215
time.sleep(1)
191216
check_route(duthost, dst_prefix, dev_port, WITHDRAW)
192-
send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, dut_mac, ptf_ip, ping_ip)
217+
send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, vlan_mac, dut_mac, ptf_ip, ping_ip)
193218

194219
announce_route(ptf_ip, dst_prefix, nexthop, exabgp_port, aspath)
195220
# Check if route is announced with first 3 routes
196221
if route_index < 4:
197222
time.sleep(1)
198223
check_route(duthost, dst_prefix, dev_port, ANNOUNCE)
199-
send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, dut_mac, ptf_ip, ping_ip)
224+
send_recv_ping_packet(ptfadapter, ptf_send_port, ptf_recv_ports, vlan_mac, dut_mac, ptf_ip, ping_ip)
200225

201226
route_index += 1
202227

0 commit comments

Comments
 (0)