mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-06 12:15:07 -05:00
ntp+cmdmon: fix responding to link-local addresses
After commit e49aececce ("socket: don't set interface for sent
packets") the NTP and cmdmon server stopped responding to requests from
link-local addresses.
Set the interface specifically for packets sent to a link-local address.
This commit is contained in:
17
socket.c
17
socket.c
@@ -1228,6 +1228,23 @@ SCK_GetLoopbackIPAddress(int family, IPAddr *local_addr)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
int
|
||||
SCK_IsLinkLocalIPAddress(IPAddr *addr)
|
||||
{
|
||||
switch (addr->family) {
|
||||
case IPADDR_INET4:
|
||||
/* 169.254.0.0/16 */
|
||||
return (addr->addr.in4 & 0xffff0000) == 0xa9fe0000;
|
||||
case IPADDR_INET6:
|
||||
/* fe80::/10 */
|
||||
return addr->addr.in6[0] == 0xfe && (addr->addr.in6[1] & 0xc0) == 0x80;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
SCK_SetPrivBind(int (*function)(int sock_fd, struct sockaddr *address,
|
||||
socklen_t address_len))
|
||||
|
||||
Reference in New Issue
Block a user