]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: pass server name to ntp_core instances
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 13 Mar 2019 16:32:40 +0000 (17:32 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Mar 2020 15:02:15 +0000 (16:02 +0100)
The server name will be needed for certificate verification in NTS-KE.

ntp_core.c
ntp_core.h
ntp_sources.c
test/unit/ntp_core.c

index ab7d503eec75c1fbaff58468dae7280f69caaa83..3dde71fa1105ae77628137cdf2b1e6ad3bb21bb7 100644 (file)
@@ -504,7 +504,8 @@ take_offline(NCR_Instance inst)
 /* ================================================== */
 
 NCR_Instance
-NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourceParameters *params)
+NCR_CreateInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
+                   SourceParameters *params, const char *name)
 {
   NCR_Instance result;
 
index 78b6ede1472503fd9b2c93dcd9075c6d7375d478..d675547a4c87b2c721b7c54830212b747ace87b4 100644 (file)
@@ -59,7 +59,8 @@ extern void NCR_Initialise(void);
 extern void NCR_Finalise(void);
 
 /* Get a new instance for a server or peer */
-extern NCR_Instance NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourceParameters *params);
+extern NCR_Instance NCR_CreateInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
+                                       SourceParameters *params, const char *name);
 
 /* Destroy an instance */
 extern void NCR_DestroyInstance(NCR_Instance instance);
index 2b1240c3cf9406948eaab6ba5bf8e1d4272aa84e..995da1b988f0f886a4fdc5e56b3dda20355ff8a1 100644 (file)
@@ -320,7 +320,7 @@ add_source(NTP_Remote_Address *remote_addr, char *name, NTP_Source_Type type, So
 
       assert(!found);
       record = get_record(slot);
-      record->data = NCR_GetInstance(remote_addr, type, params);
+      record->data = NCR_CreateInstance(remote_addr, type, params, name);
       record->remote_addr = NCR_GetRemoteAddress(record->data);
       record->name = name ? Strdup(name) : NULL;
       record->pool = pool;
index d3965cdd814cd724d1b00ab3aa227e3ec5ff441e..9a92ded28df6289f07c4741f2ce13ec181702ab6 100644 (file)
@@ -345,7 +345,8 @@ test_unit(void)
     TST_GetRandomAddress(&remote_addr.ip_addr, IPADDR_UNSPEC, -1);
     remote_addr.port = 123;
 
-    inst1 = NCR_GetInstance(&remote_addr, random() % 2 ? NTP_SERVER : NTP_PEER, &source.params);
+    inst1 = NCR_CreateInstance(&remote_addr, random() % 2 ? NTP_SERVER : NTP_PEER,
+                               &source.params, NULL);
     NCR_StartInstance(inst1);
     has_updated = 0;
 
@@ -400,7 +401,8 @@ test_unit(void)
 
     NCR_DestroyInstance(inst1);
 
-    inst1 = NCR_GetInstance(&remote_addr, random() % 2 ? NTP_SERVER : NTP_PEER, &source.params);
+    inst1 = NCR_CreateInstance(&remote_addr, random() % 2 ? NTP_SERVER : NTP_PEER,
+                               &source.params, NULL);
     NCR_StartInstance(inst1);
 
     for (j = 0; j < 20; j++) {
@@ -414,9 +416,9 @@ test_unit(void)
 
     NCR_DestroyInstance(inst1);
 
-    inst1 = NCR_GetInstance(&remote_addr, NTP_PEER, &source.params);
+    inst1 = NCR_CreateInstance(&remote_addr, NTP_PEER, &source.params, NULL);
     NCR_StartInstance(inst1);
-    inst2 = NCR_GetInstance(&remote_addr, NTP_PEER, &source.params);
+    inst2 = NCR_CreateInstance(&remote_addr, NTP_PEER, &source.params, NULL);
     NCR_StartInstance(inst2);
 
     res_length = req_length = 0;