Skip to content

Commit e22de3a

Browse files
[bgpcfgd]: Clarify error messages on reset Loopback0 ip address (#5062)
To clarify error messages in case the ip address for Loopback is already set. It doesn't make sense to call correct ip address as ambiguous in this case
1 parent 70d1e0c commit e22de3a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/sonic-bgpcfgd/bgpcfgd

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,16 +787,24 @@ class ZebraSetSrc(Manager):
787787
ip_addr_w_mask = key.replace("Loopback0|", "")
788788
slash_pos = ip_addr_w_mask.rfind("/")
789789
if slash_pos == -1:
790-
log_err("Wrong Loopback0 ip address: '%s'" % ip_addr_w_mask)
790+
log_err("Wrong Loopback0 ip prefix: '%s'" % ip_addr_w_mask)
791791
return True
792792
ip_addr = ip_addr_w_mask[:slash_pos]
793793
try:
794-
if TemplateFabric.is_ipv4(ip_addr) and self.lo_ipv4 is None:
795-
self.lo_ipv4 = ip_addr
796-
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC", lo_ip=ip_addr, ip_proto="")
797-
elif TemplateFabric.is_ipv6(ip_addr) and self.lo_ipv6 is None:
798-
self.lo_ipv6 = ip_addr
799-
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC6", lo_ip=ip_addr, ip_proto="v6")
794+
if TemplateFabric.is_ipv4(ip_addr):
795+
if self.lo_ipv4 is None:
796+
self.lo_ipv4 = ip_addr
797+
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC", lo_ip=ip_addr, ip_proto="")
798+
else:
799+
log_warn("Update command is not supported for set src templates. current ip='%s'. new ip='%s'" % (self.lo_ipv4, ip_addr))
800+
return True
801+
elif TemplateFabric.is_ipv6(ip_addr):
802+
if self.lo_ipv6 is None:
803+
self.lo_ipv6 = ip_addr
804+
txt = self.zebra_set_src_template.render(rm_name="RM_SET_SRC6", lo_ip=ip_addr, ip_proto="v6")
805+
else:
806+
log_warn("Update command is not supported for set src templates. current ip='%s'. new ip='%s'" % (self.lo_ipv6, ip_addr))
807+
return True
800808
else:
801809
log_err("Got ambiguous ip address '%s'" % ip_addr)
802810
return True

0 commit comments

Comments
 (0)