netgraph: kernel panic due to M_DONTWAIT when connecting ksocket

Wim Rijnders wim at mediamessage.nl
Mon May 24 09:17:39 GMT 2004


Hello,

When trying to use a netgraph ksocket for a tcp connection, we get a
kernel panic on opening the connection. The panic is a result of a
KASSERT() on the value of a flag which we don't set ourselves and which
we don't appear to have control over.

Details of our investigation follow. What can we do to fix this?

---
We're using the 5.2-CURRENT release.

* We use ksockets in netgraph to create a tcp connection. The kernel
panics when creating a connection with code similar to:

    result= NgSendMsg(ctrlSoc, path, NGM_KSOCKET_COOKIE,
                 NGM_KSOCKET_CONNECT, &addr, sizeof(addr) )
 
* The kernel panic occurs in ng_ksocket.c , function
ng_ksocket_incoming2() on a call to macro NG_MKMESSAGE().

This macro is defined in ng_message.h. One of the first things it does
is perform this KASSERT():

KASSERT(!(how & M_DONTWAIT),                                  \
     ("NG_MKMESSAGE() with how=M_DONTWAIT (%d)\n", how));      \   


* We do not set the  M_DONTWAIT flag anywhere our code. The setting can
be traced to call in sowakeup(), line 320 in
/usr/src/sys/kern/uipc_socket2.c:

    if (sb->sb_flags & SB_UPCALL)
        sh freebeer*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT);
---

Kind regards,

Wim Rijnders
Buyways BV.



More information about the freebsd-net mailing list