@@ -94,11 +94,13 @@ def check_route(duthost, route, dev_port, operation):
94
94
pytest_assert (dev_port in result , "Route {} was not announced {}" .format (route , result ))
95
95
96
96
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 )
99
101
100
102
ext_pkt = pkt .copy ()
101
- ext_pkt ['Ether' ].src = dst_mac
103
+ ext_pkt ['Ether' ].src = exp_src_mac
102
104
103
105
masked_exp_pkt = Mask (ext_pkt )
104
106
masked_exp_pkt .set_do_not_care_scapy (scapy .Ether ,"dst" )
@@ -131,13 +133,36 @@ def get_exabgp_port(duthost, tbinfo, dev_port):
131
133
tor1_exabgp_port = EXABGP_BASE_PORT + tor1_offset
132
134
return tor1_exabgp_port
133
135
136
+ def is_dualtor (tbinfo ):
137
+ """Check if the testbed is dualtor."""
138
+ return "dualtor" in tbinfo ["topo" ]["name" ]
134
139
135
140
def test_route_flap (duthost , tbinfo , ptfhost , ptfadapter ,
136
141
get_function_conpleteness_level , announce_default_routes ):
137
142
ptf_ip = tbinfo ['ptf_ip' ]
138
143
common_config = tbinfo ['topo' ]['properties' ]['configuration_properties' ].get ('common' , {})
139
144
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
140
150
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
141
166
142
167
#get dst_prefix_list and aspath
143
168
routes = namedtuple ('routes' , ['route' , 'aspath' ])
@@ -182,21 +207,21 @@ def test_route_flap(duthost, tbinfo, ptfhost, ptfadapter,
182
207
aspath = dst_prefix_list [route_index ].aspath
183
208
184
209
#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 )
186
211
187
212
withdraw_route (ptf_ip , dst_prefix , nexthop , exabgp_port , aspath )
188
213
# Check if route is withdraw with first 3 routes
189
214
if route_index < 4 :
190
215
time .sleep (1 )
191
216
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 )
193
218
194
219
announce_route (ptf_ip , dst_prefix , nexthop , exabgp_port , aspath )
195
220
# Check if route is announced with first 3 routes
196
221
if route_index < 4 :
197
222
time .sleep (1 )
198
223
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 )
200
225
201
226
route_index += 1
202
227
0 commit comments