-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bgpcfgd] ECMP overlay VxLan with BGP support (#10716)
Why I did it https://github.com/Azure/SONiC/blob/master/doc/vxlan/Overlay%20ECMP%20with%20BFD.md From the design, need to advertise the route with community string, the PR is to implement this. How I did it To use the route-map as the profile for the community string, all advertised routes can be associated with one route-map. Add one file, mangers_rm.py, which is to add/update/del the route-map. Modified the managers_advertise_rt.py file to associate profile with IP route. The route-map usage is very flexible, by this PR, we only support one fixed usage to add community string for route to simplify this design. How to verify it Implement new unit tests for mangers_rm.py and updated unit test for managers_advertise_rt.py. Manually verified the test case in the test plan section, will add testcase in sonic-mgmt later. sonic-net/sonic-mgmt#5581
- Loading branch information
1 parent
70e8ad3
commit 0cc9fdc
Showing
5 changed files
with
263 additions
and
34 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
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,78 @@ | ||
from .manager import Manager | ||
from .log import log_err, log_debug | ||
|
||
ROUTE_MAPS = ["FROM_SDN_SLB_ROUTES"] | ||
|
||
|
||
class RouteMapMgr(Manager): | ||
"""This class add route-map when BGP_PROFILE_TABLE in APPL_DB is updated""" | ||
|
||
def __init__(self, common_objs, db, table): | ||
""" | ||
Initialize the object | ||
:param common_objs: common object dictionary | ||
:param db: name of the db | ||
:param table: name of the table in the db | ||
""" | ||
super(RouteMapMgr, self).__init__( | ||
common_objs, | ||
[], | ||
db, | ||
table, | ||
) | ||
|
||
def set_handler(self, key, data): | ||
log_debug("BGPRouteMapMgr:: set handler") | ||
"""Only need a name as the key, and community id as the data""" | ||
if not self.__set_handler_validate(key, data): | ||
return True | ||
|
||
self.__update_rm(key, data) | ||
return True | ||
|
||
def del_handler(self, key): | ||
log_debug("BGPRouteMapMgr:: del handler") | ||
if not self.__del_handler_validate(key): | ||
return | ||
self.__remove_rm(key) | ||
|
||
def __remove_rm(self, rm): | ||
cmds = ["no route-map %s permit 100" % ("%s_RM" % rm)] | ||
log_debug("BGPRouteMapMgr:: remove route-map %s" % ("%s_RM" % rm)) | ||
self.cfg_mgr.push_list(cmds) | ||
log_debug("BGPRouteMapMgr::Done") | ||
|
||
def __set_handler_validate(self, key, data): | ||
if key not in ROUTE_MAPS: | ||
log_err("BGPRouteMapMgr:: Invalid key for route-map %s" % key) | ||
return False | ||
|
||
if not data: | ||
log_err("BGPRouteMapMgr:: data is None") | ||
return False | ||
community_ids = data["community_id"].split(":") | ||
try: | ||
if ( | ||
len(community_ids) != 2 | ||
or int(community_ids[0]) not in range(0, 65536) | ||
or int(community_ids[1]) not in range(0, 65536) | ||
): | ||
log_err("BGPRouteMapMgr:: data %s doesn't include valid community id %s" % (data, community_ids)) | ||
return False | ||
except ValueError: | ||
log_err("BGPRouteMapMgr:: data %s includes illegal input" % (data)) | ||
return False | ||
|
||
return True | ||
|
||
def __del_handler_validate(self, key): | ||
if key not in ROUTE_MAPS: | ||
log_err("BGPRouteMapMgr:: Invalid key for route-map %s" % key) | ||
return False | ||
return True | ||
|
||
def __update_rm(self, rm, data): | ||
cmds = ["route-map %s permit 100" % ("%s_RM" % rm), " set community %s" % data["community_id"]] | ||
log_debug("BGPRouteMapMgr:: update route-map %s community %s" % ("%s_RM" % rm, data["community_id"])) | ||
self.cfg_mgr.push_list(cmds) | ||
log_debug("BGPRouteMapMgr::Done") |
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
Oops, something went wrong.