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

Function udp_connect

freebsd/netinet/udp_usrreq.c:1654–1686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1652}
1653
1654static int
1655udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
1656{
1657 struct epoch_tracker et;
1658 struct inpcb *inp;
1659 struct inpcbinfo *pcbinfo;
1660 struct sockaddr_in *sin;
1661 int error;
1662
1663 pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
1664 inp = sotoinpcb(so);
1665 KASSERT(inp != NULL, ("udp_connect: inp == NULL"));
1666 INP_WLOCK(inp);
1667 if (inp->inp_faddr.s_addr != INADDR_ANY) {
1668 INP_WUNLOCK(inp);
1669 return (EISCONN);
1670 }
1671 sin = (struct sockaddr_in *)nam;
1672 error = prison_remote_ip4(td->td_ucred, &sin->sin_addr);
1673 if (error != 0) {
1674 INP_WUNLOCK(inp);
1675 return (error);
1676 }
1677 NET_EPOCH_ENTER(et);
1678 INP_HASH_WLOCK(pcbinfo);
1679 error = in_pcbconnect(inp, nam, td->td_ucred);
1680 INP_HASH_WUNLOCK(pcbinfo);
1681 NET_EPOCH_EXIT(et);
1682 if (error == 0)
1683 soisconnected(so);
1684 INP_WUNLOCK(inp);
1685 return (error);
1686}
1687
1688static void
1689udp_detach(struct socket *so)

Callers

nothing calls this directly

Calls 4

in_pcbconnectFunction · 0.85
soisconnectedFunction · 0.85
udp_get_inpcbinfoFunction · 0.70
prison_remote_ip4Function · 0.70

Tested by

no test coverage detected