Allow TSA on ibgp sessions between linecards on packet chassis (#12589)

This commit is contained in:
tjchadaga 2022-11-03 08:54:33 -07:00 committed by Ying Xie
parent dd425f11a6
commit a68c6ea454
2 changed files with 15 additions and 2 deletions

View File

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
switch_type=`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['switch_type']"`
# Check whether the routemap is for internal BGP sessions. # Check whether the routemap is for internal BGP sessions.
function is_internal_route_map() function is_internal_route_map()
{ {
[[ "$1" =~ .*"_INTERNAL_".* ]] [[ "$1" =~ .*"_INTERNAL_".* && $switch_type != "chassis-packet" ]]
} }
function check_not_installed() function check_not_installed()

View File

@ -13,11 +13,13 @@ class DeviceGlobalCfgMgr(Manager):
:param db: name of the db :param db: name of the db
:param table: name of the table in the db :param table: name of the table in the db
""" """
self.switch_type = ""
self.directory = common_objs['directory'] self.directory = common_objs['directory']
self.cfg_mgr = common_objs['cfg_mgr'] self.cfg_mgr = common_objs['cfg_mgr']
self.constants = common_objs['constants'] self.constants = common_objs['constants']
self.tsa_template = common_objs['tf'].from_file("bgpd/tsa/bgpd.tsa.isolate.conf.j2") self.tsa_template = common_objs['tf'].from_file("bgpd/tsa/bgpd.tsa.isolate.conf.j2")
self.tsb_template = common_objs['tf'].from_file("bgpd/tsa/bgpd.tsa.unisolate.conf.j2") self.tsb_template = common_objs['tf'].from_file("bgpd/tsa/bgpd.tsa.unisolate.conf.j2")
self.directory.subscribe([("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/switch_type"),], self.on_switch_type_change)
super(DeviceGlobalCfgMgr, self).__init__( super(DeviceGlobalCfgMgr, self).__init__(
common_objs, common_objs,
[], [],
@ -25,8 +27,16 @@ class DeviceGlobalCfgMgr(Manager):
table, table,
) )
def on_switch_type_change(self):
log_debug("DeviceGlobalCfgMgr:: Switch type update handler")
if self.directory.path_exist("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/switch_type"):
self.switch_type = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME)["localhost"]["switch_type"]
log_debug("DeviceGlobalCfgMgr:: Switch type: %s" % self.switch_type)
def set_handler(self, key, data): def set_handler(self, key, data):
log_debug("DeviceGlobalCfgMgr:: set handler") log_debug("DeviceGlobalCfgMgr:: set handler")
if self.switch_type:
log_debug("DeviceGlobalCfgMgr:: Switch type: %s" % self.switch_type)
""" Handle device tsa_enabled state change """ """ Handle device tsa_enabled state change """
if not data: if not data:
log_err("DeviceGlobalCfgMgr:: data is None") log_err("DeviceGlobalCfgMgr:: data is None")
@ -78,7 +88,9 @@ class DeviceGlobalCfgMgr(Manager):
def __generate_routemaps_from_template(self, route_map_names, template): def __generate_routemaps_from_template(self, route_map_names, template):
cmd = "\n" cmd = "\n"
for rm in sorted(route_map_names): for rm in sorted(route_map_names):
if "_INTERNAL_" in rm: # For packet-based chassis, the bgp session between the linecards are also considered internal sessions
# While isolating a single linecard, these sessions should not be skipped
if "_INTERNAL_" in rm and self.switch_type != "chassis-packet":
continue continue
if "V4" in rm: if "V4" in rm:
ipv="V4" ; ipp="ip" ipv="V4" ; ipp="ip"