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

Function udp_attach

freebsd/netinet/udp_usrreq.c:1550–1588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1548}
1549
1550static int
1551udp_attach(struct socket *so, int proto, struct thread *td)
1552{
1553 static uint32_t udp_flowid;
1554 struct inpcb *inp;
1555 struct inpcbinfo *pcbinfo;
1556 int error;
1557
1558 pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
1559 inp = sotoinpcb(so);
1560 KASSERT(inp == NULL, ("udp_attach: inp != NULL"));
1561 error = soreserve(so, udp_sendspace, udp_recvspace);
1562 if (error)
1563 return (error);
1564 INP_INFO_WLOCK(pcbinfo);
1565 error = in_pcballoc(so, pcbinfo);
1566 if (error) {
1567 INP_INFO_WUNLOCK(pcbinfo);
1568 return (error);
1569 }
1570
1571 inp = sotoinpcb(so);
1572 inp->inp_vflag |= INP_IPV4;
1573 inp->inp_ip_ttl = V_ip_defttl;
1574 inp->inp_flowid = atomic_fetchadd_int(&udp_flowid, 1);
1575 inp->inp_flowtype = M_HASHTYPE_OPAQUE;
1576
1577 error = udp_newudpcb(inp);
1578 if (error) {
1579 in_pcbdetach(inp);
1580 in_pcbfree(inp);
1581 INP_INFO_WUNLOCK(pcbinfo);
1582 return (error);
1583 }
1584
1585 INP_WUNLOCK(inp);
1586 INP_INFO_WUNLOCK(pcbinfo);
1587 return (0);
1588}
1589#endif /* INET */
1590
1591int

Callers

nothing calls this directly

Calls 7

soreserveFunction · 0.85
in_pcballocFunction · 0.85
udp_newudpcbFunction · 0.85
in_pcbdetachFunction · 0.85
in_pcbfreeFunction · 0.85
udp_get_inpcbinfoFunction · 0.70
atomic_fetchadd_intFunction · 0.50

Tested by

no test coverage detected