NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/60688 (npf: wrong module/config dependency for bpf filter?)



Synopsis: npf: wrong module/config dependency for bpf filter?

Responsible-Changed-From-To: kern-bug-people->tls
Responsible-Changed-By: riastradh%NetBSD.org@localhost
Responsible-Changed-When: Mon, 07 Sep 2026 14:34:28 +0000
Responsible-Changed-Why:
Can you please post the symptom (panic message, stack trace, whatever),
and make sure the dependencies are actually correct?

In particular, the change below looks suspicious for several reasons:

1. The `bpf' module already depends on `bpf_filter', so if depending on
   `bpf' wasn't enough, then surely depending on `bpf_filter' alone
   can't be enough!

   2680 MODULE(MODULE_CLASS_DRIVER, bpf, "bpf_filter");

https://nxr.netbsd.org/xref/src/sys/net/bpf.c?r=1.258#2680

   But perhaps the dependencies are not adequately matched in modules
   vs config(5) in files.net.

2. There are two MODULE declarations in npf_os.c which now disagree on
   the dependencies -- one branch depends on bpf, the other on
   bpf_filter:

diff -r aa99cd559912 -r 721be25199e5 sys/net/npf/npf_os.c
--- a/sys/net/npf/npf_os.c	Sat Sep 05 17:39:23 2026 +0000
+++ b/sys/net/npf/npf_os.c	Sat Sep 05 17:43:56 2026 +0000
...
@@ -81,7 +81,7 @@
 MODULE(MODULE_CLASS_MISC, npf, "bpf");
 #else
 /* This module autoloads via /dev/npf so it needs to be a driver */
-MODULE(MODULE_CLASS_DRIVER, npf, "bpf");
+MODULE(MODULE_CLASS_DRIVER, npf, "bpf_filter");
 #endif

3. It looks to me like npf actually _does_ depend on `bpf' per se,
   because it uses (e.g.) bpf_mtap2 and bpf_jit_generate, not just on
   `bpf_filter' (which it needs for bpf_create, bpf_set_cop,
   bpf_set_extmem, bpf_validate_ext, bpf_filter_ext):

    137 void *
    138 npf_bpf_compile(void *code, size_t size)
    139 {
    140 	return bpf_jit_generate(npf_bpfctx, code, size);
    141 }
https://nxr.netbsd.org/xref/src/sys/net/npf/npf_bpf.c?r=1.14#137

    144 		/* Pass through BPF. */
    145 		bpf_mtap2(ifp->if_bpf, &hdr, NPFLOG_HDRLEN, m, BPF_D_OUT);
https://nxr.netbsd.org/xref/src/sys/net/npf/npf_ext_log.c?r=1.17#144

   These come from bpf.c and thus from the `bpf' module, not from
   bpf_filter.c or the `bpf_filter' module (which `bpf' depends on).

https://nxr.netbsd.org/xref/src/sys/net/bpf.c?r=1.258#303


Change that was supposed to fix this bug but I suspect doesn't quite:

https://mail-index.netbsd.org/source-changes/2026/09/05/msg163893.html

Module Name:    src
Committed By:   tls
Date:           Sat Sep  5 17:43:56 UTC 2026

Modified Files:
        src/sys/net/npf: files.npf npf_os.c

Log Message:
Fix npf crash in kernels without "pseudo-device bpfilter".


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/net/npf/files.npf
cvs rdiff -u -r1.23 -r1.24 src/sys/net/npf/npf_os.c






Home | Main Index | Thread Index | Old Index