Page MenuHomeFreeBSD

epair: Fix panic on unload
ClosedPublic

Authored by kp on Oct 23 2017, 8:29 PM.
Tags
None
Referenced Files
F161858337: D12771.diff
Tue, Jul 7, 11:53 AM
Unknown Object (File)
Sat, Jul 4, 10:39 AM
Unknown Object (File)
Sat, Jul 4, 1:29 AM
Unknown Object (File)
Fri, Jul 3, 5:11 AM
Unknown Object (File)
Wed, Jul 1, 8:55 AM
Unknown Object (File)
Wed, Jun 17, 1:24 AM
Unknown Object (File)
Sun, Jun 14, 6:47 PM
Unknown Object (File)
Apr 27 2026, 11:20 PM
Subscribers

Details

Reviewers
bz
Group Reviewers
network
Commits
rS325283: epair: Fix panic on unload
Summary

The VNET_SYSUNINIT() callback is executed after the MOD_UNLOAD. That means
that netisr_unregister() has already been called when
netisr_unregister_vnet() gets calls, leading to an assertion failure.

Restore the expected order of operations by performing everything that
was done in MOD_UNLOAD to a SYSUNINIT() (that will be called after the
VNET_SYSUNINIT()).

Test Plan

Create an epair, hand one end to a vnet jail then unload the kernel module.
Previously it panicked as follows:

panic: netisr_unregister_vnet(8): protocol not registered for epair
cpuid = 4
time = 1508769842
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0469e9a650
vpanic() at vpanic+0x19c/frame 0xfffffe0469e9a6d0
kassert_panic() at kassert_panic+0x126/frame 0xfffffe0469e9a740
netisr_unregister_vnet() at netisr_unregister_vnet+0x237/frame 0xfffffe0469e9a7a0
vnet_epair_uninit() at vnet_epair_uninit+0x10/frame 0xfffffe0469e9a7b0
vnet_deregister_sysuninit() at vnet_deregister_sysuninit+0x7e/frame 0xfffffe0469e9a7e0
linker_file_unload() at linker_file_unload+0x53a/frame 0xfffffe0469e9a840
kern_kldunload() at kern_kldunload+0x10c/frame 0xfffffe0469e9a880
amd64_syscall() at amd64_syscall+0x79b/frame 0xfffffe0469e9a9b0
Xfast_syscall() at Xfast_syscall+0xfb/frame 0xfffffe0469e9a9b0

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This is similar to how I fixed this problem for pf.

This is all highly unintuitive though, and it feels like the syuninits should be called before MOD_UNLOAD, but that's a larger change affecting *all* modules.

This revision was automatically updated to reflect the committed changes.