Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Adjust dccp and sctp for struct inpcb separation
details: https://anonhg.NetBSD.org/src/rev/0ef1f2363a5d
branches: trunk
changeset: 372133:0ef1f2363a5d
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Oct 28 05:26:29 2022 +0000
description:
Adjust dccp and sctp for struct inpcb separation
diffstat:
sys/netinet/dccp_usrreq.c | 32 ++++++++++++++++----------------
sys/netinet/sctp_output.c | 26 +++++++++++++-------------
sys/netinet/sctp_pcb.h | 28 +++++-----------------------
sys/netinet6/dccp6_usrreq.c | 8 ++++----
sys/netinet6/sctp6_usrreq.c | 13 ++++++-------
5 files changed, 44 insertions(+), 63 deletions(-)
diffs (truncated from 333 to 300 lines):
diff -r f98282c03752 -r 0ef1f2363a5d sys/netinet/dccp_usrreq.c
--- a/sys/netinet/dccp_usrreq.c Fri Oct 28 05:25:36 2022 +0000
+++ b/sys/netinet/dccp_usrreq.c Fri Oct 28 05:26:29 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.23 2022/10/28 05:20:08 ozaki-r Exp $ */
+/* $NetBSD: dccp_usrreq.c,v 1.24 2022/10/28 05:26:29 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.23 2022/10/28 05:20:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.24 2022/10/28 05:26:29 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -443,8 +443,8 @@
#ifdef INET6
if (isipv6) {
inp = sotoinpcb(so);
- inp->inp_laddr6 = ip6->ip6_dst;
- inp->inp_faddr6 = ip6->ip6_src;
+ in6p_laddr(inp) = ip6->ip6_dst;
+ in6p_faddr(inp) = ip6->ip6_src;
inp->inp_lport = dh->dh_dport;
inp->inp_fport = dh->dh_sport;
in_pcbstate(inp, INP_CONNECTED);
@@ -452,8 +452,8 @@
#endif
{
inp = sotoinpcb(so);
- inp->inp_laddr = ip->ip_dst;
- inp->inp_faddr = ip->ip_src;
+ in4p_laddr(inp) = ip->ip_dst;
+ in4p_faddr(inp) = ip->ip_src;
inp->inp_lport = dh->dh_dport;
inp->inp_fport = dh->dh_sport;
}
@@ -1353,12 +1353,12 @@
ip6 = mtod(m, struct ip6_hdr *);
dh = (struct dccphdr *)(ip6 + 1);
ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) |
- (inp->inp_flowinfo & IPV6_FLOWINFO_MASK);
+ (in6p_flowinfo(inp) & IPV6_FLOWINFO_MASK);
ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) |
(IPV6_VERSION & IPV6_VERSION_MASK);
ip6->ip6_nxt = IPPROTO_DCCP;
- ip6->ip6_src = inp->inp_laddr6;
- ip6->ip6_dst = inp->inp_faddr6;
+ ip6->ip6_src = in6p_laddr(inp);
+ ip6->ip6_dst = in6p_faddr(inp);
} else
#endif
{
@@ -1366,8 +1366,8 @@
dh = (struct dccphdr *)(ip + 1);
memset(ip, 0, sizeof(struct ip));
ip->ip_p = IPPROTO_DCCP;
- ip->ip_src = inp->inp_laddr;
- ip->ip_dst = inp->inp_faddr;
+ ip->ip_src = in4p_laddr(inp);
+ ip->ip_dst = in4p_faddr(inp);
}
dlh = (struct dccplhdr *)dh;
@@ -1507,7 +1507,7 @@
if (isipv6) {
DCCP_DEBUG((LOG_INFO, "Calling ip_output6, mbuf->m_len = %u, mbuf->m_pkthdr.len = %u\n", m->m_len, m->m_pkthdr.len));
- error = ip6_output(m, inp->inp_outputopts6, &inp->inp_route,
+ error = ip6_output(m, in6p_outputopts(inp), &inp->inp_route,
(inp->inp_socket->so_options & SO_DONTROUTE), NULL, NULL,
NULL);
} else
@@ -1705,7 +1705,7 @@
return EINVAL;
}
INP_LOCK(inp);
- if (inp->inp_faddr.s_addr != INADDR_ANY) {
+ if (in4p_faddr(inp).s_addr != INADDR_ANY) {
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&dccpbinfo);
return EISCONN;
@@ -1850,7 +1850,7 @@
return EINVAL;
}
INP_LOCK(inp);
- if (inp->inp_faddr.s_addr == INADDR_ANY) {
+ if (in4p_faddr(inp).s_addr == INADDR_ANY) {
INP_INFO_WUNLOCK(&dccpbinfo);
INP_UNLOCK(inp);
return ENOTCONN;
@@ -2130,10 +2130,10 @@
inp->inp_ppcb = dp;
switch (family) {
case PF_INET:
- inp->inp_ip.ip_ttl = ip_defttl;
+ in4p_ip(inp).ip_ttl = ip_defttl;
break;
case PF_INET6:
- inp->inp_ip6.ip6_hlim = in6_selecthlim_rt(inp);
+ in6p_ip6(inp).ip6_hlim = in6_selecthlim_rt(inp);
break;
}
diff -r f98282c03752 -r 0ef1f2363a5d sys/netinet/sctp_output.c
--- a/sys/netinet/sctp_output.c Fri Oct 28 05:25:36 2022 +0000
+++ b/sys/netinet/sctp_output.c Fri Oct 28 05:26:29 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sctp_output.c,v 1.31 2022/05/31 08:43:16 andvar Exp $ */
+/* $NetBSD: sctp_output.c,v 1.32 2022/10/28 05:26:29 ozaki-r Exp $ */
/* $KAME: sctp_output.c,v 1.48 2005/06/16 18:29:24 jinmei Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.31 2022/05/31 08:43:16 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.32 2022/10/28 05:26:29 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -2137,11 +2137,11 @@
if (stcb) {
if ((stcb->asoc.ecn_allowed) && ecn_ok) {
/* Enable ECN */
- ip->ip_tos = (u_char)((inp->ip_inp.inp.inp_ip.ip_tos & 0x000000fc) |
+ ip->ip_tos = (u_char)((in4p_ip(&inp->ip_inp.inp).ip_tos & 0x000000fc) |
sctp_get_ect(stcb, chk));
} else {
/* No ECN */
- ip->ip_tos = inp->ip_inp.inp.inp_ip.ip_tos;
+ ip->ip_tos = in4p_ip(&inp->ip_inp.inp).ip_tos;
}
} else {
/* no association at all */
@@ -2299,10 +2299,10 @@
* We assume here that inp_flow is in host byte order within
* the TCB!
*/
- flowBottom = ((struct in6pcb *)inp)->in6p_flowinfo & 0x0000ffff;
- flowTop = ((((struct in6pcb *)inp)->in6p_flowinfo & 0x000f0000) >> 16);
-
- tosTop = (((((struct in6pcb *)inp)->in6p_flowinfo & 0xf0) >> 4) | IPV6_VERSION);
+ flowBottom = in6p_flowinfo(inp) & 0x0000ffff;
+ flowTop = ((in6p_flowinfo(inp) & 0x000f0000) >> 16);
+
+ tosTop = (((in6p_flowinfo(inp) & 0xf0) >> 4) | IPV6_VERSION);
/* protect *sin6 from overwrite */
memcpy(&tmp, to, sizeof(struct sockaddr_in6));
@@ -2331,14 +2331,14 @@
if (stcb != NULL) {
if ((stcb->asoc.ecn_allowed) && ecn_ok) {
/* Enable ECN */
- tosBottom = (((((struct in6pcb *)inp)->in6p_flowinfo & 0x0c) | sctp_get_ect(stcb, chk)) << 4);
+ tosBottom = (((in6p_flowinfo(inp) & 0x0c) | sctp_get_ect(stcb, chk)) << 4);
} else {
/* No ECN */
- tosBottom = ((((struct in6pcb *)inp)->in6p_flowinfo & 0x0c) << 4);
+ tosBottom = ((in6p_flowinfo(inp) & 0x0c) << 4);
}
} else {
/* we could get no asoc if it is a O-O-T-B packet */
- tosBottom = ((((struct in6pcb *)inp)->in6p_flowinfo & 0x0c) << 4);
+ tosBottom = ((in6p_flowinfo(inp) & 0x0c) << 4);
}
ip6h->ip6_flow = htonl(((tosTop << 24) | ((tosBottom|flowTop) << 16) | flowBottom));
ip6h->ip6_nxt = IPPROTO_SCTP;
@@ -2416,7 +2416,7 @@
* We set the hop limit now since there is a good chance that
* our ro pointer is now filled
*/
- ip6h->ip6_hlim = in6_selecthlim((struct in6pcb *)&inp->ip_inp.inp,
+ ip6h->ip6_hlim = in6_selecthlim(&inp->ip_inp.inp,
(ro ?
(rt ? (rt->rt_ifp) : (NULL)) :
(NULL)));
@@ -2447,7 +2447,7 @@
ro,
o_flgs,
((struct in6pcb *)inp)->in6p_moptions,
- (struct in6pcb *)inp,
+ (struct inpcb *)inp,
&ifp);
if (net) {
/* for link local this must be done */
diff -r f98282c03752 -r 0ef1f2363a5d sys/netinet/sctp_pcb.h
--- a/sys/netinet/sctp_pcb.h Fri Oct 28 05:25:36 2022 +0000
+++ b/sys/netinet/sctp_pcb.h Fri Oct 28 05:26:29 2022 +0000
@@ -1,5 +1,5 @@
/* $KAME: sctp_pcb.h,v 1.21 2005/07/16 01:18:47 suz Exp $ */
-/* $NetBSD: sctp_pcb.h,v 1.6 2022/10/28 05:20:08 ozaki-r Exp $ */
+/* $NetBSD: sctp_pcb.h,v 1.7 2022/10/28 05:26:29 ozaki-r Exp $ */
#ifndef __SCTP_PCB_H__
#define __SCTP_PCB_H__
@@ -288,7 +288,7 @@
*/
union {
struct inpcb inp;
- char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
+ char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
~SCTP_ALIGNM1];
} ip_inp;
LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */
@@ -753,32 +753,14 @@
struct sockaddr_in6 *sin6);
#ifdef __NetBSD__
-#ifndef in6pcb
-#define in6pcb inpcb
-#endif
#ifndef sotoin6pcb
-#define sotoin6pcb sotoinpcb
+#define sotoin6pcb(so) ((struct in6pcb *)((so)->so_pcb))
#endif
#ifndef in6p_flags
-#define in6p_flags inp_flags
+#define in6p_flags in6p_pcb.inp_flags
#endif
#ifndef in6p_af
-#define in6p_af inp_af
-#endif
-#ifndef in6p_cksum
-#define in6p_cksum inp_cksum6
-#endif
-#ifndef in6p_hops
-#define in6p_hops inp_hops6
-#endif
-#ifndef in6p_flowinfo
-#define in6p_flowinfo inp_flowinfo
-#endif
-#ifndef in6p_outputopts
-#define in6p_outputopts inp_outputopts6
-#endif
-#ifndef in6p_moptions
-#define in6p_moptions inp_moptions6
+#define in6p_af in6p_pcb.inp_af
#endif
#ifndef inpcb_hdr
#define inpcb_hdr inpcb
diff -r f98282c03752 -r 0ef1f2363a5d sys/netinet6/dccp6_usrreq.c
--- a/sys/netinet6/dccp6_usrreq.c Fri Oct 28 05:25:36 2022 +0000
+++ b/sys/netinet6/dccp6_usrreq.c Fri Oct 28 05:26:29 2022 +0000
@@ -1,5 +1,5 @@
/* $KAME: dccp6_usrreq.c,v 1.13 2005/07/27 08:42:56 nishida Exp $ */
-/* $NetBSD: dccp6_usrreq.c,v 1.13 2022/10/28 05:20:08 ozaki-r Exp $ */
+/* $NetBSD: dccp6_usrreq.c,v 1.14 2022/10/28 05:26:29 ozaki-r Exp $ */
/*
* Copyright (C) 2003 WIDE Project.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dccp6_usrreq.c,v 1.13 2022/10/28 05:20:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp6_usrreq.c,v 1.14 2022/10/28 05:26:29 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -162,7 +162,7 @@
return EINVAL;
}
INP_LOCK(inp);
- if (inp->inp_faddr6.s_addr != INADDR_ANY) {
+ if (in6p_faddr(inp).s_addr != INADDR_ANY) {
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&dccpbinfo);
return EISCONN;
@@ -174,7 +174,7 @@
if (inp == 0) {
return EINVAL;
}
- if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
+ if (!IN6_IS_ADDR_UNSPECIFIED(&in6p_faddr(inp))) {
return EISCONN;
}
diff -r f98282c03752 -r 0ef1f2363a5d sys/netinet6/sctp6_usrreq.c
--- a/sys/netinet6/sctp6_usrreq.c Fri Oct 28 05:25:36 2022 +0000
+++ b/sys/netinet6/sctp6_usrreq.c Fri Oct 28 05:26:29 2022 +0000
@@ -1,5 +1,5 @@
/* $KAME: sctp6_usrreq.c,v 1.38 2005/08/24 08:08:56 suz Exp $ */
-/* $NetBSD: sctp6_usrreq.c,v 1.22 2020/04/27 19:33:48 rjs Exp $ */
+/* $NetBSD: sctp6_usrreq.c,v 1.23 2022/10/28 05:26:29 ozaki-r Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp6_usrreq.c,v 1.22 2020/04/27 19:33:48 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp6_usrreq.c,v 1.23 2022/10/28 05:26:29 ozaki-r Exp $");
Home |
Main Index |
Thread Index |
Old Index