Bug 283315 - if_ffec receive packet size in mbuf header is not properly adjusted and is 2 bytes too large.
Summary: if_ffec receive packet size in mbuf header is not properly adjusted and is 2 ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: arm64 Any
: --- Affects Some People
Assignee: Michael Tuexen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-13 18:53 UTC by Mike Belanger
Modified: 2026-05-31 07:28 UTC (History)
4 users (show)

See Also:
tuexen: mfc-stable15+
tuexen: mfc-stable14+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Belanger 2024-12-13 18:53:21 UTC
In ffec_rxfinish_onebuf, there is code to adjust the start of the data, but the size is not properly adjusted.
tcpdump can be used to see the extra 2 bytes on receive packets.

The following should resolve the issue.

	if (sc->fecflags & FECFLAG_RACC) {
		m->m_data = mtod(m, uint8_t *) + 2;
>>>>>>
		m->m_len -= 2;
		m->m_pkthdr.len -= 2;
>>>>>>
	} else {
		src = mtod(m, uint8_t*);
		dst = src - ETHER_ALIGN;
		bcopy(src, dst, len);
		m->m_data = dst;
	}
Comment 1 Mike Belanger 2024-12-13 19:05:38 UTC
The following would be better, i.e. use m_adj instead of modifying m->m_data:

	if (sc->fecflags & FECFLAG_RACC) {
-		m->m_data = mtod(m, uint8_t *) + 2;
+		m_adj(m, 2);

	} else {
		src = mtod(m, uint8_t*);
		dst = src - ETHER_ALIGN;
		bcopy(src, dst, len);
		m->m_data = dst;
	}
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2024-12-13 23:29:28 UTC
^Triage: assign, and note that this contains an inline patch.
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2026-05-18 01:51:15 UTC
^Triage: does this still apply to recent versions of FreeBSD?
Comment 4 commit-hook freebsd_committer freebsd_triage 2026-05-28 11:21:33 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b29842622dcb9c9c9515fc04dc5826a8717537b1

commit b29842622dcb9c9c9515fc04dc5826a8717537b1
Author:     Mike Belanger <mibelanger@qnx.com>
AuthorDate: 2026-05-28 11:09:52 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-05-28 11:09:52 +0000

    if_ffec: correctly trim 2 bytes from the beginning

    PR:             283315
    Tested by:      tuexen
    MFC after:      3 days

 sys/dev/ffec/if_ffec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-05-31 07:19:46 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=aec9fc6dd2111b6b196dc029afbfbab646c96501

commit aec9fc6dd2111b6b196dc029afbfbab646c96501
Author:     Mike Belanger <mibelanger@qnx.com>
AuthorDate: 2026-05-28 11:09:52 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-05-31 05:17:37 +0000

    if_ffec: correctly trim 2 bytes from the beginning

    PR:             283315
    Tested by:      tuexen

    (cherry picked from commit b29842622dcb9c9c9515fc04dc5826a8717537b1)

 sys/dev/ffec/if_ffec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-05-31 07:27:48 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a346cd6edef99b5f333185492fe56956635dd8c

commit 1a346cd6edef99b5f333185492fe56956635dd8c
Author:     Mike Belanger <mibelanger@qnx.com>
AuthorDate: 2026-05-28 11:09:52 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-05-31 07:25:50 +0000

    if_ffec: correctly trim 2 bytes from the beginning

    PR:             283315
    Tested by:      tuexen

    (cherry picked from commit b29842622dcb9c9c9515fc04dc5826a8717537b1)

 sys/dev/ffec/if_ffec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)