MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_detach_common

Function ng_detach_common

freebsd/netgraph/ng_socket.c:630–659  ·  view source on GitHub ↗

* Disassociate the socket from it's protocol specific * partner. If it's attached to a node's private data structure, * then unlink from that too. If we were the last socket attached to it, * then shut down the entire node. Shared code for control and data sockets. */

Source from the content-addressed store, hash-verified

628 * then shut down the entire node. Shared code for control and data sockets.
629 */
630static void
631ng_detach_common(struct ngpcb *pcbp, int which)
632{
633 struct ngsock *priv = pcbp->sockdata;
634
635 if (priv != NULL) {
636 mtx_lock(&priv->mtx);
637
638 switch (which) {
639 case NG_CONTROL:
640 priv->ctlsock = NULL;
641 break;
642 case NG_DATA:
643 priv->datasock = NULL;
644 break;
645 default:
646 panic("%s", __func__);
647 }
648 pcbp->sockdata = NULL;
649 pcbp->node_id = 0;
650
651 ng_socket_free_priv(priv);
652 }
653
654 pcbp->ng_socket->so_pcb = NULL;
655 mtx_lock(&ngsocketlist_mtx);
656 LIST_REMOVE(pcbp, socks);
657 mtx_unlock(&ngsocketlist_mtx);
658 free(pcbp, M_PCB);
659}
660
661/*
662 * Remove a reference from node private data.

Callers 3

ngc_detachFunction · 0.85
ngd_detachFunction · 0.85
ng_attach_cntlFunction · 0.85

Calls 5

ng_socket_free_privFunction · 0.85
mtx_lockFunction · 0.50
panicFunction · 0.50
mtx_unlockFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected