socket: don't set interface for sent packets

With asymmetric routing (e.g. with BGP) it may not be possible to
respond to a request using the same interface. In such case, setting the
interface index in IP*_PKTINFO* causes the packet to be silently dropped
by the kernel.

Until we can predict if sending with the specified interface will
succeed, or provide only a hint, don't set the interface and leave it
to the kernel to select an interface.

This reverts commit 5fc7674e36 ("ntp: set interface index in
IP*_PKTINFO when responding").

Reported-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
This commit is contained in:
Miroslav Lichvar 2020-05-11 12:27:34 +02:00
parent 814b07c3a2
commit e49aececce

View file

@ -1020,8 +1020,6 @@ send_message(int sock_fd, SCK_Message *message, int flags)
return 0;
ipi->ipi_spec_dst.s_addr = htonl(message->local_addr.ip.addr.in4);
if (message->if_index != INVALID_IF_INDEX)
ipi->ipi_ifindex = message->if_index;
#elif defined(IP_SENDSRCADDR)
struct in_addr *addr;
@ -1046,8 +1044,6 @@ send_message(int sock_fd, SCK_Message *message, int flags)
memcpy(&ipi->ipi6_addr.s6_addr, &message->local_addr.ip.addr.in6,
sizeof(ipi->ipi6_addr.s6_addr));
if (message->if_index != INVALID_IF_INDEX)
ipi->ipi6_ifindex = message->if_index;
}
#endif
}