diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -490,7 +490,6 @@ inp_inpcbtotcpcb(struct inpcb *inp); void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, uint32_t *faddr, uint16_t *fp); -int inp_so_options(const struct inpcb *inp); #endif /* _KERNEL */ @@ -597,9 +596,9 @@ /* 0x00000001 */ /* 0x00000002 */ /* 0x00000004 */ -#define INP_REUSEPORT 0x00000008 /* SO_REUSEPORT option is set */ +/* 0x00000008 */ /* 0x00000010 */ -#define INP_REUSEADDR 0x00000020 /* SO_REUSEADDR option is set */ +/* 0x00000020 */ /* 0x00000040 */ /* 0x00000080 */ #define INP_RECVFLOWID 0x00000100 /* populate recv datagram with flow info */ @@ -607,7 +606,7 @@ #define INP_RATE_LIMIT_CHANGED 0x00000400 /* rate limit needs attention */ #define INP_ORIGDSTADDR 0x00000800 /* receive IP dst address/port */ /* 0x00001000 */ -#define INP_REUSEPORT_LB 0x00002000 /* SO_REUSEPORT_LB option is set */ +/* 0x00002000 */ /* 0x00004000 */ /* 0x00008000 */ /* 0x00010000 */ diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -850,25 +850,6 @@ return (in_pcb_lport_dest(inp, laddrp ? (struct sockaddr *) &laddr : NULL, lportp, NULL, 0, cred, lookupflags)); } - -/* - * Return cached socket options. - */ -int -inp_so_options(const struct inpcb *inp) -{ - int so_options; - - so_options = 0; - - if ((inp->inp_flags2 & INP_REUSEPORT_LB) != 0) - so_options |= SO_REUSEPORT_LB; - if ((inp->inp_flags2 & INP_REUSEPORT) != 0) - so_options |= SO_REUSEPORT; - if ((inp->inp_flags2 & INP_REUSEADDR) != 0) - so_options |= SO_REUSEADDR; - return (so_options); -} #endif /* INET || INET6 */ #ifdef INET @@ -979,16 +960,16 @@ ntohl(t->inp_faddr.s_addr) == INADDR_ANY) && (ntohl(sin->sin_addr.s_addr) != INADDR_ANY || ntohl(t->inp_laddr.s_addr) != INADDR_ANY || - (t->inp_flags2 & INP_REUSEPORT) || - (t->inp_flags2 & INP_REUSEPORT_LB) == 0) && + (t->inp_socket->so_options & SO_REUSEPORT) || + (t->inp_socket->so_options & SO_REUSEPORT_LB) == 0) && (inp->inp_cred->cr_uid != t->inp_cred->cr_uid)) return (EADDRINUSE); } t = in_pcblookup_local(pcbinfo, sin->sin_addr, lport, lookupflags, cred); - if (t != NULL && (reuseport & inp_so_options(t)) == 0 && - (reuseport_lb & inp_so_options(t)) == 0) { + if (t != NULL && (reuseport & t->inp_socket->so_options) == 0 && + (reuseport_lb & t->inp_socket->so_options) == 0) { #ifdef INET6 if (ntohl(sin->sin_addr.s_addr) != INADDR_ANY || @@ -2658,7 +2639,7 @@ * Add entry to load balance group. * Only do this if SO_REUSEPORT_LB is set. */ - if ((inp->inp_flags2 & INP_REUSEPORT_LB) != 0) { + if ((inp->inp_socket->so_options & SO_REUSEPORT_LB) != 0) { int error = in_pcbinslbgrouphash(inp, M_NODOM); if (error != 0) return (error); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1084,33 +1084,6 @@ if (sopt->sopt_level == SOL_SOCKET && sopt->sopt_dir == SOPT_SET) { switch (sopt->sopt_name) { - case SO_REUSEADDR: - INP_WLOCK(inp); - if ((so->so_options & SO_REUSEADDR) != 0) - inp->inp_flags2 |= INP_REUSEADDR; - else - inp->inp_flags2 &= ~INP_REUSEADDR; - INP_WUNLOCK(inp); - error = 0; - break; - case SO_REUSEPORT: - INP_WLOCK(inp); - if ((so->so_options & SO_REUSEPORT) != 0) - inp->inp_flags2 |= INP_REUSEPORT; - else - inp->inp_flags2 &= ~INP_REUSEPORT; - INP_WUNLOCK(inp); - error = 0; - break; - case SO_REUSEPORT_LB: - INP_WLOCK(inp); - if ((so->so_options & SO_REUSEPORT_LB) != 0) - inp->inp_flags2 |= INP_REUSEPORT_LB; - else - inp->inp_flags2 &= ~INP_REUSEPORT_LB; - INP_WUNLOCK(inp); - error = 0; - break; case SO_SETFIB: INP_WLOCK(inp); inp->inp_inc.inc_fibnum = so->so_fibnum; diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -256,8 +256,8 @@ IN6_IS_ADDR_UNSPECIFIED(&t->in6p_faddr)) && (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) || !IN6_IS_ADDR_UNSPECIFIED(&t->in6p_laddr) || - (t->inp_flags2 & INP_REUSEPORT) || - (t->inp_flags2 & INP_REUSEPORT_LB) == 0) && + (t->inp_socket->so_options & SO_REUSEPORT) || + (t->inp_socket->so_options & SO_REUSEPORT_LB) == 0) && (inp->inp_cred->cr_uid != t->inp_cred->cr_uid)) return (EADDRINUSE); @@ -283,8 +283,8 @@ } t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, lport, lookupflags, cred); - if (t && (reuseport & inp_so_options(t)) == 0 && - (reuseport_lb & inp_so_options(t)) == 0) { + if (t && (reuseport & t->inp_socket->so_options) == 0 && + (reuseport_lb & t->inp_socket->so_options) == 0) { return (EADDRINUSE); } #ifdef INET @@ -296,8 +296,8 @@ t = in_pcblookup_local(pcbinfo, sin.sin_addr, lport, lookupflags, cred); if (t && - (reuseport & inp_so_options(t)) == 0 && - (reuseport_lb & inp_so_options(t)) == 0 && + (reuseport & t->inp_socket->so_options) == 0 && + (reuseport_lb & t->inp_socket->so_options) == 0 && (ntohl(t->inp_laddr.s_addr) != INADDR_ANY || (t->inp_vflag & INP_IPV6PROTO) != 0)) { return (EADDRINUSE); diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1641,33 +1641,6 @@ if (sopt->sopt_level == SOL_SOCKET && sopt->sopt_dir == SOPT_SET) { switch (sopt->sopt_name) { - case SO_REUSEADDR: - INP_WLOCK(inp); - if ((so->so_options & SO_REUSEADDR) != 0) - inp->inp_flags2 |= INP_REUSEADDR; - else - inp->inp_flags2 &= ~INP_REUSEADDR; - INP_WUNLOCK(inp); - error = 0; - break; - case SO_REUSEPORT: - INP_WLOCK(inp); - if ((so->so_options & SO_REUSEPORT) != 0) - inp->inp_flags2 |= INP_REUSEPORT; - else - inp->inp_flags2 &= ~INP_REUSEPORT; - INP_WUNLOCK(inp); - error = 0; - break; - case SO_REUSEPORT_LB: - INP_WLOCK(inp); - if ((so->so_options & SO_REUSEPORT_LB) != 0) - inp->inp_flags2 |= INP_REUSEPORT_LB; - else - inp->inp_flags2 &= ~INP_REUSEPORT_LB; - INP_WUNLOCK(inp); - error = 0; - break; case SO_SETFIB: INP_WLOCK(inp); inp->inp_inc.inc_fibnum = so->so_fibnum;