Page MenuHomeFreeBSD

netgraph/ng_ether: Reattach nodes to interfaces
Needs ReviewPublic

Authored by donner on Dec 27 2021, 9:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 10:26 PM
Unknown Object (File)
Mon, Apr 29, 1:38 PM
Unknown Object (File)
Fri, Apr 26, 7:44 AM
Unknown Object (File)
Fri, Apr 26, 6:49 AM
Unknown Object (File)
Fri, Apr 26, 6:49 AM
Unknown Object (File)
Sun, Apr 14, 5:27 PM
Unknown Object (File)
Apr 2 2024, 5:38 PM
Unknown Object (File)
Dec 20 2023, 3:01 AM

Details

Reviewers
kp
glebius
Group Reviewers
network
pfsense
manpages
Summary

Allow a reattach of a detached ng_ether(4) node as proposed in D32550.

Test Plan

@kp: please test

Detatch you node from the interface (i.e.) em0 , then

# ngctl
+ show em0:
ngctl: send msg: No such file or directory
+ mkpeer . ether any em0
+ show em0:
  Name: em0           Type: ether           ID: 00000001   Num hooks: 1
  Local hook      Peer name       Peer type    Peer ID         Peer hook      
  ----------      ---------       ---------    -------         ---------      
  em0             <unnamed>        socket       00000002        any
+ rmhook em0:em0
+ show em0:
  Name: em0           Type: ether           ID: 00000001   Num hooks: 0

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 43691
Build 40579: arc lint + arc unit

Event Timeline

This is the first approach to implement the reattach process.
It does compile. I did not test anything yet.

Sorry for the delay so far. This is on my todo list for Monday.

In D33673#761884, @kp wrote:

Sorry for the delay so far. This is on my todo list for Monday.

Don't hurry. We can move this to next year.

So this appears to panic:

  • kldload ng_ether
  • ngctl show bnxt0:

    Name: bnxt0 Type: ether ID: 00000001 Num hooks: 0
  • ngctl msg bnxt0: detach
  • ngctl mkpeer . ether any bnxt0

Results in:

Fatal trap 12: page fault while in kernel mode
cpuid = 3; apic id = 03
fault virtual address	= 0x0
fault code		= supervisor read data, page not present
instruction pointer	= 0x20:0xffffffff82f4cd06
stack pointer	        = 0x28:0xfffffe0148e63880
frame pointer	        = 0x28:0xfffffe0148e638b0
code segment		= base 0x0, limit 0xfffff, type 0x1b
			= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags	= interrupt enabled, resume, IOPL = 0
current process		= 4027 (ngctl)
trap number		= 12
panic: page fault
cpuid = 3
time = 1641212765
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0148e63640
vpanic() at vpanic+0x17f/frame 0xfffffe0148e63690
panic() at panic+0x43/frame 0xfffffe0148e636f0
trap_fatal() at trap_fatal+0x385/frame 0xfffffe0148e63750
trap_pfault() at trap_pfault+0xab/frame 0xfffffe0148e637b0
calltrap() at calltrap+0x8/frame 0xfffffe0148e637b0
--- trap 0xc, rip = 0xffffffff82f4cd06, rsp = 0xfffffe0148e63880, rbp = 0xfffffe0148e638b0 ---
ng_destroy_hook() at ng_destroy_hook+0x236/frame 0xfffffe0148e638b0
ng_apply_item() at ng_apply_item+0x99/frame 0xfffffe0148e63940
ng_snd_item() at ng_snd_item+0x2e1/frame 0xfffffe0148e63980
ng_ether_newhook() at ng_ether_newhook+0x17c/frame 0xfffffe0148e639d0
ng_add_hook() at ng_add_hook+0x127/frame 0xfffffe0148e63a10
ng_mkpeer() at ng_mkpeer+0x6c/frame 0xfffffe0148e63a60
ng_apply_item() at ng_apply_item+0x522/frame 0xfffffe0148e63af0
ng_snd_item() at ng_snd_item+0x2e1/frame 0xfffffe0148e63b30
ngc_send() at ngc_send+0x1af/frame 0xfffffe0148e63bd0
sosend_generic() at sosend_generic+0x5ab/frame 0xfffffe0148e63c90
sosend() at sosend+0x50/frame 0xfffffe0148e63cc0
kern_sendit() at kern_sendit+0x245/frame 0xfffffe0148e63d60
sendit() at sendit+0x1da/frame 0xfffffe0148e63db0
sys_sendto() at sys_sendto+0x4d/frame 0xfffffe0148e63e00
amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe0148e63f30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0148e63f30
--- syscall (133, FreeBSD ELF64, sys_sendto), rip = 0x385784f4b77a, rsp = 0x7fffffffcde8, rbp = 0x7fffffffce30 ---
KDB: enter: panic
[ thread pid 4027 tid 100736 ]
Stopped at      kdb_enter+0x37: movq    $0,0x128a2ce(%rip)

I suspect that's because we've not actually done LIST_INSERT_HEAD(&node->nd_hooks, hook, hk_hooks) in ng_add_hook() at this point, so the list isn't correctly initialised.

Thank you. The bug is simple:

ng_destroy_hook() at ng_destroy_hook+0x236/frame 0xfffffe0148e638b0
ng_apply_item() at ng_apply_item+0x99/frame 0xfffffe0148e63940
ng_snd_item() at ng_snd_item+0x2e1/frame 0xfffffe0148e63980
ng_ether_newhook() at ng_ether_newhook+0x17c/frame 0xfffffe0148e639d0
ng_add_hook() at ng_add_hook+0x127/frame 0xfffffe0148e63a10

I try to remove the hook while creating it. So the hook is not finished yet, but the call to remove it is already scheduled.

donner edited the test plan for this revision. (Show Details)

It's not possible to remove a hook while creating it.
Find a better solution.

It's not possible to remove a hook while creating it.
Find a better solution.

That still panics here:

login: panic: ng_ether_disconnect: weird hook
cpuid = 1
time = 1641229275
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0146e3b800
vpanic() at vpanic+0x17f/frame 0xfffffe0146e3b850
panic() at panic+0x43/frame 0xfffffe0146e3b8b0
ng_ether_disconnect() at ng_ether_disconnect+0x7b/frame 0xfffffe0146e3b8c0
ng_destroy_hook() at ng_destroy_hook+0x26b/frame 0xfffffe0146e3b900
ng_apply_item() at ng_apply_item+0x99/frame 0xfffffe0146e3b990
ng_snd_item() at ng_snd_item+0x2e1/frame 0xfffffe0146e3b9d0
ng_destroy_hook() at ng_destroy_hook+0x11a/frame 0xfffffe0146e3ba10
ng_rmnode() at ng_rmnode+0x65/frame 0xfffffe0146e3ba40
ng_apply_item() at ng_apply_item+0x99/frame 0xfffffe0146e3bad0
ng_snd_item() at ng_snd_item+0x2e1/frame 0xfffffe0146e3bb10
ng_detach_common() at ng_detach_common+0x68/frame 0xfffffe0146e3bb40
sofree() at sofree+0x301/frame 0xfffffe0146e3bb90
soclose() at soclose+0x280/frame 0xfffffe0146e3bc00
_fdrop() at _fdrop+0x1b/frame 0xfffffe0146e3bc20
closef() at closef+0x1db/frame 0xfffffe0146e3bcb0
fdescfree() at fdescfree+0x453/frame 0xfffffe0146e3bd80
exit1() at exit1+0x4ae/frame 0xfffffe0146e3bdf0
sys_exit() at sys_exit+0xd/frame 0xfffffe0146e3be00
amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe0146e3bf30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0146e3bf30
--- syscall (1, FreeBSD ELF64, sys_exit), rip = 0x946120e2da, rsp = 0x7fffffffea28, rbp = 0x7fffffffea40 ---
KDB: enter: panic
[ thread pid 3973 tid 100676 ]
Stopped at      kdb_enter+0x37: movq    $0,0x128a2ce(%rip)
db>

Minor manual page grammar fix

share/man/man4/ng_ether.4
126

Thank you for reviewing, @pauamma_gundo.com

@kp I have to try it myself, this panic is stranger than expected.