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

Function ng_attach_common

freebsd/netgraph/ng_socket.c:598–622  ·  view source on GitHub ↗

* Set up a socket protocol control block. * This code is shared between control and data sockets. */

Source from the content-addressed store, hash-verified

596 * This code is shared between control and data sockets.
597 */
598static int
599ng_attach_common(struct socket *so, int type)
600{
601 struct ngpcb *pcbp;
602 int error;
603
604 /* Standard socket setup stuff. */
605 error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace);
606 if (error)
607 return (error);
608
609 /* Allocate the pcb. */
610 pcbp = malloc(sizeof(struct ngpcb), M_PCB, M_WAITOK | M_ZERO);
611 pcbp->type = type;
612
613 /* Link the pcb and the socket. */
614 so->so_pcb = (caddr_t)pcbp;
615 pcbp->ng_socket = so;
616
617 /* Add the socket to linked list */
618 mtx_lock(&ngsocketlist_mtx);
619 LIST_INSERT_HEAD(&ngsocklist, pcbp, socks);
620 mtx_unlock(&ngsocketlist_mtx);
621 return (0);
622}
623
624/*
625 * Disassociate the socket from it's protocol specific

Callers 2

ng_attach_cntlFunction · 0.85
ng_attach_dataFunction · 0.85

Calls 4

soreserveFunction · 0.85
mallocFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected