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

Function div_attach

freebsd/netinet/ip_divert.c:560–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558}
559
560static int
561div_attach(struct socket *so, int proto, struct thread *td)
562{
563 struct inpcb *inp;
564 int error;
565
566 inp = sotoinpcb(so);
567 KASSERT(inp == NULL, ("div_attach: inp != NULL"));
568 if (td != NULL) {
569 error = priv_check(td, PRIV_NETINET_DIVERT);
570 if (error)
571 return (error);
572 }
573 error = soreserve(so, div_sendspace, div_recvspace);
574 if (error)
575 return error;
576 INP_INFO_WLOCK(&V_divcbinfo);
577 error = in_pcballoc(so, &V_divcbinfo);
578 if (error) {
579 INP_INFO_WUNLOCK(&V_divcbinfo);
580 return error;
581 }
582 inp = (struct inpcb *)so->so_pcb;
583 INP_INFO_WUNLOCK(&V_divcbinfo);
584 inp->inp_ip_p = proto;
585 inp->inp_vflag |= INP_IPV4;
586 inp->inp_flags |= INP_HDRINCL;
587 INP_WUNLOCK(inp);
588 return 0;
589}
590
591static void
592div_detach(struct socket *so)

Callers

nothing calls this directly

Calls 3

soreserveFunction · 0.85
in_pcballocFunction · 0.85
priv_checkFunction · 0.50

Tested by

no test coverage detected