Add address.get_canonical() and is_canonical()
These functions will take either an IPv4/IPv6 address, or an IPv4/IPv6 prefix, and cast them to their canonical form. Notably for IPv6 addresses, this means lower case and with the 0-tuples correctly formatted: 2001:DB8::1 becomes 2001:db8::1 2001:db8:0:0::1 becomes 2001:db8::1 This avoids spurious diffs in vppcfg when comparing to the output of the VPP dataplane.
This commit is contained in:
@ -83,6 +83,12 @@ def validate_loopbacks(yaml):
|
||||
f"loopback {ifname} IP address {addr} conflicts with another"
|
||||
)
|
||||
result = False
|
||||
if not address.is_canonical(addr):
|
||||
canonical = address.get_canonical(addr)
|
||||
msgs.append(
|
||||
f"loopback {ifname} IP address {addr} is not canonical, use {canonical}"
|
||||
)
|
||||
result = False
|
||||
if "mac" in iface and mac.is_multicast(iface["mac"]):
|
||||
msgs.append(
|
||||
f"loopback {ifname} MAC address {iface['mac']} cannot be multicast"
|
||||
|
Reference in New Issue
Block a user