Re: [chrony-dev] Chrony 1.30-pre1 fails on FreeBSD 10 |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
On Wed, Jun 25, 2014 at 02:08:03PM +0200, Adri Koppes wrote:
> Chrony 1.29 was working without problems on FreeBSD 10.
> The new 1.30pre1 doesn't work at all, getting no samples from remove ntp
> servers.
> When I start 'chronyd -d -d', it seems there is a problem transmitting
> packets.
> 2014-06-25T11:57:23Z ntp_io.c:678:(send_packet) Could not send to
> 193.0.0.229:123 : Socket is already connected
Thanks for the report. I'm glad to see someone is testing chrony on
other systems than Linux.
It seems the Linux kernel ignores the address specified for sendmsg()
when the socket is connected, but on FreeBSD it returns with error.
Can you please try it with the attached patch?
--
Miroslav Lichvar
commit 9c6d1c214fbc11e233324f476426d399f69642f6
Author: Miroslav Lichvar <mlichvar@xxxxxxxxxx>
Date: Wed Jun 25 15:36:14 2014 +0200
ntp: don't set address for sendmsg() with connected sockets
diff --git a/ntp_io.c b/ntp_io.c
index 2473751..749261c 100644
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -583,12 +583,21 @@ send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr, NTP_Lo
struct iovec iov;
char cmsgbuf[256];
int cmsglen;
- socklen_t addrlen;
+ socklen_t addrlen = 0;
assert(initialised);
+ if (local_addr->sock_fd == INVALID_SOCK_FD) {
+ DEBUG_LOG(LOGF_NtpIO, "No socket to send to %s:%d",
+ UTI_IPToString(&remote_addr->ip_addr), remote_addr->port);
+ return;
+ }
+
switch (remote_addr->ip_addr.family) {
case IPADDR_INET4:
+ /* Don't set address with connected socket */
+ if (local_addr->sock_fd != server_sock_fd4 && separate_client_sockets)
+ break;
memset(&remote.in4, 0, sizeof (remote.in4));
addrlen = sizeof (remote.in4);
remote.in4.sin_family = AF_INET;
@@ -597,6 +606,9 @@ send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr, NTP_Lo
break;
#ifdef HAVE_IPV6
case IPADDR_INET6:
+ /* Don't set address with connected socket */
+ if (local_addr->sock_fd != server_sock_fd6 && separate_client_sockets)
+ break;
memset(&remote.in6, 0, sizeof (remote.in6));
addrlen = sizeof (remote.in6);
remote.in6.sin6_family = AF_INET6;
@@ -609,16 +621,16 @@ send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr, NTP_Lo
return;
}
- if (local_addr->sock_fd == INVALID_SOCK_FD) {
- DEBUG_LOG(LOGF_NtpIO, "No socket to send to %s:%d",
- UTI_IPToString(&remote_addr->ip_addr), remote_addr->port);
- return;
+ if (addrlen) {
+ msg.msg_name = &remote.u;
+ msg.msg_namelen = addrlen;
+ } else {
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
}
iov.iov_base = packet;
iov.iov_len = packetlen;
- msg.msg_name = &remote.u;
- msg.msg_namelen = addrlen;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = cmsgbuf;