Lines Matching defs:inp

222  * must unlock the inp. However if a tunneling protocol is in place we increment
223 * the inpcb refcnt and unlock the inp, on return from the tunneling protocol we
225 * inp is gone, we return that to the caller to tell them *not* to unlock
226 * the inp. In the case of multi-cast this will cause the distribution
231 udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
243 INP_LOCK_ASSERT(inp);
248 up = intoudpcb(inp);
250 in_pcbref(inp);
251 INP_RUNLOCK(inp);
252 filtered = (*up->u_tun_func)(n, off, inp, (struct sockaddr *)&udp_in[0],
254 INP_RLOCK(inp);
256 return (in_pcbrele_rlocked(inp));
264 IPSEC_CHECK_POLICY(ipv4, n, inp) != 0) {
275 if (mac_inpcb_check_deliver(inp, n) != 0) {
280 if (inp->inp_flags & INP_CONTROLOPTS ||
281 inp->inp_socket->so_options & (SO_TIMESTAMP | SO_BINTIME)) {
283 if (inp->inp_vflag & INP_IPV6)
284 (void)ip6_savecontrol_v4(inp, n, &opts, NULL);
287 ip_savecontrol(inp, &opts, ip, n);
289 if ((inp->inp_vflag & INP_IPV4) && (inp->inp_flags2 & INP_ORIGDSTADDR)) {
302 if (inp->inp_vflag & INP_IPV6) {
313 so = inp->inp_socket;
327 udp_multi_match(const struct inpcb *inp, void *v)
332 if (inp->inp_lport != uh->uh_dport)
335 if ((inp->inp_vflag & INP_IPV4) == 0)
338 if (inp->inp_laddr.s_addr != INADDR_ANY &&
339 inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
341 if (inp->inp_faddr.s_addr != INADDR_ANY &&
342 inp->inp_faddr.s_addr != ip->ip_src.s_addr)
344 if (inp->inp_fport != 0 &&
345 inp->inp_fport != uh->uh_sport)
360 struct inpcb *inp;
366 while ((inp = inp_next(&inpi)) != NULL) {
382 imo = inp->inp_moptions;
404 UDPLITE_PROBE(receive, NULL, inp, ip, inp, uh);
406 UDP_PROBE(receive, NULL, inp, ip, inp, uh);
407 if (udp_append(inp, ip, n, sizeof(struct ip), udp_in)) {
420 if ((inp->inp_socket->so_options &
422 INP_RUNLOCK(inp);
450 struct inpcb *inp;
591 inp = in_pcblookup_mbuf(pcbinfo, ip->ip_src, uh->uh_sport,
593 if (!inp) {
599 inp = in_pcblookup(pcbinfo, ip->ip_src,
609 inp = in_pcblookup_mbuf(pcbinfo, ip->ip_src, uh->uh_sport,
612 if (inp == NULL) {
643 INP_RLOCK_ASSERT(inp);
644 if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl) {
646 UDPLITE_PROBE(receive, NULL, inp, ip, inp, uh);
648 UDP_PROBE(receive, NULL, inp, ip, inp, uh);
649 INP_RUNLOCK(inp);
656 up = intoudpcb(inp);
658 INP_RUNLOCK(inp);
665 UDPLITE_PROBE(receive, NULL, inp, ip, inp, uh);
667 UDP_PROBE(receive, NULL, inp, ip, inp, uh);
668 if (udp_append(inp, ip, m, iphlen, udp_in) == 0)
669 INP_RUNLOCK(inp);
683 udp_notify(struct inpcb *inp, int errno)
686 INP_WLOCK_ASSERT(inp);
688 errno == EHOSTDOWN) && inp->inp_route.ro_nh) {
689 NH_FREE(inp->inp_route.ro_nh);
690 inp->inp_route.ro_nh = (struct nhop_object *)NULL;
693 inp->inp_socket->so_error = errno;
694 sorwakeup(inp->inp_socket);
695 sowwakeup(inp->inp_socket);
696 return (inp);
705 struct inpcb *inp;
711 inp = in_pcblookup(pcbinfo, ip->ip_dst, uh->uh_dport, ip->ip_src,
713 if (inp != NULL) {
714 INP_WLOCK_ASSERT(inp);
715 if (inp->inp_socket != NULL)
716 udp_notify(inp, icmp_errmap(icmp));
717 INP_WUNLOCK(inp);
719 inp = in_pcblookup(pcbinfo, ip->ip_dst, uh->uh_dport,
722 if (inp != NULL) {
726 up = intoudpcb(inp);
728 INP_RUNLOCK(inp);
756 struct inpcb *inp;
783 while ((inp = inp_next(&inpi)) != NULL) {
784 if (inp->inp_gencnt <= xig.xig_gen &&
785 cr_canseeinpcb(req->td->td_ucred, inp) == 0) {
788 in_pcbtoxinpcb(inp, &xi);
791 INP_RUNLOCK(inp);
825 struct inpcb *inp;
835 inp = in_pcblookup(&V_udbinfo, addrs[1].sin_addr, addrs[1].sin_port,
839 if (inp != NULL) {
840 INP_RLOCK_ASSERT(inp);
841 if (inp->inp_socket == NULL)
844 error = cr_canseeinpcb(req->td->td_ucred, inp);
846 cru2x(inp->inp_cred, &xuc);
847 INP_RUNLOCK(inp);
864 struct inpcb *inp;
870 inp = sotoinpcb(so);
871 KASSERT(inp != NULL, ("%s: inp == NULL", __func__));
872 INP_WLOCK(inp);
876 INP_WUNLOCK(inp);
885 INP_WUNLOCK(inp);
901 INP_WUNLOCK(inp);
904 error = UDPENCAP_PCBCTL(ipv4, inp, sopt);
911 INP_WUNLOCK(inp);
914 error = UDPENCAP_PCBCTL(ipv6, inp, sopt);
918 INP_WUNLOCK(inp);
926 INP_WUNLOCK(inp);
930 INP_WUNLOCK(inp);
935 inp = sotoinpcb(so);
936 KASSERT(inp != NULL, ("%s: inp == NULL", __func__));
937 INP_WLOCK(inp);
938 up = intoudpcb(inp);
941 INP_WUNLOCK(inp);
949 INP_WUNLOCK(inp);
952 INP_WUNLOCK(inp);
965 INP_WUNLOCK(inp);
968 error = UDPENCAP_PCBCTL(ipv4, inp, sopt);
975 INP_WUNLOCK(inp);
978 error = UDPENCAP_PCBCTL(ipv6, inp, sopt);
982 INP_WUNLOCK(inp);
990 INP_WUNLOCK(inp);
994 up = intoudpcb(inp);
1000 INP_WUNLOCK(inp);
1004 INP_WUNLOCK(inp);
1018 struct inpcb *inp, int flags)
1063 src->sin_port = inp->inp_lport;
1074 struct inpcb *inp;
1092 inp = sotoinpcb(so);
1093 KASSERT(inp != NULL, ("udp_send: inp == NULL"));
1127 use_cached_route = sin == NULL || (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0);
1129 INP_WLOCK(inp);
1131 INP_RLOCK(inp);
1133 tos = inp->inp_ip_tos;
1154 error = udp_v4mapped_pktinfo(cm, &src, inp, flags);
1171 src.sin_port = inp->inp_lport;
1222 pr = inp->inp_socket->so_proto->pr_protocol;
1230 laddr = inp->inp_laddr;
1231 lport = inp->inp_lport;
1240 vflagsav = inp->inp_vflag;
1241 inp->inp_vflag |= INP_IPV4;
1242 inp->inp_vflag &= ~INP_IPV6;
1245 error = in_pcbbind_setup(inp, &src, &laddr.s_addr, &lport,
1249 inp->inp_vflag = vflagsav;
1263 INP_LOCK_ASSERT(inp);
1264 if (inp->inp_faddr.s_addr != INADDR_ANY) {
1288 if (inp->inp_laddr.s_addr == INADDR_ANY ||
1289 inp->inp_lport == 0 ||
1293 vflagsav = inp->inp_vflag;
1294 inp->inp_vflag |= INP_IPV4;
1295 inp->inp_vflag &= ~INP_IPV6;
1298 error = in_pcbconnect_setup(inp, sin, &laddr.s_addr,
1301 inp->inp_vflag = vflagsav;
1312 if (inp->inp_laddr.s_addr == INADDR_ANY &&
1313 inp->inp_lport == 0) {
1314 INP_WLOCK_ASSERT(inp);
1320 inp->inp_laddr = laddr;
1321 inp->inp_lport = lport;
1322 error = in_pcbinshash(inp);
1325 inp->inp_lport = 0;
1329 inp->inp_flags |= INP_ANONPORT;
1337 INP_LOCK_ASSERT(inp);
1338 faddr = inp->inp_faddr;
1339 fport = inp->inp_fport;
1381 up = intoudpcb(inp);
1395 if (inp->inp_socket->so_options & SO_DONTROUTE)
1397 if (inp->inp_socket->so_options & SO_BROADCAST)
1399 if (inp->inp_flags & INP_ONESBCAST)
1403 mac_inpcb_create_mbuf(inp, m);
1411 if (inp->inp_flags & INP_ONESBCAST)
1421 if (inp->inp_flags & INP_ONESBCAST)
1435 if (inp->inp_flags & INP_DONTFRAG)
1437 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl;
1461 * Don't override with the inp cached flowid value.
1463 * Depending upon the kind of send being done, the inp
1475 UDPLITE_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u);
1477 UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u);
1478 error = ip_output(m, inp->inp_options,
1479 use_cached_route ? &inp->inp_route : NULL, ipflags,
1480 inp->inp_moptions, inp);
1481 INP_UNLOCK(inp);
1486 INP_UNLOCK(inp);
1495 struct inpcb *inp;
1499 inp = sotoinpcb(so);
1500 KASSERT(inp != NULL, ("udp_abort: inp == NULL"));
1501 INP_WLOCK(inp);
1502 if (inp->inp_faddr.s_addr != INADDR_ANY) {
1504 in_pcbdisconnect(inp);
1508 INP_WUNLOCK(inp);
1516 struct inpcb *inp;
1521 inp = sotoinpcb(so);
1522 KASSERT(inp == NULL, ("udp_attach: inp != NULL"));
1530 inp = sotoinpcb(so);
1531 inp->inp_ip_ttl = V_ip_defttl;
1532 inp->inp_flowid = atomic_fetchadd_int(&udp_flowid, 1);
1533 inp->inp_flowtype = M_HASHTYPE_OPAQUE;
1534 up = intoudpcb(inp);
1536 INP_WUNLOCK(inp);
1545 struct inpcb *inp;
1550 inp = sotoinpcb(so);
1551 KASSERT(inp != NULL, ("udp_set_kernel_tunneling: inp == NULL"));
1552 INP_WLOCK(inp);
1553 up = intoudpcb(inp);
1556 INP_WUNLOCK(inp);
1562 INP_WUNLOCK(inp);
1570 struct inpcb *inp;
1576 inp = sotoinpcb(so);
1577 KASSERT(inp != NULL, ("udp_bind: inp == NULL"));
1593 INP_WLOCK(inp);
1595 error = in_pcbbind(inp, sinp, td->td_ucred);
1597 INP_WUNLOCK(inp);
1604 struct inpcb *inp;
1608 inp = sotoinpcb(so);
1609 KASSERT(inp != NULL, ("udp_close: inp == NULL"));
1610 INP_WLOCK(inp);
1611 if (inp->inp_faddr.s_addr != INADDR_ANY) {
1613 in_pcbdisconnect(inp);
1617 INP_WUNLOCK(inp);
1624 struct inpcb *inp;
1630 inp = sotoinpcb(so);
1631 KASSERT(inp != NULL, ("udp_connect: inp == NULL"));
1639 INP_WLOCK(inp);
1640 if (inp->inp_faddr.s_addr != INADDR_ANY) {
1641 INP_WUNLOCK(inp);
1646 INP_WUNLOCK(inp);
1651 error = in_pcbconnect(inp, sin, td->td_ucred);
1656 INP_WUNLOCK(inp);
1663 struct inpcb *inp;
1665 inp = sotoinpcb(so);
1666 KASSERT(inp != NULL, ("udp_detach: inp == NULL"));
1667 KASSERT(inp->inp_faddr.s_addr == INADDR_ANY,
1669 INP_WLOCK(inp);
1670 in_pcbfree(inp);
1676 struct inpcb *inp;
1680 inp = sotoinpcb(so);
1681 KASSERT(inp != NULL, ("udp_disconnect: inp == NULL"));
1682 INP_WLOCK(inp);
1683 if (inp->inp_faddr.s_addr == INADDR_ANY) {
1684 INP_WUNLOCK(inp);
1688 in_pcbdisconnect(inp);
1693 INP_WUNLOCK(inp);