Fix to prevent truncating IPv6 value when NTP alarm is triggered.

This fix is to allow the validation of IPv6 when ntpq command
output returns a invalid IPv6 format. In some cases the
truncated IPv6 only ends with single colon, internally the
a method is invoked to validate the IP family corresponding
to that format and since it is not a valid format, it fails.
This behavior causes the returned IP to always be a truncated IP.

The logic is corrected to validate only when the IP is version 4
only.

Test Plan:

PASS: Configure NTP with unreachable IPv6 peers to trigger the
NTP alarm
PASS: Configure NTP with reachable IPv6 peers to avoid alarms
PASS: Configure NTP with unreachable IPv4 peers to trigger the
NTP alarm
PASS: Configure NTP with reachable IPv4 peers to avoid alarms

Closes-Bug: 2004043

Review Ref: https://review.opendev.org/c/starlingx/monitoring/+/872036
Change-Id: I8b5b0080a4714cc864a4bdd0a7e8ad558e18adfa
Signed-off-by: Cristian Mondo <cristian.mondo@windriver.com>
This commit is contained in:
Cristian Mondo 2023-04-20 14:45:53 -03:00
parent f26bbf8842
commit 99c893e966

View File

@ -724,7 +724,7 @@ def _get_assoc_srcadr(assoc_id, ip):
srcadr = ''
# IPv4 no further processing required, returns same IP value
if assoc_id < 1 or socket.AF_INET6 != _is_ip_address(ip):
if assoc_id < 1 or socket.AF_INET == _is_ip_address(ip):
return ip
# Do NTP Query to retrieve assoc information