-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixed FDB cleanup race issue where the mac flush may flush newly learnt MACs #2679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4c0d1f8
3592040
33397c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,9 @@ | |
| DUMMY_MAC_PREFIX = "02:11:22:33" | ||
| DUMMY_MAC_COUNT = 10 | ||
| FDB_POPULATE_SLEEP_TIMEOUT = 2 | ||
| FDB_CLEAN_UP_SLEEP_TIMEOUT = 2 | ||
| FDB_WAIT_EXPECTED_PACKET_TIMEOUT = 5 | ||
| PKT_TYPES = ["ethernet", "arp_request", "arp_reply"] | ||
| PKT_TYPES = ["ethernet", "arp_request", "arp_reply", "cleanup"] | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -150,25 +151,46 @@ def setup_fdb(ptfadapter, vlan_table, router_mac, pkt_type): | |
| time.sleep(FDB_POPULATE_SLEEP_TIMEOUT) | ||
| # Flush dataplane | ||
| ptfadapter.dataplane.flush() | ||
|
|
||
| return fdb | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def get_fdb_dynamic_mac_count(duthost): | ||
| res = duthost.command('show mac') | ||
| logger.info('"show mac" output on DUT:\n{}'.format(pprint.pformat(res['stdout_lines']))) | ||
| total_mac_count = 0 | ||
| for l in res['stdout_lines']: | ||
| if "dynamic" in l.lower(): | ||
| total_mac_count += 1 | ||
| return total_mac_count | ||
|
|
||
|
|
||
| def fdb_cleanup(duthosts, rand_one_dut_hostname): | ||
| """ cleanup FDB before and after test run """ | ||
| duthost = duthosts[rand_one_dut_hostname] | ||
| try: | ||
| duthost.command('sonic-clear fdb all') | ||
| yield | ||
| finally: | ||
| # in any case clear fdb after test | ||
| total_dyn_mac_count = get_fdb_dynamic_mac_count(duthost) | ||
| if total_dyn_mac_count == 0: | ||
| return | ||
| else: | ||
| done = False | ||
| duthost.command('sonic-clear fdb all') | ||
| while not done: | ||
| total_dyn_mac_count = get_fdb_dynamic_mac_count(duthost) | ||
| if total_dyn_mac_count != 0: | ||
| time.sleep(FDB_CLEAN_UP_SLEEP_TIMEOUT) | ||
| else: | ||
| return | ||
|
||
|
|
||
|
|
||
| @pytest.mark.bsl | ||
| @pytest.mark.usefixtures('fdb_cleanup') | ||
| @pytest.mark.parametrize("pkt_type", PKT_TYPES) | ||
| def test_fdb(ansible_adhoc, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost, pkt_type): | ||
|
|
||
| # Perform FDB clean up before each test and at the end of the final test | ||
| fdb_cleanup(duthosts, rand_one_dut_hostname) | ||
| if pkt_type == "cleanup": | ||
| return | ||
|
|
||
| """ | ||
| 1. verify fdb forwarding. | ||
| 2. verify show mac command on DUT for learned mac. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.