ntp: enable PKTINFO on client sockets
This will be useful to detect synchronization loops.
This commit is contained in:
parent
2f738d5805
commit
15d8c08eaa
1 changed files with 8 additions and 11 deletions
5
ntp_io.c
5
ntp_io.c
|
@ -174,8 +174,7 @@ prepare_socket(int family, int port_number, int client_only)
|
||||||
if (family == AF_INET) {
|
if (family == AF_INET) {
|
||||||
#ifdef IP_PKTINFO
|
#ifdef IP_PKTINFO
|
||||||
/* We want the local IP info on server sockets */
|
/* We want the local IP info on server sockets */
|
||||||
if (!client_only &&
|
if (setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
||||||
setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set packet info socket option");
|
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set packet info socket option");
|
||||||
/* Don't quit - we might survive anyway */
|
/* Don't quit - we might survive anyway */
|
||||||
}
|
}
|
||||||
|
@ -190,7 +189,6 @@ prepare_socket(int family, int port_number, int client_only)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!client_only) {
|
|
||||||
#ifdef IPV6_RECVPKTINFO
|
#ifdef IPV6_RECVPKTINFO
|
||||||
if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option");
|
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option");
|
||||||
|
@ -201,7 +199,6 @@ prepare_socket(int family, int port_number, int client_only)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Bind the socket if a port or address was specified */
|
/* Bind the socket if a port or address was specified */
|
||||||
|
|
Loading…
Reference in a new issue