@@ -243,32 +243,32 @@ def setup_fdb(ptfadapter, vlan_table, router_mac, pkt_type, dummy_mac_count):
243243 # portchannel might have no member ports or all member ports are down, so skip empty list
244244 if not member ['port_index' ]:
245245 continue
246- port_index = member ['port_index' ][ 0 ]
247- vlan_id = vlan if member ['tagging_mode' ] == 'tagged' else 0
248- mac = ptfadapter .dataplane .get_mac (0 , port_index )
249- # send a packet to switch to populate layer 2 table with MAC of PTF interface
250- send_eth (ptfadapter , port_index , mac , router_mac , vlan_id )
251-
252- # put in learned MAC
253- fdb [port_index ] = {mac }
254-
255- # Send packets to switch to populate the layer 2 table with dummy MACs for each port
256- # Totally 10 dummy MACs for each port, send 1 packet for each dummy MAC
257- dummy_macs = ['{}:{:02x}:{:02x}' .format (DUMMY_MAC_PREFIX , port_index , i )
258- for i in range (dummy_mac_count )]
259-
260- for dummy_mac in dummy_macs :
261- if pkt_type == "ethernet" :
262- send_eth (ptfadapter , port_index , dummy_mac , router_mac , vlan_id )
263- elif pkt_type == "arp_request" :
264- send_arp_request (ptfadapter , port_index , dummy_mac , router_mac , vlan_id )
265- elif pkt_type == "arp_reply" :
266- send_arp_reply (ptfadapter , port_index , dummy_mac , router_mac , vlan_id )
267- else :
268- pytest .fail ("Unknown option '{}'" .format (pkt_type ))
269-
270- # put in set learned dummy MACs
271- fdb [port_index ].update (dummy_macs )
246+ for port_index in member ['port_index' ]:
247+ vlan_id = vlan if member ['tagging_mode' ] == 'tagged' else 0
248+ mac = ptfadapter .dataplane .get_mac (0 , port_index )
249+ # send a packet to switch to populate layer 2 table with MAC of PTF interface
250+ send_eth (ptfadapter , port_index , mac , router_mac , vlan_id )
251+
252+ # put in learned MAC
253+ fdb [port_index ] = {mac }
254+
255+ # Send packets to switch to populate the layer 2 table with dummy MACs for each port
256+ # Totally 10 dummy MACs for each port, send 1 packet for each dummy MAC
257+ dummy_macs = ['{}:{:02x}:{:02x}' .format (DUMMY_MAC_PREFIX , port_index , i )
258+ for i in range (dummy_mac_count )]
259+
260+ for dummy_mac in dummy_macs :
261+ if pkt_type == "ethernet" :
262+ send_eth (ptfadapter , port_index , dummy_mac , router_mac , vlan_id )
263+ elif pkt_type == "arp_request" :
264+ send_arp_request (ptfadapter , port_index , dummy_mac , router_mac , vlan_id )
265+ elif pkt_type == "arp_reply" :
266+ send_arp_reply (ptfadapter , port_index , dummy_mac , router_mac , vlan_id )
267+ else :
268+ pytest .fail ("Unknown option '{}'" .format (pkt_type ))
269+
270+ # put in set learned dummy MACs
271+ fdb [port_index ].update (dummy_macs )
272272
273273 time .sleep (FDB_POPULATE_SLEEP_TIMEOUT )
274274 # Flush dataplane
@@ -376,7 +376,7 @@ def test_fdb(ansible_adhoc, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost
376376 if port_index :
377377 vlan_table [vlan_id ].append ({'port_index' : port_index , 'tagging_mode' : tagging_mode })
378378
379- vlan_member_count = sum ([ len (members ) for members in list ( vlan_table .values ())] )
379+ vlan_member_count = sum (len (port [ 'port_index' ] ) for members in vlan_table .values () for port in members )
380380
381381 fdb = setup_fdb (ptfadapter , vlan_table , router_mac , pkt_type , configured_dummay_mac_count )
382382 for vlan in vlan_table :
0 commit comments