From nobody Thu Jul 27 03:51:36 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RBGzD4JnZz4p90l; Thu, 27 Jul 2023 03:51:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RBGzD23JQz3Pp8; Thu, 27 Jul 2023 03:51:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690429896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Fs7vn0rGMMfs1OoDOqxwk7o9MHt+nYN3tW4hHEm4pzg=; b=t7DNu6ZqSX3lW0uNg6QY4DZqPD4YIdMoa3U5serRmGE+VW6LqT9uBk6smc2JDJSWoIaOsG wRLDjQy1G3bB2nsb0CICW4rG2kSl8vT6Ntgpq8u5E+t7Awu7035X9iCeklnkRymWL7+0er pfh/+Iv0DfgCLHHLM8vTMoKx90i+L14OrxEC3UH7taMP5SI1DNntvk5Ox6lyAUls5x46Ti KqG0gQMG5FOscf/t4TnMFEesYtj+wzNQBBpDTI2PR0xswE1PJsXb4QI8+nkrBV6y8uLm4R iMipuc5cmdgV6Gyve1pXLsKlqOhEqEKxnGncuoV80xCn7CZ1IsjDMHPWm6Vz3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690429896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Fs7vn0rGMMfs1OoDOqxwk7o9MHt+nYN3tW4hHEm4pzg=; b=lDl8QSz0LTnBjq3dRierSGifFfepHBUcQJIkSfYNQm/3AVlkMs9unwPJHYszsx+5IXAy30 H2PzPBAQi9WI5G2wXn7W915gAxMC0BZwvwqWw7VFugpYdnX6sWzBNcd1BhF7vdKpRb78gK RBjaTyf2dRGpiwuxJA4nWCmu572XWhRu20A2vcQKT4LrQ83WecbpCkf3BZfXW44Sr8/sKk O2bGqVgx72JBU/rwZT4KdOig0ZMfdtbksGtGQlZ3RwknnJNOUsF83lLXI+KQAHDQ1jALo+ ag92YU2fHTnE7Nqbl+hHNEhsJS7s4OaIwxvxohLhv5jiiZTEVQVNm5QoOb/3EQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690429896; a=rsa-sha256; cv=none; b=CzaL1jjrKlaAiGGZ4TKnOVkSGBc3LCqwbGLDvUrn0YVge3WmZyG9KyUewypScAV51iOqRM 7cJDpDuFE25kf0bZar0PUpt3v28u/PO/6Mo4dj75Ihrx1tv58g6fYrgWWI49HoQDXeYh+1 Ahv7Ic1lV5OiDRhFf9t26lBoadhhNao+3aR89k4JT2pfA1yMSMlpsarvn/q0jg2eiMfww0 kiu4ZRFRG+DTfnhczdj9I+2/9ayX+kmVfuiFaPicmEazOJz+9b2/M0/MJJ9YFz8VDuo/gy bffHjiqW22ihjXg7dhaytXodjPTArBDvDWxWOeDqsdBhSxt9qSSRUUf0MZBX8g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RBGzD0mhjz18YL; Thu, 27 Jul 2023 03:51:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36R3panH060604; Thu, 27 Jul 2023 03:51:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36R3pa8o060603; Thu, 27 Jul 2023 03:51:36 GMT (envelope-from git) Date: Thu, 27 Jul 2023 03:51:36 GMT Message-Id: <202307270351.36R3pa8o060603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: e3ba0d6adde3 - main - inpcb: do not copy so_options into inp_flags2 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e3ba0d6adde3c694f46a30b3b67eba43a7099395 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=e3ba0d6adde3c694f46a30b3b67eba43a7099395 commit e3ba0d6adde3c694f46a30b3b67eba43a7099395 Author: Gleb Smirnoff AuthorDate: 2023-07-27 03:35:41 +0000 Commit: Gleb Smirnoff CommitDate: 2023-07-27 03:35:42 +0000 inpcb: do not copy so_options into inp_flags2 Since f71cb9f74808 socket stays connnected with inpcb through latter's lifetime and there is no reason to complicate things and copy these flags. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D41198 --- sys/netinet/in_pcb.c | 29 +++++------------------------ sys/netinet/in_pcb.h | 7 +++---- sys/netinet/ip_output.c | 27 --------------------------- sys/netinet6/in6_pcb.c | 12 ++++++------ sys/netinet6/ip6_output.c | 27 --------------------------- 5 files changed, 14 insertions(+), 88 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 44775e21e201..e7b5e3221ae4 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -850,25 +850,6 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp, 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 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr_in *sin, in_addr_t *laddrp, 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 @@ in_pcbinshash(struct inpcb *inp) * 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/in_pcb.h b/sys/netinet/in_pcb.h index a989776105fb..44e9cfd3c861 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -490,7 +490,6 @@ struct tcpcb * 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 @@ int inp_so_options(const struct inpcb *inp); /* 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 @@ int inp_so_options(const struct inpcb *inp); #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/ip_output.c b/sys/netinet/ip_output.c index 3f30c63cdc87..9c4d98a979ee 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1084,33 +1084,6 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) 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 index 43f567461598..c43d4e804b46 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -256,8 +256,8 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr_in6 *sin6, struct ucred *cred) 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 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr_in6 *sin6, struct ucred *cred) } 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 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr_in6 *sin6, struct ucred *cred) 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 index 7e3c98270cc2..2a447a8a738f 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1641,33 +1641,6 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt) 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;