]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: add function to change authentication-specific address
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 4 Feb 2020 10:50:29 +0000 (11:50 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Mar 2020 15:02:15 +0000 (16:02 +0100)
When an NTS source will be replaced, the authentication-specific address
of the NTS-KE server will need to be changed too.

ntp_auth.c
ntp_auth.h
ntp_core.c

index 43f4483a18277fa92e48d19ebeabb5ab902aee5f..4f9915440b0ca261044c6e4e721497f32579355a 100644 (file)
@@ -422,3 +422,17 @@ NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response, NTP_PacketInf
 
   return 1;
 }
+
+/* ================================================== */
+
+void
+NAU_ChangeAddress(NAU_Instance instance, IPAddr *address)
+{
+  switch (instance->mode) {
+    case NTP_AUTH_NONE:
+    case NTP_AUTH_SYMMETRIC:
+      break;
+    default:
+      assert(0);
+  }
+}
index a0326142d383d20ed07d36ab6dbe1e5c86c894e7..8211c631bf8d5c0fcb7e0964a5b4cd5d33e25d28 100644 (file)
@@ -81,4 +81,7 @@ extern int NAU_GenerateResponseAuth(NTP_Packet *request, NTP_PacketInfo *request
 extern int NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response,
                                  NTP_PacketInfo *info);
 
+/* Change an authentication-specific address (e.g. after replacing a source) */
+extern void NAU_ChangeAddress(NAU_Instance instance, IPAddr *address);
+
 #endif
index 9ce0426b3160c70e50a1c530cb128f909a4c9673..ab7d503eec75c1fbaff58468dae7280f69caaa83 100644 (file)
@@ -710,6 +710,9 @@ NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr, int
   SRC_SetRefid(inst->source, UTI_IPToRefid(&remote_addr->ip_addr),
                &inst->remote_addr.ip_addr);
   SRC_ResetInstance(inst->source);
+
+  if (!ntp_only)
+    NAU_ChangeAddress(inst->auth, &remote_addr->ip_addr);
 }
 
 /* ================================================== */