From nobody Wed Aug 10 18:10:26 2022 X-Original-To: dev-commits-src-all@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 4M2yfB6Pbmz4Ylp0; Wed, 10 Aug 2022 18:10:26 +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 4M2yfB5rzRz3MhD; Wed, 10 Aug 2022 18:10:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660155026; 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=Ae4+rM/fM4NHGX5rhePDb/vgqWqIjh4dMfNQO73P/mo=; b=GH4j5esGHH4Sj4U1YHbw5uV0roHnoLPR9SUKS+e5FoY2BoUf2DREp/lGesug6PIuJDEMRH osJ5sMOeqA/RAmbrBQjdZg67SvprR4rdfl8aWkEIwIwMst5NmiQL6zNC34nvR6av7TdOs8 omnX3KX9RMDsswmpTyECo2KlA4YdnLmKyilqXwgTR1JF2jNq1UWqqmBzB5Sl7lER0KtZlP qY1Zbf6SZSthMbX0fGfZ2yChL6fvWQeaNmbuM+h/TKg3w8G2fNnrlWnEeKaTjQuhl0ZTmN 2/AFqkMKXPZcquPf540854noIvKQ+/O9h4sA73YkzAwIlJIETYKAKF30d6m4XQ== 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 4M2yfB4nXKzLJQ; Wed, 10 Aug 2022 18:10:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27AIAQOm043975; Wed, 10 Aug 2022 18:10:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27AIAQIw043974; Wed, 10 Aug 2022 18:10:26 GMT (envelope-from git) Date: Wed, 10 Aug 2022 18:10:26 GMT Message-Id: <202208101810.27AIAQIw043974@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: c7a62c925c81 - main - inpcb: gather v4/v6 handling code into in_pcballoc() from protocols List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: c7a62c925c814885b36a9ca900fbf258cafdb247 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660155026; 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=Ae4+rM/fM4NHGX5rhePDb/vgqWqIjh4dMfNQO73P/mo=; b=d/ouKjb3Azup9xW/oGq8uhYu0vNzFwZPT6hJNxWyeocNGeH5gEs0bhEvizQ/D2md9lnkDh 6L49WkQENTaQdTVXL32PQUydPJXb1PSJeh4HZZb7127r5d6lCZkv1gd0NUjPsWpojmM7Aq l0UOHSOJClciZJWTSv61u2XmlLQVN+pufD/R1rS2A+H3/wURk4CbCbBTZD+17FPmqwfEDf y/BNgBtFaqcl1z2eOl2vZ2suGMjGR9T6q6VQuxayEoe4C3zxtU8NqJ2a+LqZ6ZABPbDqaY Jd5knKnPH/OpwIWUWTlUupz08oCMO7KaPfbVlMXbrWcSiT0jb3hx7tgkynCFgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660155026; a=rsa-sha256; cv=none; b=P3JO1GJFvOGlYnEqdfFxIu9RTfK/pgHG2W3bb6njoBDbNaKy6lq1VmuJusT0drububqjap mjloD98TwGYQ+AaMzSxDB4s5emdQ2feicR8PJqm5VkK3bn7bAPDtfzehCyJeIfObBl9G2B j7tLkbDGPR6ZvOUtycBJTobCWwFo7fIYkgK2kZQ25JzL3V4KXcEyDxZvIPNbjd1rFLs9ik LxLYDuNrdi7dNz+VPi9SpL7eMPQ3rifG2fR6Cbh7hOaW5yJ8E2h46XQoAEZ+A2LUjy3rNz wEz5q1t15S56b8u7H2g/VtiW6TJkx3xV5mUp8QsS6ZJDgjH1mbv5EoJwvBzsKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c7a62c925c814885b36a9ca900fbf258cafdb247 commit c7a62c925c814885b36a9ca900fbf258cafdb247 Author: Gleb Smirnoff AuthorDate: 2022-08-10 18:09:34 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-10 18:09:34 +0000 inpcb: gather v4/v6 handling code into in_pcballoc() from protocols Reviewed by: rrs, tuexen Differential revision: https://reviews.freebsd.org/D36062 --- sys/netinet/in_pcb.c | 17 ++++++++++++++--- sys/netinet/ip_divert.c | 1 - sys/netinet/raw_ip.c | 1 - sys/netinet/tcp_usrreq.c | 10 ---------- sys/netinet/udp_usrreq.c | 1 - sys/netinet6/raw_ip6.c | 2 -- sys/netinet6/udp6_usrreq.c | 4 ---- 7 files changed, 14 insertions(+), 22 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 321af17a4767..7033ad05cab7 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -635,12 +635,23 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo) #endif /*IPSEC*/ #ifdef INET6 if (INP_SOCKAF(so) == AF_INET6) { - inp->inp_vflag |= INP_IPV6PROTO; + inp->inp_vflag |= INP_IPV6PROTO | INP_IPV6; if (V_ip6_v6only) inp->inp_flags |= IN6P_IPV6_V6ONLY; +#ifdef INET + else + inp->inp_vflag |= INP_IPV4; +#endif + if (V_ip6_auto_flowlabel) + inp->inp_flags |= IN6P_AUTOFLOWLABEL; + inp->in6p_hops = -1; /* use kernel default */ } - if (V_ip6_auto_flowlabel) - inp->inp_flags |= IN6P_AUTOFLOWLABEL; +#endif +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET + inp->inp_vflag |= INP_IPV4; #endif /* * Routes in inpcb's can cache L2 as well; they are guaranteed diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index a745073d1ec0..c149a2a2c416 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -593,7 +593,6 @@ div_attach(struct socket *so, int proto, struct thread *td) return error; inp = (struct inpcb *)so->so_pcb; inp->inp_ip_p = proto; - inp->inp_vflag |= INP_IPV4; inp->inp_flags |= INP_HDRINCL; INP_WUNLOCK(inp); return 0; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index cd048284c5e8..1f631e108a49 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -857,7 +857,6 @@ rip_attach(struct socket *so, int proto, struct thread *td) if (error) return (error); inp = (struct inpcb *)so->so_pcb; - inp->inp_vflag |= INP_IPV4; inp->inp_ip_p = proto; inp->inp_ip_ttl = V_ip_defttl; INP_HASH_WLOCK(&V_ripcbinfo); diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 158ed5d9658c..9280e4310bc3 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -184,16 +184,6 @@ tcp_usr_attach(struct socket *so, int proto, struct thread *td) if (error) goto out; inp = sotoinpcb(so); -#ifdef INET6 - if (inp->inp_vflag & INP_IPV6PROTO) { - inp->inp_vflag |= INP_IPV6; - if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) - inp->inp_vflag |= INP_IPV4; - inp->in6p_hops = -1; /* use kernel default */ - } - else -#endif - inp->inp_vflag |= INP_IPV4; tp = tcp_newtcpcb(inp); if (tp == NULL) { error = ENOBUFS; diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 3b3bb71339d4..86093806dccc 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1529,7 +1529,6 @@ udp_attach(struct socket *so, int proto, struct thread *td) return (error); inp = sotoinpcb(so); - inp->inp_vflag |= INP_IPV4; inp->inp_ip_ttl = V_ip_defttl; inp->inp_flowid = atomic_fetchadd_int(&udp_flowid, 1); inp->inp_flowtype = M_HASHTYPE_OPAQUE; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index be7c57a52cfe..ab0b6771fe99 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -658,9 +658,7 @@ rip6_attach(struct socket *so, int proto, struct thread *td) return (error); } inp = (struct inpcb *)so->so_pcb; - inp->inp_vflag |= INP_IPV6; inp->inp_ip_p = (long)proto; - inp->in6p_hops = -1; /* use kernel default */ inp->in6p_cksum = -1; inp->in6p_icmp6filt = filter; ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 9b3bce7db7bc..a7bdfce97707 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -1045,10 +1045,6 @@ udp6_attach(struct socket *so, int proto, struct thread *td) if (error) return (error); inp = (struct inpcb *)so->so_pcb; - inp->inp_vflag |= INP_IPV6; - if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) - inp->inp_vflag |= INP_IPV4; - inp->in6p_hops = -1; /* use kernel default */ inp->in6p_cksum = -1; /* just to be sure */ /* * XXX: ugly!!