summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2015-01-08 07:31:52 -0500
committerThomas Markwalder <tmark@isc.org>2015-01-08 07:31:52 -0500
commitacbecb2e9b0e92a804b428fe4829f6f337498ed2 (patch)
tree20dd31eacd58e3efde0bb85ff3fffabad8273117 /common
parent001b9d53258126b10d0d2e3776345095754aecd7 (diff)
downloadisc-dhcp-acbecb2e9b0e92a804b428fe4829f6f337498ed2.tar.gz
[master] Linux packet handling ignores VLAN packets sent to physical interface
Merges in rt37415.
Diffstat (limited to 'common')
-rw-r--r--common/lpf.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/common/lpf.c b/common/lpf.c
index 99937e6c..37cb99eb 100644
--- a/common/lpf.c
+++ b/common/lpf.c
@@ -4,7 +4,8 @@
Support Services in Vancouver, B.C. */
/*
- * Copyright (c) 2009,2012,2014 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2014-2015 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
@@ -385,14 +386,32 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
#ifdef PACKET_AUXDATA
{
- /* Determine if checksum is valid for use. It may not be if checksum
- offloading is enabled on the interface. */
+ /* Use auxiliary packet data to:
+ *
+ * a. Weed out extraneous VLAN-tagged packets - If the NIC driver is
+ * handling VLAN encapsulation (i.e. stripping/adding VLAN tags),
+ * then an inbound VLAN packet will be seen twice: Once by
+ * the parent interface (e.g. eth0) with a VLAN tag != 0; and once
+ * by the vlan interface (e.g. eth0.n) with a VLAN tag of 0 (i.e none).
+ * We want to discard the packet sent to the parent and thus respond
+ * only over the vlan interface. (Drivers for Intel PRO/1000 series
+ * NICs perform VLAN encapsulation, while drivers for PCnet series
+ * do not, for example. The linux kernel makes stripped vlan info
+ * visible to user space via CMSG/auxdata, this appears to not be
+ * true for BSD OSs.)
+ *
+ * b. Determine if checksum is valid for use. It may not be if
+ * checksum offloading is enabled on the interface. */
struct cmsghdr *cmsg;
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == SOL_PACKET &&
cmsg->cmsg_type == PACKET_AUXDATA) {
struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
+ /* Discard packets with stripped vlan id */
+ if (aux->tp_vlan_tci != 0)
+ return 0;
+
csum_ready = ((aux->tp_status & TP_STATUS_CSUMNOTREADY)
? 0 : 1);
}