From 364f80184de4bada2db49ab904c17bfa7b7fa9c8 Mon Sep 17 00:00:00 2001 From: Roman Penyaev Date: Thu, 6 Jun 2024 14:23:42 +0200 Subject: [PATCH] Introduce new ZInfoNTPSource message in `proto/info/ntpsource.proto` This will be published from EVE. Signed-off-by: Roman Penyaev --- proto/info/info.proto | 3 ++ proto/info/ntpsources.proto | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 proto/info/ntpsources.proto diff --git a/proto/info/info.proto b/proto/info/info.proto index cbc892b9..4d7888d8 100644 --- a/proto/info/info.proto +++ b/proto/info/info.proto @@ -11,6 +11,7 @@ import "google/protobuf/timestamp.proto"; import "evecommon/devmodelcommon.proto"; import "evecommon/evecommon.proto"; import "info/patch_envelope.proto"; +import "info/ntpsources.proto"; // Deprecated: see deprecatedMetricItem below enum DepMetricItemType { @@ -67,6 +68,7 @@ enum ZInfoTypes { ZiEdgeview = 12; ZiLocation = 13; ZiPatchEnvelope = 14; + ZiNTPSources = 16; } // Information about assignable I/O adapter bundles @@ -1181,6 +1183,7 @@ message ZInfoMsg { ZInfoPatchEnvelope patchInfo = 20; // 21 reserved ZInfoClusterNode cluster_node = 22; + ZInfoNTPSources ntp_sources = 23; } google.protobuf.Timestamp atTimeStamp = 6; } diff --git a/proto/info/ntpsources.proto b/proto/info/ntpsources.proto new file mode 100644 index 00000000..8abc8aec --- /dev/null +++ b/proto/info/ntpsources.proto @@ -0,0 +1,74 @@ +// Copyright(c) 2024 Zededa, Inc. +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +import "google/protobuf/timestamp.proto"; + +package org.lfedge.eve.info; +option go_package = "github.com/lf-edge/eve-api/go/info"; + +option java_package = "org.lfedge.eve.info"; + +// Enum for describing the NTP source state +enum NTPSourceState { + NTP_SOURCE_STATE_SYNC = 0; + NTP_SOURCE_STATE_UNREACH = 1; + NTP_SOURCE_STATE_FALSETICKER = 2; + NTP_SOURCE_STATE_JITTERY = 3; + NTP_SOURCE_STATE_CANDIDATE = 4; + NTP_SOURCE_STATE_OUTLIER = 5; +} + +// Enum for describing the NTP source mode +enum NTPSourceMode { + NTP_SOURCE_MODE_CLIENT = 0; + NTP_SOURCE_MODE_PEER = 1; // ntp + NTP_SOURCE_MODE_REF = 2; // local +} + +// Flags from RFC 5905 + defined by chrony +enum NTPSourceBitmap { + NTP_SOURCE_BITMAP_UNSPECIFIED = 0x0000; + NTP_SOURCE_BITMAP_PKT_DUP = 0x0001; + NTP_SOURCE_BITMAP_PKT_BOGUS = 0x0002; + NTP_SOURCE_BITMAP_PKT_INVALID = 0x0004; + NTP_SOURCE_BITMAP_PKT_AUTH = 0x0008; + NTP_SOURCE_BITMAP_PKT_STRATUM = 0x0010; + NTP_SOURCE_BITMAP_PKT_HEADER = 0x0020; + NTP_SOURCE_BITMAP_TST_MAX_DELAY = 0x0040; + NTP_SOURCE_BITMAP_TST_DELAY_RATIO = 0x0080; + NTP_SOURCE_BITMAP_TST_DELAY_DEV_RATION = 0x0100; + NTP_SOURCE_BITMAP_TST_SYNC_LOOP = 0x0200; +} + +// As described in http://doc.ntp.org/current-stable/ntpq.html +message NTPSource { + bool authenticated = 1; + bool reachable = 2; // (reachability == 0xff), i.e. 8 attempts + uint32 reachability = 3; + NTPSourceState state = 4; + NTPSourceMode mode = 5; + string hostname = 6; + string src_addr = 7; + uint32 src_port = 8; + string dst_addr = 9; + uint32 dst_port = 10; + uint32 leap = 11; + uint32 stratum = 12; + uint32 precision = 13; + string ref_id = 14; + google.protobuf.Timestamp ref_time = 15; + sint32 poll = 16; + uint32 flags = 17; // bitmap from NTPSourceBitmap + double offset = 18; + double delay = 19; + double dispersion = 20; + double jitter = 21; + double root_delay = 22; + double root_disp = 23; +} + +message ZInfoNTPSources { + repeated NTPSource sources = 1; +}