[systemd-commits] src/libsystemd-network
Tom Gundersen
tomegun at kemper.freedesktop.org
Sat Jun 21 06:10:07 PDT 2014
src/libsystemd-network/dhcp-network.c | 4 ++++
src/libsystemd-network/sd-dhcp-server.c | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
New commits:
commit d6bd972d061af306ede2affd2c9340a1660f7996
Author: Tom Gundersen <teg at jklm.no>
Date: Sat Jun 21 14:39:36 2014 +0200
sd-dhcp-server: fix broadcast of DHCP packets
The destination IP address should be INADDR_BROADCAST, but was
accidentally left as INADDR_ANY.
diff --git a/src/libsystemd-network/dhcp-network.c b/src/libsystemd-network/dhcp-network.c
index d7ba0ef..0e37bea 100644
--- a/src/libsystemd-network/dhcp-network.c
+++ b/src/libsystemd-network/dhcp-network.c
@@ -127,6 +127,10 @@ int dhcp_network_bind_udp_socket(be32_t address, uint16_t port) {
r = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
if (r < 0)
return -errno;
+
+ r = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
+ if (r < 0)
+ return -errno;
}
r = bind(s, &src.sa, sizeof(src.in));
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index e4236e8..55a8fbe 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -340,9 +340,12 @@ int dhcp_server_send_packet(sd_dhcp_server *server,
} else if (req->message->ciaddr && type != DHCP_NAK)
destination = req->message->ciaddr;
- if (destination || requested_broadcast(req) || type == DHCP_NAK)
+ if (destination != INADDR_ANY)
return dhcp_server_send_udp(server, destination, &packet->dhcp,
sizeof(DHCPMessage) + optoffset);
+ else if (requested_broadcast(req) || type == DHCP_NAK)
+ return dhcp_server_send_udp(server, INADDR_BROADCAST, &packet->dhcp,
+ sizeof(DHCPMessage) + optoffset);
else
/* we cannot send UDP packet to specific MAC address when the address is
not yet configured, so must fall back to raw packets */
More information about the systemd-commits
mailing list