From 42252a58e7396370a32444339f409a8c4635d232 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 24 Mar 2025 10:57:41 +0100 Subject: [PATCH] busybox: the DHCP client would sometimes send a superflous port unreachable frame Signed-off-by: John Crispin --- .../patches/600-dhcp-port-unreachable.patch | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 package/utils/busybox/patches/600-dhcp-port-unreachable.patch diff --git a/package/utils/busybox/patches/600-dhcp-port-unreachable.patch b/package/utils/busybox/patches/600-dhcp-port-unreachable.patch new file mode 100644 index 0000000000..2055f9750a --- /dev/null +++ b/package/utils/busybox/patches/600-dhcp-port-unreachable.patch @@ -0,0 +1,49 @@ +diff --git a/package/utils/busybox/patches/202-udhcpc_reuseport.patch b/package/utils/busybox/patches/202-udhcpc_reuseport.patch +new file mode 100644 +index 000000000000..d91d58397ee9 +--- /dev/null ++++ b/package/utils/busybox/patches/202-udhcpc_reuseport.patch +@@ -0,0 +1,43 @@ ++--- a/libbb/xconnect.c +++++ b/libbb/xconnect.c ++@@ -37,6 +37,10 @@ void FAST_FUNC setsockopt_reuseaddr(int ++ { ++ setsockopt_SOL_SOCKET_1(fd, SO_REUSEADDR); ++ } +++int FAST_FUNC setsockopt_reuseport(int fd) +++{ +++ return setsockopt_SOL_SOCKET_1(fd, SO_REUSEPORT); +++} ++ int FAST_FUNC setsockopt_broadcast(int fd) ++ { ++ return setsockopt_SOL_SOCKET_1(fd, SO_BROADCAST); ++--- a/include/libbb.h +++++ b/include/libbb.h ++@@ -734,6 +734,7 @@ int setsockopt_SOL_SOCKET_1(int fd, int ++ * regardless of SO_REUSEADDR (unlike some other flavors of Unix). ++ * Turn it on before you call bind(). */ ++ void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */ +++int setsockopt_reuseport(int fd) FAST_FUNC; ++ int setsockopt_keepalive(int fd) FAST_FUNC; ++ int setsockopt_broadcast(int fd) FAST_FUNC; ++ int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC; ++--- a/networking/udhcp/packet.c +++++ b/networking/udhcp/packet.c ++@@ -206,6 +206,7 @@ int FAST_FUNC udhcp_send_kernel_packet(s ++ goto ret_msg; ++ } ++ setsockopt_reuseaddr(fd); +++ setsockopt_reuseport(fd); ++ ++ /* If interface carrier goes down, unless we ++ * bind socket to a particular netdev, the packet ++--- a/networking/udhcp/socket.c +++++ b/networking/udhcp/socket.c ++@@ -86,6 +86,7 @@ int FAST_FUNC udhcp_listen_socket(/*uint ++ fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); ++ ++ setsockopt_reuseaddr(fd); +++ setsockopt_reuseport(fd); ++ if (setsockopt_broadcast(fd) == -1) ++ bb_simple_perror_msg_and_die("SO_BROADCAST"); ++ -- 2.34.1