Bug 205164 - BPF gives EIO with sendmsg() where write > pagesize
Summary: BPF gives EIO with sendmsg() where write > pagesize
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.2-STABLE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-09 18:28 UTC by Andrew Basterfield
Modified: 2023-09-17 14:30 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Basterfield 2015-12-09 18:28:02 UTC
I have been playing with net/vblade and jumbo frames, specifically I would like to fit a 4K block within an AOE frame, which means sending a packet slightly larger than 4K.

vblade errors out with EIO in sendmsg() when asked to write over 4K to bpf fd - is this expected?

NetworkPerformanceTuning on the wiki says

"Sendmsg() cat't send messages more than maxdgram length. Default value causes routing software to fail with OSPF if jumbo frames is turned on.

net.inet.raw.maxdgram=16384
net.inet.raw.recvspace=16384"

No joy from above

em0: <Intel(R) PRO/1000 Network Connection 7.4.2> port 0xe800-0xe81f mem 0xfe8e0000-0xfe8fffff,0xfe800000-0xfe87ffff,0xfe8dc000-0xfe8dffff irq 16 at device 0.0 on pci2
em0: Using MSIX interrupts with 3 vectors
Comment 1 Andrew Basterfield 2015-12-10 00:38:42 UTC
https://github.com/OpenAoE/vblade/issues/7
Comment 2 Florian Florensa 2018-02-16 10:01:32 UTC
I have been encountering the same issue and came up with a patch that fixes the issue, if anyone wants to review it : https://github.com/fflorens/freebsd/commit/92e0329076d3f3bc7d3537aa11786dfd7d26abfb
Also opened a PR : https://github.com/freebsd/freebsd/pull/131
Comment 3 Andrew Basterfield 2018-02-16 10:32:10 UTC
Excellent thanks I will be able to have a look at that for my use-case at least
Comment 4 Andrew Basterfield 2018-02-16 22:28:07 UTC
Works great many thanks
Comment 5 Florian Florensa 2018-02-17 21:43:23 UTC
You're welcome, but from what i have been told (see the discussion in the PR : https://github.com/freebsd/freebsd/pull/131 and the chain of email there : https://lists.freebsd.org/pipermail/freebsd-net/2017-November/049231.html) the patch i proposed might not be a good idea under memory pressure.
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-06-23 16:41:10 UTC
A commit in branch main references this bug:

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

commit f13da24715a75ce0fdac31062866877d980aa908
Author:     Florian Florensa <florian@florensa.me>
AuthorDate: 2018-02-16 09:53:22 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-06-23 16:39:18 +0000

    net/bpf: Fix writing of buffer bigger than PAGESIZE

    When allocating the mbuf we used m_get2 which fails
    if len is superior to MJUMPAGESIZE, if its the case,
    use m_getjcl instead.

    Reviewed by:    kp@
    PR:             205164
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/131

 sys/net/bpf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Comment 7 Xin LI freebsd_committer freebsd_triage 2022-11-22 23:01:47 UTC
Hi, Warner, should this be MFC'ed?
Comment 8 Warner Losh freebsd_committer freebsd_triage 2023-09-17 14:20:33 UTC
Just merged this, so closing. It will land once testing is done. If it fails for some reason, I'm never going to merge.
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-09-17 14:30:03 UTC
A commit in branch stable/13 references this bug:

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

commit 7965d4d9e326373b4669e451d3bd2a7d840c4b5b
Author:     Florian Florensa <florian@florensa.me>
AuthorDate: 2023-09-17 14:16:07 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-09-17 14:17:51 +0000

    net/bpf: Fix writing of buffer bigger than PAGESIZE

    When allocating the mbuf we used m_get2 which fails
    if len is superior to MJUMPAGESIZE, if its the case,
    use m_getjcl instead.

    Reviewed by:    kp@
    PR:             205164
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/131

    (cherry picked from commit f13da24715a75ce0fdac31062866877d980aa908)

 sys/net/bpf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)