| 1652 | } |
| 1653 | |
| 1654 | static int |
| 1655 | udp_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 | |
| 1688 | static void |
| 1689 | udp_detach(struct socket *so) |
nothing calls this directly
no test coverage detected