aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorMichal Kazior <michal@plume.com>2020-12-15 09:53:40 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-15 21:44:21 +0100
commitb817699e6c5c8efe4fce45e910d66133c9d8c482 (patch)
treeea4ad25a0ca09d8b5e1e7853bc52b85d94bf64bf /networking/udhcp/dhcpd.c
parent01004f9796fd7a5223a40802026d2023e3f9cf28 (diff)
downloadbusybox-b817699e6c5c8efe4fce45e910d66133c9d8c482.tar.gz
udhcp: bind to device even for ucast packets
There are cases where binding to source IP and destination IP is insufficient to guarantee sane xmit netdev. One case where this can fail is when route-matching netdev carrier is down (cable unplugged, wifi disconnected), or the netdev is admin down. Then all the IP based bindings (bind() + connect()) will seemingly succeed but the actual packet can go out through a default gw path. Depending on the network this happens on it can create issues or false alarms. It can also leak some subnet info across networks that shouldn't be routed. As such better be safe than sorry and bind to a netdev to be sure it's used for xmit. function old new delta udhcp_send_kernel_packet 293 336 +43 send_packet 182 188 +6 bcast_or_ucast 37 43 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 55/0) Total: 55 bytes Signed-off-by: Michal Kazior <michal@plume.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index de16cf955..9e950ca1f 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -612,7 +612,8 @@ static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
udhcp_send_kernel_packet(dhcp_pkt,
server_data.server_nip, SERVER_PORT,
- dhcp_pkt->gateway_nip, SERVER_PORT);
+ dhcp_pkt->gateway_nip, SERVER_PORT,
+ server_data.interface);
}
static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast)