| 1548 | } |
| 1549 | |
| 1550 | static int |
| 1551 | udp_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 | |
| 1591 | int |
nothing calls this directly
no test coverage detected