ntp: set interface index in IP*_PKTINFO when responding
When a server with multiple interfaces in the same network is sending a response, setting the ipi_spec_dst/ipi6_addr field of the IP*_PKTINFO control message selects the source address, but not necessarily the interface. The packet has the expected source address, but it may be sent by an interface that doesn't have the address. Set the ipi_ifindex/ipi6_ifindex field to respond on the same interface as the request was received from to avoid asymmetries in delay and timestamping.
This commit is contained in:
parent
018977044a
commit
5fc7674e36
1 changed files with 4 additions and 0 deletions
4
ntp_io.c
4
ntp_io.c
|
@ -827,6 +827,8 @@ NIO_SendPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr,
|
|||
|
||||
ipi = (struct in_pktinfo *) CMSG_DATA(cmsg);
|
||||
ipi->ipi_spec_dst.s_addr = htonl(local_addr->ip_addr.addr.in4);
|
||||
if (local_addr->if_index != INVALID_IF_INDEX)
|
||||
ipi->ipi_ifindex = local_addr->if_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -845,6 +847,8 @@ NIO_SendPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr,
|
|||
ipi = (struct in6_pktinfo *) CMSG_DATA(cmsg);
|
||||
memcpy(&ipi->ipi6_addr.s6_addr, &local_addr->ip_addr.addr.in6,
|
||||
sizeof(ipi->ipi6_addr.s6_addr));
|
||||
if (local_addr->if_index != INVALID_IF_INDEX)
|
||||
ipi->ipi6_ifindex = local_addr->if_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue