Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 Adjust pf, wg, dccp and sctp for struct inpcb i...
details: https://anonhg.NetBSD.org/src/rev/28d4ef95e444
branches: trunk
changeset: 372129:28d4ef95e444
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Oct 28 05:20:08 2022 +0000
description:
Adjust pf, wg, dccp and sctp for struct inpcb integration
diffstat:
sys/dist/pf/net/pf.c | 9 +-
sys/net/if_wg.c | 13 +-
sys/netinet/dccp_usrreq.c | 380 +++++++++----------------------------------
sys/netinet/dccp_var.h | 10 +-
sys/netinet/sctp_pcb.h | 41 ++++-
sys/netinet6/dccp6_usrreq.c | 62 +++---
6 files changed, 163 insertions(+), 352 deletions(-)
diffs (truncated from 1006 to 300 lines):
diff -r f7d060061e1d -r 28d4ef95e444 sys/dist/pf/net/pf.c
--- a/sys/dist/pf/net/pf.c Fri Oct 28 05:18:39 2022 +0000
+++ b/sys/dist/pf/net/pf.c Fri Oct 28 05:20:08 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pf.c,v 1.84 2020/08/10 10:59:34 rin Exp $ */
+/* $NetBSD: pf.c,v 1.85 2022/10/28 05:20:08 ozaki-r Exp $ */
/* $OpenBSD: pf.c,v 1.552.2.1 2007/11/27 16:37:57 henning Exp $ */
/*
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.84 2020/08/10 10:59:34 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.85 2022/10/28 05:20:08 ozaki-r Exp $");
#include "pflog.h"
@@ -2758,11 +2758,8 @@
struct inpcbtable *tb;
struct inpcb *inp = NULL;
struct socket *so = NULL;
-#if defined(__NetBSD__) && defined(INET6)
- struct in6pcb *in6p = NULL;
-#else
#define in6p inp
-#endif /* __NetBSD__ && INET6 */
+#define in6p_socket inp_socket
if (pd == NULL)
return (-1);
diff -r f7d060061e1d -r 28d4ef95e444 sys/net/if_wg.c
--- a/sys/net/if_wg.c Fri Oct 28 05:18:39 2022 +0000
+++ b/sys/net/if_wg.c Fri Oct 28 05:20:08 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wg.c,v 1.69 2022/03/25 08:57:50 hannken Exp $ */
+/* $NetBSD: if_wg.c,v 1.70 2022/10/28 05:20:08 ozaki-r Exp $ */
/*
* Copyright (C) Ryota Ozaki <ozaki.ryota%gmail.com@localhost>
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.69 2022/03/25 08:57:50 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.70 2022/10/28 05:20:08 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_altq_enabled.h"
@@ -3266,12 +3266,7 @@
so->so_upcallarg = wg;
so->so_upcall = wg_so_upcall;
so->so_rcv.sb_flags |= SB_UPCALL;
- if (af == AF_INET)
- in_pcb_register_overudp_cb(sotoinpcb(so), wg_overudp_cb, wg);
-#if INET6
- else
- in6_pcb_register_overudp_cb(sotoin6pcb(so), wg_overudp_cb, wg);
-#endif
+ in_pcb_register_overudp_cb(sotoinpcb(so), wg_overudp_cb, wg);
sounlock(so);
*sop = so;
@@ -3924,7 +3919,7 @@
error = udp_send(so, m, wgsatosa(wgsa), NULL, curlwp);
} else {
#ifdef INET6
- error = udp6_output(sotoin6pcb(so), m, wgsatosin6(wgsa),
+ error = udp6_output(sotoinpcb(so), m, wgsatosin6(wgsa),
NULL, curlwp);
#else
m_freem(m);
diff -r f7d060061e1d -r 28d4ef95e444 sys/netinet/dccp_usrreq.c
--- a/sys/netinet/dccp_usrreq.c Fri Oct 28 05:18:39 2022 +0000
+++ b/sys/netinet/dccp_usrreq.c Fri Oct 28 05:20:08 2022 +0000
@@ -1,5 +1,5 @@
/* $KAME: dccp_usrreq.c,v 1.67 2005/11/03 16:05:04 nishida Exp $ */
-/* $NetBSD: dccp_usrreq.c,v 1.22 2021/12/04 13:23:04 andvar Exp $ */
+/* $NetBSD: dccp_usrreq.c,v 1.23 2022/10/28 05:20:08 ozaki-r Exp $ */
/*
* Copyright (c) 2003 Joacim Häggmark, Magnus Erixzon, Nils-Erik Mattsson
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.22 2021/12/04 13:23:04 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.23 2022/10/28 05:20:08 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -188,7 +188,6 @@
struct dccphdr *dh;
struct dccplhdr *dlh;
struct inpcb *inp = NULL, *oinp = NULL;
- struct in6pcb *in6p = NULL, *oin6p = NULL;
struct dccpcb *dp;
struct ipovly *ipov = NULL;
struct dccp_requesthdr *drqh;
@@ -338,11 +337,11 @@
*/
#ifdef INET6
if (isipv6) {
- in6p = in6_pcblookup_connect(&dccpbtable, &ip6->ip6_src,
+ inp = in6_pcblookup_connect(&dccpbtable, &ip6->ip6_src,
dh->dh_sport, &ip6->ip6_dst, dh->dh_dport, 0, 0);
- if (in6p == 0) {
+ if (inp == NULL) {
/* XXX stats increment? */
- in6p = in6_pcblookup_bind(&dccpbtable, &ip6->ip6_dst,
+ inp = in6_pcblookup_bind(&dccpbtable, &ip6->ip6_dst,
dh->dh_dport, 0);
}
} else
@@ -357,12 +356,12 @@
}
}
if (isipv6) {
- DCCP_DEBUG((LOG_INFO, "in6p=%p\n", in6p));
+ DCCP_DEBUG((LOG_INFO, "in6p=%p\n", inp));
} else {
DCCP_DEBUG((LOG_INFO, "inp=%p\n", inp));
}
- if (isipv6 ? in6p == NULL : inp == NULL) {
+ if (inp == NULL) {
if (dccp_log_in_vain) {
#ifdef INET6
char dbuf[INET6_ADDRSTRLEN+2], sbuf[INET6_ADDRSTRLEN+2];
@@ -409,14 +408,8 @@
}
INP_LOCK(inp);
-#ifdef INET6
- if (isipv6)
- dp = in6todccpcb(in6p);
- else
-#endif
- dp = intodccpcb(inp);
-
- if (dp == 0) {
+ dp = intodccpcb(inp);
+ if (dp == NULL) {
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&dccpbinfo);
goto badunlocked;
@@ -431,12 +424,7 @@
goto badunlocked;
}
-#if defined(INET6)
- if (isipv6)
- so = in6p->in6p_socket;
- else
-#endif
- so = inp->inp_socket;
+ so = inp->inp_socket;
if (so->so_options & SO_ACCEPTCONN) {
DCCP_DEBUG((LOG_INFO, "so->options & SO_ACCEPTCONN! dp->state = %i\n", dp->state));
@@ -450,21 +438,16 @@
/* INP_LOCK(inp); XXX */
-#if defined(INET6)
- if (isipv6)
- oin6p = in6p;
- else
-#endif
- oinp = inp;
+ oinp = inp;
#ifdef INET6
if (isipv6) {
- in6p = sotoin6pcb(so);
- in6p->in6p_laddr = ip6->ip6_dst;
- in6p->in6p_faddr = ip6->ip6_src;
- in6p->in6p_lport = dh->dh_dport;
- in6p->in6p_fport = dh->dh_sport;
- in6_pcbstate(in6p, IN6P_CONNECTED);
+ inp = sotoinpcb(so);
+ inp->inp_laddr6 = ip6->ip6_dst;
+ inp->inp_faddr6 = ip6->ip6_src;
+ inp->inp_lport = dh->dh_dport;
+ inp->inp_fport = dh->dh_sport;
+ in_pcbstate(inp, INP_CONNECTED);
} else
#endif
{
@@ -478,27 +461,13 @@
if (!isipv6)
in_pcbstate(inp, INP_BOUND);
-#if defined(INET6)
- if (isipv6)
- dp = (struct dccpcb *)in6p->in6p_ppcb;
- else
-#endif
- dp = (struct dccpcb *)inp->inp_ppcb;
+ dp = inp->inp_ppcb;
dp->state = DCCPS_LISTEN;
dp->who = DCCP_SERVER;
-#if defined(INET6)
- if (isipv6) {
- dp->cslen = ((struct dccpcb *)oin6p->in6p_ppcb)->cslen;
- dp->avgpsize = ((struct dccpcb *)oin6p->in6p_ppcb)->avgpsize;
- dp->scode = ((struct dccpcb *)oin6p->in6p_ppcb)->scode;
- } else
-#endif
- {
- dp->cslen = ((struct dccpcb *)oinp->inp_ppcb)->cslen;
- dp->avgpsize = ((struct dccpcb *)oinp->inp_ppcb)->avgpsize;
- dp->scode = ((struct dccpcb *)oinp->inp_ppcb)->scode;
- }
+ dp->cslen = ((struct dccpcb *)oinp->inp_ppcb)->cslen;
+ dp->avgpsize = ((struct dccpcb *)oinp->inp_ppcb)->avgpsize;
+ dp->scode = ((struct dccpcb *)oinp->inp_ppcb)->scode;
dp->seq_snd = (((u_int64_t)random() << 32) | random()) % 281474976710656LL;
dp->ref_seq.hi = dp->seq_snd >> 24;
dp->ref_seq.lo = (u_int64_t)(dp->seq_snd & 0xffffff);
@@ -690,12 +659,7 @@
DCCP_DEBUG((LOG_INFO, "Setting DCCPS_ESTAB & soisconnected\n"));
dp->state = DCCPS_ESTAB;
dccpstat.dccps_connects++;
-#if defined(INET6)
- if (isipv6)
- soisconnected(in6p->in6p_socket);
- else
-#endif
- soisconnected(inp->inp_socket);
+ soisconnected(inp->inp_socket);
} else {
dp->state = DCCPS_RESPOND;
DCCP_DEBUG((LOG_INFO, "CC negotiation is not finished, cc_in_use[0] = %u, cc_in_use[1] = %u\n",dp->cc_in_use[0], dp->cc_in_use[1]));
@@ -744,12 +708,7 @@
DCCP_DEBUG((LOG_INFO, "Setting DCCPS_ESTAB & soisconnected\n"));
dp->state = DCCPS_ESTAB;
dccpstat.dccps_connects++;
-#if defined(INET6)
- if (isipv6)
- soisconnected(in6p->in6p_socket);
- else
-#endif
- soisconnected(inp->inp_socket);
+ soisconnected(inp->inp_socket);
} else {
DCCP_DEBUG((LOG_INFO, "CC negotiation is not finished, cc_in_use[0] = %u, cc_in_use[1] = %u\n",dp->cc_in_use[0], dp->cc_in_use[1]));
/* Force an output!!! */
@@ -1094,9 +1053,6 @@
{
int s, error = 0;
struct inpcb *inp;
-#if defined(INET6)
- struct in6pcb *in6p;
-#endif
struct dccpcb *dp;
int family; /* family of the socket */
@@ -1105,29 +1061,8 @@
s = splsoftnet();
INP_INFO_RLOCK(&dccpbinfo);
- switch (family) {
- case PF_INET:
- inp = sotoinpcb(so);
-#if defined(INET6)
- in6p = NULL;
-#endif
- break;
-#if defined(INET6)
- case PF_INET6:
- inp = NULL;
- in6p = sotoin6pcb(so);
- break;
-#endif
- default:
- INP_INFO_RUNLOCK(&dccpbinfo);
- splx(s);
- return EAFNOSUPPORT;
- }
-#if defined(INET6)
- if (inp == NULL && in6p == NULL)
-#else
+ inp = sotoinpcb(so);
if (inp == NULL)
-#endif
{
INP_INFO_RUNLOCK(&dccpbinfo);
splx(s);
@@ -1155,14 +1090,7 @@
return (error);
}
- if (inp)
- dp = intodccpcb(inp);
-#if defined(INET6)
- else if (in6p)
- dp = in6todccpcb(in6p);
-#endif
Home |
Main Index |
Thread Index |
Old Index