net: dhcp: Avoid source port validation in replies

There's nothing in RFC 2131 or RFC 8415 that would mandate the DHCP
server to reply with a source port set to the IANA assigned one, and
some servers seem to send responses with some arbitrary source port set.

Therefore, make Zephyr's DHCP client implementation more permissive,
accepting packets with a source port set to a different port than the
IANA assigned server port.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2025-02-10 13:16:55 +01:00 committed by Benjamin Cabé
commit d0e5696a0e
2 changed files with 2 additions and 3 deletions

View file

@ -1885,8 +1885,7 @@ int net_dhcpv4_init(void)
* all dhcpv4 related incoming packets.
*/
ret = net_udp_register(AF_INET, NULL, &local_addr,
DHCPV4_SERVER_PORT,
DHCPV4_CLIENT_PORT,
0, DHCPV4_CLIENT_PORT,
NULL, net_dhcpv4_input, NULL, NULL);
if (ret < 0) {
NET_DBG("UDP callback registration failed");

View file

@ -2222,7 +2222,7 @@ int net_dhcpv6_init(void)
unspec_addr.sa_family = AF_INET6;
ret = net_udp_register(AF_INET6, NULL, &unspec_addr,
DHCPV6_SERVER_PORT, DHCPV6_CLIENT_PORT,
0, DHCPV6_CLIENT_PORT,
NULL, dhcpv6_input, NULL, NULL);
if (ret < 0) {
NET_DBG("UDP callback registration failed");