Skip to content

Commit

Permalink
Merge pull request sonic-net#66 from chenkelly/202311.X
Browse files Browse the repository at this point in the history
fix non canonical format of IPv6 address string in bgpcfgd
  • Loading branch information
gord1306 authored Jul 11, 2024
2 parents 1840e8e + ff481bb commit 33c7306
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ def get_local_interface(self, local_addr):
If the interface has not been set, return None
"""
local_addresses = self.directory.get_slot("LOCAL", "local_addresses")

# Handle local_addr string that is not represented in canonical text format, especially for IPv6 addresses
try:
ip = netaddr.IPAddress(str(local_addr))
except (netaddr.NotRegisteredError, netaddr.AddrFormatError, netaddr.AddrConversionError):
log_warn("IP Address '%s' format is wrong" % (local_addr))
return None
local_addr = str(ip)

# Check if the local address of this bgp session has been set
if local_addr not in local_addresses:
return None
Expand Down

0 comments on commit 33c7306

Please sign in to comment.