Skip to content

Commit ff68832

Browse files
[route_check] fix IPv6 address handling (#2722)
*In case user has configured an IPv6 address on an interface in CONFIG DB in non simplified form like 2000:31:0:0::1/64 it is present in a simplified form in ASIC_DB. This leads to route_check failure since it just compares strings.
1 parent 7a604c5 commit ff68832

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

scripts/route_check.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import traceback
4848
import subprocess
4949

50+
from ipaddress import ip_network
5051
from swsscommon import swsscommon
5152
from utilities_common import chassis
5253

@@ -145,7 +146,7 @@ def add_prefix(ip):
145146
ip = ip + PREFIX_SEPARATOR + "32"
146147
else:
147148
ip = ip + PREFIX_SEPARATOR + "128"
148-
return ip
149+
return str(ip_network(ip))
149150

150151

151152
def add_prefix_ifnot(ip):
@@ -154,7 +155,7 @@ def add_prefix_ifnot(ip):
154155
:param ip: IP to add prefix as string.
155156
:return ip with prefix
156157
"""
157-
return ip if ip.find(PREFIX_SEPARATOR) != -1 else add_prefix(ip)
158+
return str(ip_network(ip)) if ip.find(PREFIX_SEPARATOR) != -1 else add_prefix(ip)
158159

159160

160161
def is_local(ip):

tests/route_check_test_data.py

+18
Original file line numberDiff line numberDiff line change
@@ -462,4 +462,22 @@
462462
},
463463
RET: -1,
464464
},
465+
"10": {
466+
DESCR: "basic good one with IPv6 address",
467+
ARGS: "route_check -m INFO -i 1000",
468+
PRE: {
469+
APPL_DB: {
470+
ROUTE_TABLE: {
471+
},
472+
INTF_TABLE: {
473+
"PortChannel1013:2000:31:0:0::1/64": {},
474+
}
475+
},
476+
ASIC_DB: {
477+
RT_ENTRY_TABLE: {
478+
RT_ENTRY_KEY_PREFIX + "2000:31::1/128" + RT_ENTRY_KEY_SUFFIX: {},
479+
}
480+
}
481+
}
482+
},
465483
}

0 commit comments

Comments
 (0)