[bgpcfgd]: Fix bgpcfgd crash on reset Loopback0 ip addresses (#5050)

Fix an error which causes bgpcfgd crash on invalid ip address. Before the fix we had an issue here. When either loopback ipv4 or ipv6 addresses were already set and bgpcfgd received another "SET" message for already set ip loopback address, bgpcfgd will send syslog message about ambiguous ip address (despite the fact that the address is good) and crash of bgpcfgd. With this change this behavior is changed: if we receive ip address and this ip address is already set, bgpcfgd will send this message to the syslog and return from the handler.
This commit is contained in:
pavel-shirshov 2020-07-28 12:18:07 -07:00 committed by GitHub
parent 6120145bf1
commit 459c29cfaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,14 +150,23 @@ class BGPConfigManager(object):
return
ip_addr = ip_addr_w_mask[:slash_pos]
try:
if TemplateFabric.is_ipv4(ip_addr) and self.lo_ipv4 is None:
self.lo_ipv4 = ip_addr
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC", lo_ip=ip_addr, ip_proto="")
elif TemplateFabric.is_ipv6(ip_addr) and self.lo_ipv6 is None:
self.lo_ipv6 = ip_addr
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC6", lo_ip=ip_addr, ip_proto="v6")
if TemplateFabric.is_ipv4(ip_addr):
if self.lo_ipv4 is None:
self.lo_ipv4 = ip_addr
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC", lo_ip=ip_addr, ip_proto="")
else:
syslog.syslog(syslog.LOG_INFO, "Update command is not supported for set src templates. lo_ip='%s'" % ip_addr)
return
elif TemplateFabric.is_ipv6(ip_addr):
if self.lo_ipv6 is None:
self.lo_ipv6 = ip_addr
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC6", lo_ip=ip_addr, ip_proto="v6")
else:
syslog.syslog(syslog.LOG_INFO, "Update command is not supported for set src templates. lo_ip='%s'" % ip_addr)
return
else:
syslog.syslog(syslog.LOG_ERR, "Got ambigous ip addres '%s'" % ip_addr)
syslog.syslog(syslog.LOG_ERR, "Got ambiguous ip address '%s'" % ip_addr)
return
except:
syslog.syslog(syslog.LOG_ERR, "Error while rendering set src template '%s'" % ip_addr)
else: