From 99c893e966b6f1fd0018107e8aa07efa4a71866d Mon Sep 17 00:00:00 2001 From: Cristian Mondo Date: Thu, 20 Apr 2023 14:45:53 -0300 Subject: [PATCH] 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 --- collectd-extensions/src/ntpq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collectd-extensions/src/ntpq.py b/collectd-extensions/src/ntpq.py index e352b20..c752eb4 100755 --- a/collectd-extensions/src/ntpq.py +++ b/collectd-extensions/src/ntpq.py @@ -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