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:
Miroslav Lichvar
2020-06-30 16:13:48 +02:00
parent 99e3c67a81
commit 4e747da4b4
4 changed files with 28 additions and 4 deletions

View File

@@ -301,8 +301,10 @@ transmit_reply(int sock_fd, SCK_Message *message)
{
message->length = PKL_ReplyLength((CMD_Reply *)message->data);
/* Don't require the response to use the same interface */
message->if_index = INVALID_IF_INDEX;
/* Don't require responses to non-link-local addresses to use the same
interface */
if (!SCK_IsLinkLocalIPAddress(&message->remote_addr.ip.ip_addr))
message->if_index = INVALID_IF_INDEX;
if (!SCK_SendMessage(sock_fd, message, 0))
return;