Fix DHCPv6 relay to use a more sensble source address.

Tweak things so that packets relayed towards a server
have source address on the server-facing network, not the
client-facing network. Thanks to Luis Thomas for spotting this
and initial patch.
This commit is contained in:
Simon Kelley
2022-09-06 15:40:42 +01:00
parent d6c69f6bdb
commit 84a6d07cdd
2 changed files with 10 additions and 15 deletions

View File

@@ -79,6 +79,11 @@ version 2.87
This would return <ip> for queries in some.domain, rather than This would return <ip> for queries in some.domain, rather than
forwarding the query via the default server. forwarding the query via the default server.
Tweak DHCPv6 relay code so that packets relayed towards a server
have source address on the server-facing network, not the
client facing network. Thanks to Luis Thomas for spotting this
and initial patch.
version 2.86 version 2.86
Handle DHCPREBIND requests in the DHCPv6 server code. Handle DHCPREBIND requests in the DHCPv6 server code.

View File

@@ -2181,10 +2181,7 @@ int relay_upstream6(int iface_index, ssize_t sz,
if (relay->iface_index != 0 && relay->iface_index == iface_index) if (relay->iface_index != 0 && relay->iface_index == iface_index)
{ {
union mysockaddr to; union mysockaddr to;
union all_addr from;
/* source address == relay address */
from.addr6 = relay->local.addr6;
memcpy(&header[2], &relay->local.addr6, IN6ADDRSZ); memcpy(&header[2], &relay->local.addr6, IN6ADDRSZ);
to.sa.sa_family = AF_INET6; to.sa.sa_family = AF_INET6;
@@ -2206,18 +2203,11 @@ int relay_upstream6(int iface_index, ssize_t sz,
} }
#ifdef HAVE_DUMPFILE #ifdef HAVE_DUMPFILE
{ dump_packet_udp(DUMP_DHCPV6, (void *)daemon->outpacket.iov_base, save_counter(-1), NULL, &to, daemon->dhcp6fd);
union mysockaddr fromsock;
fromsock.in6.sin6_port = htons(DHCPV6_SERVER_PORT);
fromsock.in6.sin6_addr = from.addr6;
fromsock.sa.sa_family = AF_INET6;
fromsock.in6.sin6_flowinfo = 0;
fromsock.in6.sin6_scope_id = 0;
dump_packet_udp(DUMP_DHCPV6, (void *)daemon->outpacket.iov_base, save_counter(-1), &fromsock, &to, -1);
}
#endif #endif
send_from(daemon->dhcp6fd, 0, daemon->outpacket.iov_base, save_counter(-1), &to, &from, 0);
while (retry_send(sendto(daemon->dhcp6fd, (void *)daemon->outpacket.iov_base, save_counter(-1),
0, (struct sockaddr *)&to, sa_len(&to))));
if (option_bool(OPT_LOG_OPTS)) if (option_bool(OPT_LOG_OPTS))
{ {