From 428c8cb96f4db1bcd655f1079209ac6957731a4c Mon Sep 17 00:00:00 2001 From: Ruben Herold Date: Fri, 30 Oct 2026 12:57:31 +0100 Subject: isc-kea: T8461: drop VLAN tagged packets on the raw socket of the parent interface Kea answers a DHCP request that arrived tagged on a VLAN a second time from the raw socket of the parent interface, with an address of the subnet of the parent. The client gets two offers, one of them from the wrong subnet. Backport the upstream fix of Kea 3.1.7 and 3.2.0, so the socket of the parent no longer sees tagged packets. Only the Linux part is needed. It is carried as a patch on top of 3.0.3 and can be taken to the LTS branch as well, the update to a newer Kea follows separately. With a subnet on the parent and one on VLAN 3, one request on VLAN 3 gave two offers before and gives one offer with the patch. --- .../0001-1117-drop-packets-with-vlan-tag.patch | 88 ++++++++++++++++++++++ .../0002-1117-addressed-review-comments.patch | 31 ++++++++ 2 files changed, 119 insertions(+) create mode 100644 scripts/package-build/isc-kea/patches/isc-kea/0001-1117-drop-packets-with-vlan-tag.patch create mode 100644 scripts/package-build/isc-kea/patches/isc-kea/0002-1117-addressed-review-comments.patch (limited to 'scripts') diff --git a/scripts/package-build/isc-kea/patches/isc-kea/0001-1117-drop-packets-with-vlan-tag.patch b/scripts/package-build/isc-kea/patches/isc-kea/0001-1117-drop-packets-with-vlan-tag.patch new file mode 100644 index 00000000..72890676 --- /dev/null +++ b/scripts/package-build/isc-kea/patches/isc-kea/0001-1117-drop-packets-with-vlan-tag.patch @@ -0,0 +1,88 @@ +From fed3ece02e2ca865377e9fbdb148bb5769c89940 Mon Sep 17 00:00:00 2001 +From: Razvan Becheriu +Date: Fri, 27 Feb 2026 17:43:26 +0200 +Subject: [PATCH] [#1117] drop packets with vlan tag + +(cherry picked from commit fed3ece02e2ca865377e9fbdb148bb5769c89940, only the part for Linux) +--- + src/lib/dhcp/pkt_filter_lpf.cc | 26 ++++++++++++++++++-------- + 1 file changed, 18 insertions(+), 8 deletions(-) + +diff --git a/src/lib/dhcp/pkt_filter_lpf.cc b/src/lib/dhcp/pkt_filter_lpf.cc +index 2c6bfc726e..b120e340da 100644 +--- a/src/lib/dhcp/pkt_filter_lpf.cc ++++ b/src/lib/dhcp/pkt_filter_lpf.cc +@@ -46,13 +46,13 @@ using namespace isc::dhcp; + struct sock_filter dhcp_sock_filter [] = { + // Make sure this is an IP packet: check the half-word (two bytes) + // at offset 12 in the packet (the Ethernet packet type). If it +- // is, advance to the next instruction. If not, advance 11 ++ // is, advance to the next instruction. If not, advance 13 + // instructions (which takes execution to the last instruction in + // the sequence: "drop it"). + // #0 + BPF_STMT(BPF_LD + BPF_H + BPF_ABS, ETHERNET_PACKET_TYPE_OFFSET), + // #1 +- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 11), ++ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 13), + + // Make sure it's a UDP packet. The IP protocol is at offset + // 9 in the IP header so, adding the Ethernet packet header size +@@ -61,7 +61,7 @@ struct sock_filter dhcp_sock_filter [] = { + BPF_STMT(BPF_LD + BPF_B + BPF_ABS, + ETHERNET_HEADER_LEN + IP_PROTO_TYPE_OFFSET), + // #3 +- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 9), ++ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 11), + + // Make sure this isn't a fragment by checking that the fragment + // offset field in the IP header is zero. This field is the +@@ -71,7 +71,7 @@ struct sock_filter dhcp_sock_filter [] = { + // #4 + BPF_STMT(BPF_LD + BPF_H + BPF_ABS, ETHERNET_HEADER_LEN + IP_FLAGS_OFFSET), + // #5 +- BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 7, 0), ++ BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 9, 0), + + // Check the packet's destination address. The program will only + // allow the packets sent to the broadcast address or unicast +@@ -89,7 +89,7 @@ struct sock_filter dhcp_sock_filter [] = { + // If this is not broadcast address, compare it with the unicast + // address specified for the interface. + // #8 +- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0x00000000, 0, 4), ++ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0x00000000, 0, 6), + + // Get the IP header length. This is achieved by the following + // (special) instruction that, given the offset of the start +@@ -110,14 +110,24 @@ struct sock_filter dhcp_sock_filter [] = { + // offset 11 in the program. If this is changed, openSocket() must be + // updated. + // #11 +- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP4_SERVER_PORT, 0, 1), ++ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP4_SERVER_PORT, 0, 3), + +- // If we passed all the tests, ask for the whole packet. ++ // Make sure this packet does not contain a vlan tag. The tag is stripped ++ // automatically by the kernel when presented to the vlan interface. ++ // Parent interface should not see this packet. + // #12 ++ BPF_STMT(BPF_LD + BPF_B + BPF_ABS, (u_int)SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), ++ ++ // If this packet contains vlan tag drop the packet. ++ // #13 ++ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 0, 1), ++ ++ // If we passed all the tests, ask for the whole packet. ++ // #14 + BPF_STMT(BPF_RET + BPF_K, (u_int)-1), + + // Otherwise, drop it. +- // #13 ++ // #15 + BPF_STMT(BPF_RET + BPF_K, 0), + }; + +-- +2.55.0 + diff --git a/scripts/package-build/isc-kea/patches/isc-kea/0002-1117-addressed-review-comments.patch b/scripts/package-build/isc-kea/patches/isc-kea/0002-1117-addressed-review-comments.patch new file mode 100644 index 00000000..b43459dc --- /dev/null +++ b/scripts/package-build/isc-kea/patches/isc-kea/0002-1117-addressed-review-comments.patch @@ -0,0 +1,31 @@ +From 4313cbb478a8855a52f21a8f787478953fe038fa Mon Sep 17 00:00:00 2001 +From: Razvan Becheriu +Date: Tue, 3 Mar 2026 10:57:14 +0200 +Subject: [PATCH] [#1117] addressed review comments + +(cherry picked from commit 4313cbb478a8855a52f21a8f787478953fe038fa, only the part for Linux) +--- +diff --git a/src/lib/dhcp/pkt_filter_lpf.cc b/src/lib/dhcp/pkt_filter_lpf.cc +index b120e340da..06f7305ae8 100644 +--- a/src/lib/dhcp/pkt_filter_lpf.cc ++++ b/src/lib/dhcp/pkt_filter_lpf.cc +@@ -173,8 +173,15 @@ PktFilterLPF::openSocket(Iface& iface, + << " on the socket " << sock); + } + +-#ifdef SO_TIMESTAMP + int enable = 1; ++ // Enable ancillary data to detect VLAN tagged packets. ++ if (setsockopt(sock, SOL_PACKET, PACKET_AUXDATA, &enable, sizeof(enable))) { ++ const char* errmsg = strerror(errno); ++ isc_throw(SocketConfigError, "Could not enable PACKET_AUXDATA for " << addr.toText() ++ << ", error: " << errmsg); ++ } ++ ++#ifdef SO_TIMESTAMP + if (setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &enable, sizeof(enable))) { + const char* errmsg = strerror(errno); + isc_throw(SocketConfigError, "Could not enable SO_TIMESTAMP for " << addr.toText() +-- +2.55.0 + -- cgit v1.2.3