Thread View: muc.lists.freebsd.bugs
2 messages
2 total messages
Started by bugzilla-noreply
Fri, 06 Nov 2026 08:55
[Bug 300551] in_arpinput() sends a reply longer than m_pkthdr.len when the request mbuf arrives as a chain, which happens on if_...
Author: bugzilla-noreply
Date: Fri, 06 Nov 2026 08:55
Date: Fri, 06 Nov 2026 08:55
181 lines
8464 bytes
8464 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300551
Bug ID: 300551
Summary: in_arpinput() sends a reply longer than m_pkthdr.len
when the request mbuf arrives as a chain, which
happens on if_bridge(4) with 64-byte requests
Product: Base System
Version: Unspecified
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: DanielWeigl@gmx.at
When the IPv4 address is on an if_bridge(4) interface, ARP replies to some
clients come out 4 bytes too long: 46 bytes instead of 42 before NIC padding.
The ARP payload is 32 bytes instead of 28, with 4 trailing zero bytes. It only
happens when the incoming ARP request is 64 bytes long; some Wi-Fi access
points pad frames to 64 bytes instead of 60. With the same address on the
physical member interface (no bridge), replies to all hosts are 42 bytes.
Analysis
--------
bridge_input() in sys/net/if_bridge.c copies broadcast frames for local
delivery and realigns them:
mc2 = m_dup(m, M_NOWAIT);
if (mc2 != NULL) {
/* Keep the layer3 header aligned */
int i = min(mc2->m_pkthdr.len, max_protohdr);
mc2 = m_copyup(mc2, i, ETHER_ALIGN);
}
With max_protohdr at 60 and a 64-byte frame, this gives a two-mbuf chain of 60
+ 4 bytes. A 60-byte frame stays in a single mbuf.
in_arpinput() in sys/netinet/if_ether.c reuses the request mbuf for the reply
and sets only the first mbuf’s length:
m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln);
m->m_pkthdr.len = m->m_len;
m->m_next is neither freed nor trimmed. After this, m_pkthdr.len (28) no longer
matches the chain length (32). BPF and the driver walk the whole chain, so the
4 stale bytes go out with the reply.
Captures (tcpdump -i igc1 -e -xx arp on the bridge member port; MACs
anonymised)
The client’s ARP request as seen on igc1: 64 bytes, ARP length 50.
ffff ffff ffff 0200 0000 0001 0806 0001
0800 0604 0001 0200 0000 0001 0a64 01a8
0000 0000 0000 0a64 0064 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
The reply with the IP on bridge0 (source MAC is the bridge’s generated 58:9c:fc
address): 46 bytes, ARP length 32.
0200 0000 0001 589c fc00 0001 0806 0001
0800 0604 0002 589c fc00 0001 0a64 0064
0200 0000 0001 0a64 01a8 0000 0000
The reply with the IP directly on igc1, to a different client on the same
network: 42 bytes, ARP length 28.
0200 0000 0003 7c2b e100 0002 0806 0001
0800 0604 0002 7c2b e100 0002 0a64 0064
0200 0000 0003 0a64 01cc
While the IP was on the bridge, replies to clients that sent normal 60-byte
requests were also 42 bytes. Only 64-byte requests produced the longer reply.
The m_dup() + m_copyup(mc2, min(len, max_protohdr), ETHER_ALIGN) block in
bridge_input() dates back to commit 7536320 (Dec 2005: "It is not safe to use
m_copypacket() here as the returned mbuf is readonly, change to m_dup and keep
the alignment on the layer3 header."). The resulting mbuf chain is valid. The
bug is that in_arpinput() assumes the ARP request fits in one mbuf when it
builds the reply in place: it sets m_len and m_pkthdr.len on the first mbuf and
leaves m_next attached. So the bridge path has probably sent these trailing
bytes for any request longer than max_protohdr since 2005.
How to reproduce
----------------
Create bridge0 with one member, for example igc1, and put an IPv4 address on
bridge0.
From another host, send a broadcast ARP request for that address, padded to 64
bytes. For example, in scapy:
sendp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=...)/Raw(b"\0"*22)).
Run tcpdump -i igc1 -e -xx arp. The reply is length 32 instead of length 28.
Suggested fix
In in_arpinput(), trim the whole chain before sending the reply instead of
setting only m_len. For example, use m_adj(m, m->m_pkthdr.len - reply_len) or
free m->m_next, so m_pkthdr.len and the chain length match.
Observed impact
---------------
A TP-Link EAP225(EU) v5 access point (MediaTek chipset, firmware 1.3.1) pads
its clients’ ARP requests to 64 bytes. With the gateway address on the bridge,
its Wi-Fi clients regularly failed to resolve the gateway after associating:
The client’s ARP stayed INCOMPLETE.
The replies left the gateway but never showed up in the access point’s own
wired-side capture.
It cleared up after about 6.5 minutes, or straight away after any bridge
reconfiguration (which sends a gratuitous ARP).
Moving the address from bridge0 to igc1 fixed it completely.
It isn’t proven that the 4 extra bytes cause the drop. The NIC pads both frames
to 60 bytes on the wire, and the source MAC also differs: the bridge’s
generated address versus the physical one. But the mismatched mbuf lengths are
a bug either way.
Other reports
-------------
Similar reports (same symptom: a BSD gateway bridge plus TP-Link or MediaTek
access points, fixed by removing the bridge)
* TP-Link community, EAP610 with a pfSense bridge; ARP replies from the
58:9c:fc bridge MAC are dropped inside the access point:
- https://community.tp-link.com/en/business/forum/topic/873390
- https://community.tp-link.com/en/business/forum/topic/840380
* OpenWrt, MediaTek access point used as a plain AP behind a pfSense/OPNsense
bridge; clients lose the gateway for about 5 minutes:
- https://github.com/openwrt/openwrt/issues/11942
* OPNsense forum, LAN bridge with similar Wi-Fi client connectivity loss, fixed
by removing the bridge:
- https://forum.opnsense.org/index.php?topic=32652.0
- https://forum.opnsense.org/index.php?topic=46397.0
Ps: the bug triage and writeup was done with the help of AI, but i tried to
understand and reason the issue as good as possible - but im not very
experienced with this abstraction level of the networking stack - so please
excuse if there are some errors in the write up.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300551] in_arpinput() sends a reply longer than m_pkthdr.len when the request mbuf arrives as a chain, which happens on if_...
Author: bugzilla-noreply
Date: Fri, 06 Nov 2026 08:59
Date: Fri, 06 Nov 2026 08:59
16 lines
2654 bytes
2654 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300551
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|bugs@FreeBSD.org |net@FreeBSD.org
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads