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

Function ng_attach_cntl

freebsd/netgraph/ng_socket.c:542–586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540 */
541
542static int
543ng_attach_cntl(struct socket *so)
544{
545 struct ngsock *priv;
546 struct ngpcb *pcbp;
547 node_p node;
548 int error;
549
550 /* Setup protocol control block */
551 if ((error = ng_attach_common(so, NG_CONTROL)) != 0)
552 return (error);
553 pcbp = sotongpcb(so);
554
555 /* Make the generic node components */
556 if ((error = ng_make_node_common(&typestruct, &node)) != 0) {
557 ng_detach_common(pcbp, NG_CONTROL);
558 return (error);
559 }
560
561 /*
562 * Allocate node private info and hash. We start
563 * with 16 hash entries, however we may grow later
564 * in ngs_newhook(). We can't predict how much hooks
565 * does this node plan to have.
566 */
567 priv = malloc(sizeof(*priv), M_NETGRAPH_SOCK, M_WAITOK | M_ZERO);
568 priv->hash = hashinit(16, M_NETGRAPH_SOCK, &priv->hmask);
569
570 /* Initialize mutex. */
571 mtx_init(&priv->mtx, "ng_socket", NULL, MTX_DEF);
572
573 /* Link the pcb the private data. */
574 priv->ctlsock = pcbp;
575 pcbp->sockdata = priv;
576 priv->refs++;
577 priv->node = node;
578 pcbp->node_id = node->nd_ID; /* hint for netstat(1) */
579
580 /* Link the node and the private data. */
581 NG_NODE_SET_PRIVATE(priv->node, priv);
582 NG_NODE_REF(priv->node);
583 priv->refs++;
584
585 return (0);
586}
587
588static int
589ng_attach_data(struct socket *so)

Callers 1

ngc_attachFunction · 0.85

Calls 6

ng_attach_commonFunction · 0.85
ng_detach_commonFunction · 0.85
mallocFunction · 0.85
mtx_initFunction · 0.85
ng_make_node_commonFunction · 0.70
hashinitFunction · 0.50

Tested by

no test coverage detected