Skip to content

Commit

Permalink
Fix Allow prefix Delete case (#6671)
Browse files Browse the repository at this point in the history
When we add allow-list key with action above route-map gets updated . For eg if we add deny action above template will become to no-export community. Now if we delete the key Issue is we still keep the no-export and do not move back to drop community.

This PR fixes this issue by rolling back default route-map community value back to constants.yml default action.
  • Loading branch information
abdosi committed Feb 4, 2021
1 parent 9c9f045 commit fede95d
Show file tree
Hide file tree
Showing 2 changed files with 378 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def __remove_policy(self, deployment_id, community_value):
msg += " deployment_id '%s'. community: '%s'"
log_info(msg % info)

default_action = self.__get_default_action_community()
names = self.__generate_names(deployment_id, community_value)
self.cfg_mgr.update()
cmds = []
Expand All @@ -181,6 +182,8 @@ def __remove_policy(self, deployment_id, community_value):
cmds += self.__remove_prefix_list(self.V4, names['pl_v4'])
cmds += self.__remove_prefix_list(self.V6, names['pl_v6'])
cmds += self.__remove_community(names['community'])
cmds += self.__update_default_route_map_entry(names['rm_v4'], default_action)
cmds += self.__update_default_route_map_entry(names['rm_v6'], default_action)
if cmds:
self.cfg_mgr.push_list(cmds)
peer_groups = self.__find_peer_group_by_deployment_id(deployment_id)
Expand Down Expand Up @@ -676,7 +679,7 @@ def __af_to_family(self, af):
"""
return 'ip' if af == self.V4 else 'ipv6'

def __get_default_action_community(self, data):
def __get_default_action_community(self, data=None):
"""
Determine the default action community based on the request.
If request doesn't contain "default_action" field - the default_action value
Expand All @@ -685,7 +688,7 @@ def __get_default_action_community(self, data):
:return: returns community value for "default_action"
"""
drop_community = self.constants["bgp"]["allow_list"]["drop_community"]
if "default_action" in data:
if data and "default_action" in data:
if data["default_action"] == "deny":
return "no-export"
else: # "permit"
Expand Down
Loading

0 comments on commit fede95d

Please sign in to comment.