Lines Matching refs:inp

116 in6_pcbbind(struct inpcb *inp, struct sockaddr *nam,
119 struct socket *so = inp->inp_socket;
121 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
126 INP_WLOCK_ASSERT(inp);
131 if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
136 if ((error = prison_local_ip6(cred, &inp->in6p_laddr,
137 ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
153 ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
173 (inp->inp_flags & INP_BINDANY) == 0) {
203 priv_check_cred(inp->inp_cred,
209 ((inp->inp_flags2 & INP_BINDMULTI) == 0) &&
216 (inp->inp_cred->cr_uid !=
226 if (t && (! in_pcbbind_check_bindmulti(inp, t)))
230 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 &&
239 ((inp->inp_flags2 & INP_BINDMULTI) == 0) &&
245 (inp->inp_cred->cr_uid !=
249 if (t && (! in_pcbbind_check_bindmulti(inp, t)))
271 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 &&
284 INADDR_ANY || ((inp->inp_vflag &
296 inp->in6p_laddr = sin6->sin6_addr;
299 if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) {
301 inp->in6p_laddr = in6addr_any;
305 inp->inp_lport = lport;
306 if (in_pcbinshash(inp) != 0) {
307 inp->in6p_laddr = in6addr_any;
308 inp->inp_lport = 0;
327 in6_pcbladdr(struct inpcb *inp, struct sockaddr *nam,
335 INP_WLOCK_ASSERT(inp);
336 INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); /* XXXRW: why? */
358 if ((error = prison_remote_ip6(inp->inp_cred, &sin6->sin6_addr)) != 0)
361 error = in6_selectsrc_socket(sin6, inp->in6p_outputopts,
362 inp, inp->inp_cred, scope_ambiguous, &in6a, NULL);
392 in6_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr *nam,
395 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
400 INP_WLOCK_ASSERT(inp);
407 if ((error = in6_pcbladdr(inp, nam, &addr6)) != 0)
412 IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)
413 ? &addr6 : &inp->in6p_laddr,
414 inp->inp_lport, 0, NULL) != NULL) {
417 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
418 if (inp->inp_lport == 0) {
419 error = in6_pcbbind(inp, (struct sockaddr *)0, cred);
423 inp->in6p_laddr = addr6;
425 inp->in6p_faddr = sin6->sin6_addr;
426 inp->inp_fport = sin6->sin6_port;
428 inp->inp_flow &= ~IPV6_FLOWLABEL_MASK;
429 if (inp->inp_flags & IN6P_AUTOFLOWLABEL)
430 inp->inp_flow |=
433 in_pcbrehash_mbuf(inp, m);
439 in6_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred)
442 return (in6_pcbconnect_mbuf(inp, nam, cred, NULL));
446 in6_pcbdisconnect(struct inpcb *inp)
449 INP_WLOCK_ASSERT(inp);
450 INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo);
452 bzero((caddr_t)&inp->in6p_faddr, sizeof(inp->in6p_faddr));
453 inp->inp_fport = 0;
455 inp->inp_flow &= ~IPV6_FLOWLABEL_MASK;
456 in_pcbrehash(inp);
497 struct inpcb *inp;
501 inp = sotoinpcb(so);
502 KASSERT(inp != NULL, ("in6_getsockaddr: inp == NULL"));
504 INP_RLOCK(inp);
505 port = inp->inp_lport;
506 addr = inp->in6p_laddr;
507 INP_RUNLOCK(inp);
516 struct inpcb *inp;
520 inp = sotoinpcb(so);
521 KASSERT(inp != NULL, ("in6_getpeeraddr: inp == NULL"));
523 INP_RLOCK(inp);
524 port = inp->inp_fport;
525 addr = inp->in6p_faddr;
526 INP_RUNLOCK(inp);
535 struct inpcb *inp;
538 inp = sotoinpcb(so);
539 KASSERT(inp != NULL, ("in6_mapped_sockaddr: inp == NULL"));
542 if ((inp->inp_vflag & (INP_IPV4 | INP_IPV6)) == INP_IPV4) {
559 struct inpcb *inp;
562 inp = sotoinpcb(so);
563 KASSERT(inp != NULL, ("in6_mapped_peeraddr: inp == NULL"));
566 if ((inp->inp_vflag & (INP_IPV4 | INP_IPV6)) == INP_IPV4) {
593 struct inpcb *inp, *inp_temp;
630 LIST_FOREACH_SAFE(inp, pcbinfo->ipi_listhead, inp_list, inp_temp) {
631 INP_WLOCK(inp);
632 if ((inp->inp_vflag & INP_IPV6) == 0) {
633 INP_WUNLOCK(inp);
644 ip6_notify_pmtu(inp, (struct sockaddr_in6 *)dst,
656 inp->inp_socket != NULL &&
657 flowinfo == (inp->inp_flow & IPV6_FLOWLABEL_MASK) &&
658 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, &sa6_src.sin6_addr))
660 else if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr,
662 inp->inp_socket == 0 ||
663 (lport && inp->inp_lport != lport) ||
665 !IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr,
667 (fport && inp->inp_fport != fport)) {
668 INP_WUNLOCK(inp);
674 if ((*notify)(inp, errno))
675 INP_WUNLOCK(inp);
677 INP_WUNLOCK(inp);
690 struct inpcb *inp;
707 LIST_FOREACH(inp, head, inp_hash) {
708 /* XXX inp locking */
709 if ((inp->inp_vflag & INP_IPV6) == 0)
711 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) &&
712 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) &&
713 inp->inp_lport == lport) {
717 inp->inp_cred->cr_prison))
718 return (inp);
746 LIST_FOREACH(inp, &phd->phd_pcblist, inp_portlist) {
750 inp->inp_cred->cr_prison))
752 /* XXX inp locking */
753 if ((inp->inp_vflag & INP_IPV6) == 0)
755 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr))
758 &inp->in6p_laddr)) {
762 &inp->in6p_laddr, laddr))
769 match = inp;
845 in6_rtchange(struct inpcb *inp, int errno)
848 if (inp->inp_route6.ro_rt) {
849 RTFREE(inp->inp_route6.ro_rt);
850 inp->inp_route6.ro_rt = (struct rtentry *)NULL;
852 if (inp->inp_route.ro_lle)
853 LLE_FREE(inp->inp_route.ro_lle); /* zeros ro_lle */
854 return inp;
867 struct inpcb *inp, *tmpinp;
878 LIST_FOREACH(inp, head, inp_pcbgrouphash) {
879 /* XXX inp locking */
880 if ((inp->inp_vflag & INP_IPV6) == 0)
882 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, faddr) &&
883 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) &&
884 inp->inp_fport == fport &&
885 inp->inp_lport == lport) {
888 * the inp here, without any checks.
891 if (prison_flag(inp->inp_cred, PR_IP6))
894 tmpinp = inp;
898 inp = tmpinp;
919 LIST_FOREACH(inp, head, inp_pcbgrouphash) {
920 /* XXX inp locking */
921 if ((inp->inp_vflag & INP_IPV6) == 0)
924 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) ||
925 inp->inp_lport != lport) {
929 injail = prison_flag(inp->inp_cred, PR_IP6);
931 if (prison_check_ip6(inp->inp_cred,
939 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr)) {
943 local_exact = inp;
944 } else if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
946 jail_wild = inp;
948 local_wild = inp;
952 inp = jail_wild;
953 if (inp == NULL)
954 inp = jail_wild;
955 if (inp == NULL)
956 inp = local_exact;
957 if (inp == NULL)
958 inp = local_wild;
959 if (inp != NULL)
981 LIST_FOREACH(inp, head, inp_pcbgroup_wild) {
982 /* XXX inp locking */
983 if ((inp->inp_vflag & INP_IPV6) == 0)
986 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) ||
987 inp->inp_lport != lport) {
991 injail = prison_flag(inp->inp_cred, PR_IP6);
993 if (prison_check_ip6(inp->inp_cred,
1001 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr)) {
1005 local_exact = inp;
1006 } else if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
1008 jail_wild = inp;
1010 local_wild = inp;
1014 inp = jail_wild;
1015 if (inp == NULL)
1016 inp = jail_wild;
1017 if (inp == NULL)
1018 inp = local_exact;
1019 if (inp == NULL)
1020 inp = local_wild;
1021 if (inp != NULL)
1029 locked = INP_TRY_WLOCK(inp);
1031 locked = INP_TRY_RLOCK(inp);
1035 in_pcbref(inp);
1039 INP_WLOCK(inp);
1040 if (in_pcbrele_wlocked(inp))
1043 INP_RLOCK(inp);
1044 if (in_pcbrele_rlocked(inp))
1050 INP_WLOCK_ASSERT(inp);
1052 INP_RLOCK_ASSERT(inp);
1054 return (inp);
1067 struct inpcb *inp, *tmpinp;
1081 LIST_FOREACH(inp, head, inp_hash) {
1082 /* XXX inp locking */
1083 if ((inp->inp_vflag & INP_IPV6) == 0)
1085 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, faddr) &&
1086 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) &&
1087 inp->inp_fport == fport &&
1088 inp->inp_lport == lport) {
1091 * the inp here, without any checks.
1094 if (prison_flag(inp->inp_cred, PR_IP6))
1095 return (inp);
1097 tmpinp = inp;
1121 LIST_FOREACH(inp, head, inp_hash) {
1122 /* XXX inp locking */
1123 if ((inp->inp_vflag & INP_IPV6) == 0)
1126 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) ||
1127 inp->inp_lport != lport) {
1131 injail = prison_flag(inp->inp_cred, PR_IP6);
1133 if (prison_check_ip6(inp->inp_cred,
1141 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr)) {
1143 return (inp);
1145 local_exact = inp;
1146 } else if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
1148 jail_wild = inp;
1150 local_wild = inp;
1178 struct inpcb *inp;
1182 inp = in6_pcblookup_hash_locked(pcbinfo, faddr, fport, laddr, lport,
1184 if (inp != NULL) {
1186 locked = INP_TRY_WLOCK(inp);
1188 locked = INP_TRY_RLOCK(inp);
1192 in_pcbref(inp);
1196 INP_WLOCK(inp);
1197 if (in_pcbrele_wlocked(inp))
1200 INP_RLOCK(inp);
1201 if (in_pcbrele_rlocked(inp))
1207 INP_WLOCK_ASSERT(inp);
1209 INP_RLOCK_ASSERT(inp);
1213 return (inp);