-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for VNET route precedence over BGP learnt route. (#15710)
What is the motivation for this PR? Currently if a route is learnt via BGP and added into the hardware, adding a VNET route results in failure. In addition due to a bug in VnetOrch, we start advertising the failed route, This prompts the BGP to remove the learnt route in favor of the local route. Since the Vnet Orch doesn't retry adding the Vnet route, This results in no route being present in the Hardware. How I verified it The fix is in PR sonic-net/sonic-swss#3345 These tests cover various scenario in which VNET and BGP routes are added and removed in different order How did you do it? How did you verify/test it? Any platform specific information? Cisco-8000 and mlnx. Supported testbed topology if it's a new test case? Documentation There are 5 differnet scenarios which are checked. Each scenario is tested with with the following options. Encap types [v4_inv4, v6_inV4] Monitor Type [BFD, Custom] Init NH state( BFD/monitor sessions for nexthops are initially up or not.) test_vnet_route_after_bgp ADD BGP ROUTE on TOR Add VNET route Configure monitor (BFD or custom) with nexthop state (UP) Test with traffic Remove VNET route Remove BGP route test_vnet_route_before_bgp_after_ep_up Add VNET route Configure monitor (BFD or custom) with nexthop state (UP) Add BGP ROUTE on TOR Test with traffic Remove VNET ROUTE Remove BGP route test_vnet_route_bgp_removal_before_ep ADD BGP ROUTE on TOR Add VNET route Remove BGP route Configure monitor (BFD or custom) with nexthop state (UP) Test with traffic Remove VNET route test_vnet_route_after_bgp_with_early_bgp_removal Add VNET route Add BGP ROUTE on TOR Configure monitor (BFD or custom) with nexthop state (UP) Test with traffic Remove BGP route Test with traffic Remove VNET route test_vnet_route_after_bgp_multi_flap ADD BGP ROUTE on TOR Add VNET route Configure monitor (BFD or custom) with nexthop state (UP) Test with traffic flap the bfd/monitor sessions. Test with traffic Remove VNET route Remove BGP route
- Loading branch information
1 parent
86a132e
commit 071bdfe
Showing
3 changed files
with
1,305 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
''' | ||
# Description: This script is used to force notify the BFD state change to Orchagent. | ||
This script can be called as | ||
>>python script.py | ||
{'363:1d0:e:88d::64c:ed8': 'oid:0x45000000000ae7', '203:1d0:e:288::64c:e18': 'oid:0x45000000000adc'} | ||
>>python script.py --set "oid:0x45000000000ae7, oid:0x45000000000adc" "Up" | ||
>>python script.py --set "oid:0x45000000000ae7, oid:0x45000000000adc" "Down" | ||
>>python script.py --set "oid:0x45000000000ae7, oid:0x45000000000adc" "Init" | ||
>>python script.py --set "oid:0x45000000000ae7, oid:0x45000000000adc" "Admin_Down" | ||
''' | ||
import swsscommon.swsscommon as swsscommon | ||
import argparse | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="BFD Notifier Script") | ||
parser.add_argument("--set", nargs=2, metavar=('KEYLIST', 'STATE'), help="Comma separated key list and state") | ||
args = parser.parse_args() | ||
|
||
notifier = BFDNotifier() | ||
if args.set: | ||
key_list_str, state = args.set | ||
key_list = key_list_str.split(',') | ||
key_list = [key.strip() for key in key_list] | ||
notifier.update_bfds_state(key_list, state) | ||
else: | ||
result = notifier.get_asic_db_bfd_session_id() | ||
print(result) | ||
|
||
|
||
class BFDNotifier: | ||
def get_asic_db_bfd_session_id(self): | ||
asic_db = swsscommon.DBConnector("ASIC_DB", 0, True) | ||
tbl = swsscommon.Table(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_BFD_SESSION") | ||
entries = set(tbl.getKeys()) | ||
result = {} | ||
for entry in entries: | ||
status, fvs = tbl.get(entry) | ||
fvs = dict(fvs) | ||
assert status, "Got an error when get a key" | ||
result[fvs["SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS"]] = entry | ||
return result | ||
|
||
def update_bfds_state(self, bfd_ids, state): | ||
bfd_sai_state = { | ||
"Admin_Down": "SAI_BFD_SESSION_STATE_ADMIN_DOWN", | ||
"Down": "SAI_BFD_SESSION_STATE_DOWN", | ||
"Init": "SAI_BFD_SESSION_STATE_INIT", | ||
"Up": "SAI_BFD_SESSION_STATE_UP" | ||
} | ||
|
||
asic_db = swsscommon.DBConnector("ASIC_DB", 0, True) | ||
ntf = swsscommon.NotificationProducer(asic_db, "NOTIFICATIONS") | ||
fvp = swsscommon.FieldValuePairs() | ||
for bfd_id in bfd_ids: | ||
ntf_data = "[{\"bfd_session_id\":\""+bfd_id+"\",\"session_state\":\""+bfd_sai_state[state]+"\"}]" | ||
ntf.send("bfd_session_state_change", ntf_data, fvp) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.