Lines Matching defs:inp
126 in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred)
128 struct socket *so = inp->inp_socket;
132 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
135 INP_WLOCK_ASSERT(inp);
139 ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0));
147 inp->inp_flags |= INP_ANONPORT;
149 error = in_pcb_lport(inp, NULL, &lport, cred, lookupflags);
153 inp->inp_lport = lport;
154 if (in_pcbinshash(inp) != 0) {
155 inp->in6p_laddr = in6addr_any;
156 inp->inp_lport = 0;
167 in6_pcbbind_avail(struct inpcb *inp, const struct sockaddr_in6 *sin6,
174 INP_LOCK_ASSERT(inp);
175 INP_HASH_LOCK_ASSERT(inp->inp_pcbinfo);
211 NULL && (inp->inp_flags & INP_BINDANY) == 0) {
240 priv_check_cred(inp->inp_cred, PRIV_NETINET_REUSEPORT) !=
251 t = in6_pcblookup_local(inp->inp_pcbinfo, laddr, lport,
254 (inp->inp_socket->so_type != SOCK_STREAM ||
256 (inp->inp_cred->cr_uid != t->inp_cred->cr_uid))
260 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 &&
265 t = in_pcblookup_local(inp->inp_pcbinfo,
269 (inp->inp_socket->so_type != SOCK_STREAM ||
271 (inp->inp_cred->cr_uid !=
277 t = in6_pcblookup_local(inp->inp_pcbinfo, laddr, lport,
283 if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 &&
288 t = in_pcblookup_local(inp->inp_pcbinfo, sin.sin_addr,
303 in6_pcbbind(struct inpcb *inp, struct sockaddr_in6 *sin6, struct ucred *cred)
305 struct socket *so = inp->inp_socket;
309 INP_WLOCK_ASSERT(inp);
310 INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo);
312 if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
320 if ((error = prison_local_ip6(cred, &inp->in6p_laddr,
321 ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
333 ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
337 error = in6_pcbbind_avail(inp, sin6, sooptions, lookupflags,
343 inp->in6p_laddr = sin6->sin6_addr;
346 if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) {
348 inp->in6p_laddr = in6addr_any;
352 inp->inp_lport = lport;
353 if (in_pcbinshash(inp) != 0) {
354 inp->in6p_laddr = in6addr_any;
355 inp->inp_lport = 0;
374 in6_pcbladdr(struct inpcb *inp, struct sockaddr_in6 *sin6,
382 INP_WLOCK_ASSERT(inp);
383 INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); /* XXXRW: why? */
404 if ((error = prison_remote_ip6(inp->inp_cred, &sin6->sin6_addr)) != 0)
408 error = in6_selectsrc_socket(sin6, inp->in6p_outputopts,
409 inp, inp->inp_cred, scope_ambiguous, &in6a, NULL);
421 in6a = inp->in6p_laddr;
452 in6_pcbconnect(struct inpcb *inp, struct sockaddr_in6 *sin6, struct ucred *cred,
455 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
460 INP_WLOCK_ASSERT(inp);
466 KASSERT(IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr),
467 ("%s: inp is already connected", __func__));
476 hash_val = fib6_calc_software_hash(&inp->in6p_laddr,
478 inp->inp_socket->so_proto->pr_protocol, &hash_type);
479 inp->inp_flowid = hash_val;
480 inp->inp_flowtype = hash_type;
487 if ((error = in6_pcbladdr(inp, sin6, &laddr6.sin6_addr,
492 sin6->sin6_port, IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) ?
493 &laddr6.sin6_addr : &inp->in6p_laddr, inp->inp_lport, 0,
496 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
497 if (inp->inp_lport == 0) {
498 error = in_pcb_lport_dest(inp,
499 (struct sockaddr *) &laddr6, &inp->inp_lport,
505 inp->in6p_laddr = laddr6.sin6_addr;
507 inp->in6p_faddr = sin6->sin6_addr;
508 inp->inp_fport = sin6->sin6_port;
510 inp->inp_flow &= ~IPV6_FLOWLABEL_MASK;
511 if (inp->inp_flags & IN6P_AUTOFLOWLABEL)
512 inp->inp_flow |=
515 if ((inp->inp_flags & INP_INHASHLIST) != 0) {
516 in_pcbrehash(inp);
518 in_pcbinshash(inp);
525 in6_pcbdisconnect(struct inpcb *inp)
528 INP_WLOCK_ASSERT(inp);
529 INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo);
530 KASSERT(inp->inp_smr == SMR_SEQ_INVALID,
531 ("%s: inp %p was already disconnected", __func__, inp));
533 in_pcbremhash_locked(inp);
536 inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr);
539 memset(&inp->in6p_laddr, 0, sizeof(inp->in6p_laddr));
540 memset(&inp->in6p_faddr, 0, sizeof(inp->in6p_faddr));
541 inp->inp_fport = 0;
543 inp->inp_flow &= ~IPV6_FLOWLABEL_MASK;
549 struct inpcb *inp;
551 inp = sotoinpcb(so);
552 KASSERT(inp != NULL, ("in6_getsockaddr: inp == NULL"));
557 .sin6_port = inp->inp_lport,
558 .sin6_addr = inp->in6p_laddr,
569 struct inpcb *inp;
571 inp = sotoinpcb(so);
572 KASSERT(inp != NULL, ("in6_getpeeraddr: inp == NULL"));
577 .sin6_port = inp->inp_fport,
578 .sin6_addr = inp->in6p_faddr,
591 struct inpcb *inp;
593 inp = sotoinpcb(so);
594 KASSERT(inp != NULL, ("in6_mapped_sockaddr: inp == NULL"));
596 if ((inp->inp_vflag & (INP_IPV4 | INP_IPV6)) == INP_IPV4) {
617 struct inpcb *inp;
619 inp = sotoinpcb(so);
620 KASSERT(inp != NULL, ("in6_mapped_peeraddr: inp == NULL"));
622 if ((inp->inp_vflag & (INP_IPV4 | INP_IPV6)) == INP_IPV4) {
648 inp_match6(const struct inpcb *inp, void *v __unused)
651 return ((inp->inp_vflag & INP_IPV6) != 0);
662 struct inpcb *inp;
676 while ((inp = inp_next(&inpi)) != NULL) {
677 INP_WLOCK_ASSERT(inp);
685 ip6_notify_pmtu(inp, sa6_dst, *(uint32_t *)cmdarg);
696 inp->inp_socket != NULL &&
697 flowinfo == (inp->inp_flow & IPV6_FLOWLABEL_MASK) &&
698 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, &sa6_src.sin6_addr))
700 else if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr,
702 inp->inp_socket == 0 ||
703 (lport && inp->inp_lport != lport) ||
705 !IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr,
707 (fport && inp->inp_fport != fport)) {
713 (*notify)(inp, errno);
725 struct inpcb *inp;
741 CK_LIST_FOREACH(inp, head, inp_hash_wild) {
742 /* XXX inp locking */
743 if ((inp->inp_vflag & INP_IPV6) == 0)
745 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) &&
746 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) &&
747 inp->inp_lport == lport) {
750 inp->inp_cred->cr_prison))
751 return (inp);
779 CK_LIST_FOREACH(inp, &phd->phd_pcblist, inp_portlist) {
782 inp->inp_cred->cr_prison))
784 /* XXX inp locking */
785 if ((inp->inp_vflag & INP_IPV6) == 0)
787 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr))
790 &inp->in6p_laddr)) {
794 &inp->in6p_laddr, laddr))
801 match = inp;
813 in6_multi_match(const struct inpcb *inp, void *v __unused)
816 if ((inp->inp_vflag & INP_IPV6) && inp->in6p_moptions != NULL)
827 struct inpcb *inp;
834 while ((inp = inp_next(&inpi)) != NULL) {
835 INP_RLOCK_ASSERT(inp);
837 im6o = inp->in6p_moptions;
869 in6_losing(struct inpcb *inp)
872 RO_INVALIDATE_CACHE(&inp->inp_route6);
880 in6_rtchange(struct inpcb *inp, int errno __unused)
883 RO_INVALIDATE_CACHE(&inp->inp_route6);
884 return inp;
901 struct inpcb *inp;
970 inp = grp->il_inp[INP6_PCBLBGROUP_PKTHASH(faddr, lport, fport) % count];
971 KASSERT(inp != NULL, ("%s: inp == NULL", __func__));
972 return (inp);
976 in6_pcblookup_exact_match(const struct inpcb *inp, const struct in6_addr *faddr,
979 /* XXX inp locking */
980 if ((inp->inp_vflag & INP_IPV6) == 0)
982 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, faddr) &&
983 IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) &&
984 inp->inp_fport == fport && inp->inp_lport == lport)
995 struct inpcb *inp;
1004 CK_LIST_FOREACH(inp, head, inp_hash_exact) {
1005 if (in6_pcblookup_exact_match(inp, faddr, fport, laddr, lport))
1006 return (inp);
1018 in6_pcblookup_wild_match(const struct inpcb *inp, const struct in6_addr *laddr,
1021 /* XXX inp locking */
1022 if ((inp->inp_vflag & INP_IPV6) == 0)
1024 if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) ||
1025 inp->inp_lport != lport)
1027 if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
1029 if (IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr))
1041 struct inpcb *inp;
1048 CK_LIST_FOREACH(inp, head, inp_hash_wild) {
1051 match = in6_pcblookup_wild_match(inp, laddr, lport);
1055 if (__predict_true(inp_smr_lock(inp, lockflags))) {
1056 match = in6_pcblookup_wild_match(inp, laddr, lport);
1058 prison_check_ip6_locked(inp->inp_cred->cr_prison,
1060 return (inp);
1061 inp_unlock(inp, lockflags);
1078 struct inpcb *inp, *jail_wild, *local_exact, *local_wild;
1092 CK_LIST_FOREACH(inp, head, inp_hash_wild) {
1096 match = in6_pcblookup_wild_match(inp, laddr, lport);
1100 injail = prison_flag(inp->inp_cred, PR_IP6) != 0;
1103 inp->inp_cred->cr_prison, laddr) != 0)
1112 return (inp);
1114 local_exact = inp;
1117 jail_wild = inp;
1119 local_wild = inp;
1138 struct inpcb *inp;
1149 inp = in6_pcblookup_hash_exact(pcbinfo, faddr, fport, laddr, lport);
1150 if (inp != NULL)
1151 return (inp);
1154 inp = in6_pcblookup_lbgroup(pcbinfo, faddr, fport, laddr,
1156 if (inp == NULL) {
1157 inp = in6_pcblookup_hash_wild_locked(pcbinfo,
1161 return (inp);
1169 struct inpcb *inp;
1176 inp = in6_pcblookup_hash_locked(pcbinfo, faddr, fport, laddr, lport,
1178 if (inp != NULL && !inp_trylock(inp, lockflags)) {
1179 in_pcbref(inp);
1181 inp_lock(inp, lockflags);
1182 if (in_pcbrele(inp, lockflags))
1184 inp = NULL;
1188 return (inp);
1196 struct inpcb *inp;
1206 inp = in6_pcblookup_hash_exact(pcbinfo, faddr, fport, laddr, lport);
1207 if (inp != NULL) {
1208 if (__predict_true(inp_smr_lock(inp, lockflags))) {
1209 if (__predict_true(in6_pcblookup_exact_match(inp,
1211 return (inp);
1212 inp_unlock(inp, lockflags);
1223 inp = in6_pcblookup_lbgroup(pcbinfo, faddr, fport,
1225 if (inp != NULL) {
1226 if (__predict_true(inp_smr_lock(inp, lockflags))) {
1227 if (__predict_true(in6_pcblookup_wild_match(inp,
1229 return (inp);
1230 inp_unlock(inp, lockflags);
1232 inp = INP_LOOKUP_AGAIN;
1234 inp = in6_pcblookup_hash_wild_smr(pcbinfo, laddr, lport,
1237 if (inp == INP_LOOKUP_AGAIN) {
1243 if (inp == NULL)
1246 return (inp);