git: c7a62c925c81 - main - inpcb: gather v4/v6 handling code into in_pcballoc() from protocols
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 Aug 2022 18:10:26 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=c7a62c925c814885b36a9ca900fbf258cafdb247
commit c7a62c925c814885b36a9ca900fbf258cafdb247
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-08-10 18:09:34 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
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!!