summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2016-12-07 19:51:48 +0000
committerpatrick <patrick@openbsd.org>2016-12-07 19:51:48 +0000
commit99e009ca8dfc139c16efe20f10b2b6249ddea83a (patch)
tree3587f9140ae2998e2494a05659ce55ab2226d183
parentsync (diff)
downloadwireguard-openbsd-99e009ca8dfc139c16efe20f10b2b6249ddea83a.tar.xz
wireguard-openbsd-99e009ca8dfc139c16efe20f10b2b6249ddea83a.zip
If the BROADCAST flag is set on a BOOTREPLY, the RFC specifies that
we SHOULD forward the packet not only as L3 broadcast, but also as L2 broadcast. Apparently that helps on older machines that can't handle L2 unicast replies. ok jca@
-rw-r--r--usr.sbin/dhcrelay/dhcrelay.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/usr.sbin/dhcrelay/dhcrelay.c b/usr.sbin/dhcrelay/dhcrelay.c
index 88802339879..c4e723f1bb4 100644
--- a/usr.sbin/dhcrelay/dhcrelay.c
+++ b/usr.sbin/dhcrelay/dhcrelay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcrelay.c,v 1.45 2016/12/07 16:41:17 reyk Exp $ */
+/* $OpenBSD: dhcrelay.c,v 1.46 2016/12/07 19:51:48 patrick Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org>
@@ -283,12 +283,20 @@ relay(struct interface_info *ip, struct dhcp_packet *packet, int length,
to.sin_family = AF_INET;
to.sin_len = sizeof to;
- /* Set up the hardware destination address. */
- hto.hlen = packet->hlen;
- if (hto.hlen > sizeof hto.haddr)
- hto.hlen = sizeof hto.haddr;
- memcpy(hto.haddr, packet->chaddr, hto.hlen);
- hto.htype = packet->htype;
+ /*
+ * Set up the hardware destination address. If it's a reply
+ * with the BROADCAST flag set, we should send an L2 broad-
+ * cast as well.
+ */
+ if (!(packet->flags & htons(BOOTP_BROADCAST))) {
+ hto.hlen = packet->hlen;
+ if (hto.hlen > sizeof hto.haddr)
+ hto.hlen = sizeof hto.haddr;
+ memcpy(hto.haddr, packet->chaddr, hto.hlen);
+ hto.htype = packet->htype;
+ } else {
+ bzero(&hto, sizeof(hto));
+ }
if ((length = relay_agentinfo(interfaces,
packet, length, NULL, &to.sin_addr)) == -1) {