]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
nts: follow bind*device settings for NTS-KE sockets
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 13 Jul 2020 12:16:42 +0000 (14:16 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 16 Jul 2020 10:07:35 +0000 (12:07 +0200)
Bind the server and client NTS-KE sockets to the specified device.

nts_ke_client.c
nts_ke_server.c

index 967e0147d7ec4acdd468c83a545596cc4215b7b2..5b5441ea8ba77b17285157ba5e531144e0297d3b 100644 (file)
@@ -308,7 +308,7 @@ int
 NKC_Start(NKC_Instance inst)
 {
   IPSockAddr local_addr;
-  char label[512];
+  char label[512], *iface;
   int sock_fd;
 
   assert(!NKC_IsActive(inst));
@@ -318,14 +318,15 @@ NKC_Start(NKC_Instance inst)
     return 0;
   }
 
-  /* Follow the bindacqaddress setting */
+  /* Follow the bindacqaddress and bindacqdevice settings */
   CNF_GetBindAcquisitionAddress(inst->address.ip_addr.family, &local_addr.ip_addr);
   if (local_addr.ip_addr.family != inst->address.ip_addr.family)
     SCK_GetAnyLocalIPAddress(inst->address.ip_addr.family, &local_addr.ip_addr);
 
   local_addr.port = 0;
+  iface = CNF_GetBindAcquisitionInterface();
 
-  sock_fd = SCK_OpenTcpSocket(&inst->address, &local_addr, NULL, 0);
+  sock_fd = SCK_OpenTcpSocket(&inst->address, &local_addr, iface, 0);
   if (sock_fd < 0)
     return 0;
 
index 2b94b9bca69dc45c4b1a2f85eab2983df0aea534..7dc6d704573775452b21366b763887b75cc0c8d5 100644 (file)
@@ -256,19 +256,21 @@ static int
 open_socket(int family, int port)
 {
   IPSockAddr local_addr;
+  char *iface;
   int sock_fd;
 
   if (!SCK_IsIpFamilyEnabled(family))
     return INVALID_SOCK_FD;
 
   CNF_GetBindAddress(family, &local_addr.ip_addr);
+  iface = CNF_GetBindNtpInterface();
 
   if (local_addr.ip_addr.family != family)
     SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr);
 
   local_addr.port = port;
 
-  sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, NULL, 0);
+  sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, iface, 0);
   if (sock_fd < 0) {
     LOG(LOGS_ERR, "Could not open NTS-KE socket on %s", UTI_IPSockAddrToString(&local_addr));
     return INVALID_SOCK_FD;