CVS commit: src/usr.bin

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:27:17 UTC 2022

Modified Files:
src/usr.bin/fstat: fstat.c
src/usr.bin/netstat: inet.c inet6.c
src/usr.bin/systat: netcmds.c netstat.c

Log Message:
Adjust userland commands for struct inpcb separation

Only kvm users are affected.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/systat/netcmds.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/systat/netstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.116 src/usr.bin/fstat/fstat.c:1.117
--- src/usr.bin/fstat/fstat.c:1.116	Fri Oct 28 05:24:07 2022
+++ src/usr.bin/fstat/fstat.c	Fri Oct 28 05:27:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.c,v 1.116 2022/10/28 05:24:07 ozaki-r Exp $	*/
+/*	$NetBSD: fstat.c,v 1.117 2022/10/28 05:27:16 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)fstat.c	8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.116 2022/10/28 05:24:07 ozaki-r Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.117 2022/10/28 05:27:16 ozaki-r Exp $");
 #endif
 #endif /* not lint */
 
@@ -1061,7 +1061,8 @@ socktrans(struct file *f, struct socket 
 	struct socket	so;
 	struct protosw	proto;
 	struct domain	dom;
-	struct inpcb	inpcb;
+	struct in4pcb	in4pcb;
+	struct in6pcb	in6pcb;
 	struct unpcb	unpcb;
 	struct ddpcb	ddpcb;
 	int len;
@@ -1123,15 +1124,16 @@ socktrans(struct file *f, struct socket 
 		case IPPROTO_TCP:
 			if (so.so_pcb == NULL)
 break;
-			if (kvm_read(kd, (u_long)so.so_pcb, (char *),
-			sizeof(inpcb)) != sizeof(inpcb)) {
-dprintf("can't read inpcb at %p", so.so_pcb);
+			if (kvm_read(kd, (u_long)so.so_pcb, (char *),
+			sizeof(in4pcb)) != sizeof(in4pcb)) {
+dprintf("can't read in4pcb at %p", so.so_pcb);
 goto bad;
 			}
-			inet_addrstr(lbuf, sizeof(lbuf), _laddr,
-			ntohs(inpcb.inp_lport), isdgram);
-			inet_addrstr(fbuf, sizeof(fbuf), _faddr,
-			ntohs(inpcb.inp_fport), isdgram);
+			struct inpcb *inp = (struct inpcb *)
+			inet_addrstr(lbuf, sizeof(lbuf), _laddr(inp),
+			ntohs(inp->inp_lport), isdgram);
+			inet_addrstr(fbuf, sizeof(fbuf), _faddr(inp),
+			ntohs(inp->inp_fport), isdgram);
 			break;
 		default:
 			break;
@@ -1147,15 +1149,16 @@ socktrans(struct file *f, struct socket 
 		case IPPROTO_TCP:
 			if (so.so_pcb == NULL)
 break;
-			if (kvm_read(kd, (u_long)so.so_pcb, (char *),
-			sizeof(inpcb)) != sizeof(inpcb)) {
-dprintf("can't read inpcb at %p", so.so_pcb);
+			if (kvm_read(kd, (u_long)so.so_pcb, (char *),
+			sizeof(in6pcb)) != sizeof(in6pcb)) {
+dprintf("can't read in6pcb at %p", so.so_pcb);
 goto bad;
 			}
-			inet6_addrstr(lbuf, sizeof(lbuf), _laddr6,
-			ntohs(inpcb.inp_lport), isdgram);
-			inet6_addrstr(fbuf, sizeof(fbuf), _faddr6,
-			ntohs(inpcb.inp_fport), isdgram);
+			struct inpcb *inp = (struct inpcb *)
+			inet6_addrstr(lbuf, sizeof(lbuf), _laddr(inp),
+			ntohs(inp->inp_lport), isdgram);
+			inet6_addrstr(fbuf, sizeof(fbuf), _faddr(inp),
+			ntohs(inp->inp_fport), isdgram);
 			break;
 		default:
 			break;

Index: src/usr.bin/netstat/inet.c
diff -u src/usr.bin/netstat/inet.c:1.118 src/usr.bin/netstat/inet.c:1.119
--- src/usr.bin/netstat/inet.c:1.118	Fri Oct 28 05:24:07 2022
+++ src/usr.bin/netstat/inet.c	Fri Oct 28 05:27:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet.c,v 1.118 2022/10/28 05:24:07 ozaki-r Exp $	*/
+/*	$NetBSD: inet.c,v 1.119 2022/10/28 05:27:17 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.118 2022/10/28 05:24:07 ozaki-r Exp $");
+__RCSID("$NetBSD: inet.c,v 1.119 2022/10/28 05:27:17 ozaki-r Exp $");
 #endif
 #endif /* not lint */
 
@@ -276,7 +276,8 @@ getpcblist_kmem(u_long off, const char *
 {
 	struct inpcbtable table;
 	struct inpcb *next, *prev;
-	struct inpcb inpcb;
+	struct in4pcb in4pcb;
+	struct inpcb *inp;
 	struct tcpcb tcpcb;
 	struct socket sockb;
 	int istcp = strcmp(name, "tcp") == 0;
@@ -301,31 +302,32 @@ getpcblist_kmem(u_long off, const char *
 
 	i = 0;
 	while (next != TAILQ_END(head)) {
-		kread((u_long)next, (char *), sizeof inpcb);
+		kread((u_long)next, (char *), sizeof in4pcb);
 		prev = next;
-		next = TAILQ_NEXT(, inp_queue);
+		inp = (struct inpcb *)
+		next = TAILQ_NEXT(inp, inp_queue);
 
-		if (inpcb.inp_af != AF_INET)
+		if (inp->inp_af != AF_INET)
 			continue;
 
-		kread((u_long)inpcb.inp_socket, (char *), sizeof(sockb));
+		kread((u_long)inp->inp_socket, (char *), sizeof(sockb));
 		if (istcp) {
-			

CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:26:29 UTC 2022

Modified Files:
src/sys/netinet: dccp_usrreq.c sctp_output.c sctp_pcb.h
src/sys/netinet6: dccp6_usrreq.c sctp6_usrreq.c

Log Message:
Adjust dccp and sctp for struct inpcb separation


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.31 -r1.32 src/sys/netinet/sctp_output.c
cvs rdiff -u -r1.6 -r1.7 src/sys/netinet/sctp_pcb.h
cvs rdiff -u -r1.13 -r1.14 src/sys/netinet6/dccp6_usrreq.c
cvs rdiff -u -r1.22 -r1.23 src/sys/netinet6/sctp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:27:17 UTC 2022

Modified Files:
src/usr.bin/fstat: fstat.c
src/usr.bin/netstat: inet.c inet6.c
src/usr.bin/systat: netcmds.c netstat.c

Log Message:
Adjust userland commands for struct inpcb separation

Only kvm users are affected.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/systat/netcmds.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/systat/netstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:26:29 UTC 2022

Modified Files:
src/sys/netinet: dccp_usrreq.c sctp_output.c sctp_pcb.h
src/sys/netinet6: dccp6_usrreq.c sctp6_usrreq.c

Log Message:
Adjust dccp and sctp for struct inpcb separation


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.31 -r1.32 src/sys/netinet/sctp_output.c
cvs rdiff -u -r1.6 -r1.7 src/sys/netinet/sctp_pcb.h
cvs rdiff -u -r1.13 -r1.14 src/sys/netinet6/dccp6_usrreq.c
cvs rdiff -u -r1.22 -r1.23 src/sys/netinet6/sctp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/dccp_usrreq.c
diff -u src/sys/netinet/dccp_usrreq.c:1.23 src/sys/netinet/dccp_usrreq.c:1.24
--- src/sys/netinet/dccp_usrreq.c:1.23	Fri Oct 28 05:20:08 2022
+++ src/sys/netinet/dccp_usrreq.c	Fri Oct 28 05:26:29 2022
@@ -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 
-__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 @@ dccp_input(struct mbuf *m, int off, int 
 #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 @@ dccp_input(struct mbuf *m, int off, int 
 #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 @@ again:
 		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 @@ again:
 		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 @@ again:
 	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_route,
+		error = ip6_output(m, in6p_outputopts(inp), >inp_route,
 		(inp->inp_socket->so_options & SO_DONTROUTE), NULL, NULL,
 		NULL);
 	} else
@@ -1705,7 +1705,7 @@ dccp_connect(struct socket *so, struct s
 		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();
 		return EISCONN;
@@ -1850,7 +1850,7 @@ dccp_disconnect(struct socket *so)
 		return EINVAL;
 	}
 	INP_LOCK(inp);
-	if (inp->inp_faddr.s_addr == INADDR_ANY) {
+	if (in4p_faddr(inp).s_addr == INADDR_ANY) {
 		INP_INFO_WUNLOCK();
 		INP_UNLOCK(inp);
 		return ENOTCONN;
@@ -2130,10 +2130,10 @@ dccp_newdccpcb(int family, void *aux)
 	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;
 	}
 	

Index: src/sys/netinet/sctp_output.c
diff -u src/sys/netinet/sctp_output.c:1.31 src/sys/netinet/sctp_output.c:1.32
--- src/sys/netinet/sctp_output.c:1.31	Tue May 31 08:43:16 2022
+++ src/sys/netinet/sctp_output.c	Fri Oct 28 05:26:29 2022
@@ -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 
-__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
 

CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:25:36 UTC 2022

Modified Files:
src/sys/netinet: in_pcb.c in_pcb.h ip_output.c portalgo.c raw_ip.c
tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c tcp_timer.c
tcp_usrreq.c tcp_vtw.c udp_usrreq.c
src/sys/netinet6: icmp6.c in6_pcb.c in6_src.c ip6_output.c raw_ip6.c
udp6_usrreq.c

Log Message:
inpcb: separate inpcb again to reduce the size of PCB for IPv4

The data size of PCB for IPv4 increased because of the merge of
struct in6pcb.  The change decreases the size to the original size by
separating struct inpcb (again).  struct in4pcb and in6pcb that embed
struct inpcb are introduced.

Even after the separation, users don't need to realize the separation
and only have to use some macros to access dedicated data.  For example,
inp->inp_laddr is now accessed through in4p_laddr(inp).


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.72 -r1.73 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.321 -r1.322 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.12 -r1.13 src/sys/netinet/portalgo.c
cvs rdiff -u -r1.182 -r1.183 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.435 -r1.436 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.215 -r1.216 src/sys/netinet/tcp_output.c
cvs rdiff -u -r1.292 -r1.293 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/netinet/tcp_syncache.c
cvs rdiff -u -r1.97 -r1.98 src/sys/netinet/tcp_timer.c
cvs rdiff -u -r1.233 -r1.234 src/sys/netinet/tcp_usrreq.c
cvs rdiff -u -r1.22 -r1.23 src/sys/netinet/tcp_vtw.c
cvs rdiff -u -r1.262 -r1.263 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.253 -r1.254 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.172 -r1.173 src/sys/netinet6/in6_pcb.c
cvs rdiff -u -r1.89 -r1.90 src/sys/netinet6/in6_src.c
cvs rdiff -u -r1.230 -r1.231 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.179 -r1.180 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.151 -r1.152 src/sys/netinet6/udp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/in_pcb.c
diff -u src/sys/netinet/in_pcb.c:1.192 src/sys/netinet/in_pcb.c:1.193
--- src/sys/netinet/in_pcb.c:1.192	Fri Oct 28 05:18:39 2022
+++ src/sys/netinet/in_pcb.c	Fri Oct 28 05:25:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.c,v 1.192 2022/10/28 05:18:39 ozaki-r Exp $	*/
+/*	$NetBSD: in_pcb.c,v 1.193 2022/10/28 05:25:36 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.192 2022/10/28 05:18:39 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.193 2022/10/28 05:25:36 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -156,13 +156,16 @@ int	anonportmax = IPPORT_ANONMAX;
 int	lowportmin  = IPPORT_RESERVEDMIN;
 int	lowportmax  = IPPORT_RESERVEDMAX;
 
-static struct pool inpcb_pool;
+static struct pool in4pcb_pool;
+static struct pool in6pcb_pool;
 
 static int
 inpcb_poolinit(void)
 {
 
-	pool_init(_pool, sizeof(struct inpcb), 0, 0, 0, "inpcbpl", NULL,
+	pool_init(_pool, sizeof(struct in4pcb), 0, 0, 0, "in4pcbpl", NULL,
+	IPL_NET);
+	pool_init(_pool, sizeof(struct in6pcb), 0, 0, 0, "in6pcbpl", NULL,
 	IPL_NET);
 	return 0;
 }
@@ -194,30 +197,39 @@ in_pcballoc(struct socket *so, void *v)
 
 	KASSERT(soaf(so) == AF_INET || soaf(so) == AF_INET6);
 
-	inp = pool_get(_pool, PR_NOWAIT);
+	if (soaf(so) == AF_INET)
+		inp = pool_get(_pool, PR_NOWAIT|PR_ZERO);
+	else
+		inp = pool_get(_pool, PR_NOWAIT|PR_ZERO);
 	if (inp == NULL)
 		return (ENOBUFS);
-	memset(inp, 0, sizeof(*inp));
 	inp->inp_af = soaf(so);
 	inp->inp_table = table;
 	inp->inp_socket = so;
-	inp->inp_errormtu = -1;
 	inp->inp_portalgo = PORTALGO_DEFAULT;
 	inp->inp_bindportonsend = false;
-	inp->inp_prefsrcip.s_addr = INADDR_ANY;
 	inp->inp_overudp_cb = NULL;
 	inp->inp_overudp_arg = NULL;
+
+	if (inp->inp_af == AF_INET) {
+		in4p_errormtu(inp) = -1;
+		in4p_prefsrcip(inp).s_addr = INADDR_ANY;
+	}
 #ifdef INET6
-	inp->inp_hops6 = -1;	/* use kernel default */
-	inp->inp_icmp6filt = NULL;
-	if (inp->inp_af == AF_INET6 && ip6_v6only)
-		inp->inp_flags |= IN6P_IPV6_V6ONLY;
+	else {
+		in6p_hops6(inp) = -1;	/* use kernel default */
+		if (ip6_v6only)
+			inp->inp_flags |= IN6P_IPV6_V6ONLY;
+	}
 #endif
 #if defined(IPSEC)
 	if (ipsec_enabled) {
 		int error = ipsec_init_pcbpolicy(so, >inp_sp);
 		if (error != 0) {
-			pool_put(_pool, inp);
+			if (inp->inp_af == AF_INET)
+pool_put(_pool, inp);
+			else
+pool_put(_pool, inp);
 			return error;
 		}
 		inp->inp_sp->sp_inp = inp;
@@ -325,7 +337,7 @@ in_pcbbind_addr(struct inpcb *inp, struc
 
 	error = in_pcbbindableaddr(inp, sin, cred);
 	if (error == 0)
-		inp->inp_laddr = sin->sin_addr;
+		in4p_laddr(inp) = sin->sin_addr;
 	return error;
 }
 
@@ -399,7 +411,7 @@ in_pcbbind_port(struct inpcb *inp, struc
 			 */
 			if (t &&
 			

CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:25:36 UTC 2022

Modified Files:
src/sys/netinet: in_pcb.c in_pcb.h ip_output.c portalgo.c raw_ip.c
tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c tcp_timer.c
tcp_usrreq.c tcp_vtw.c udp_usrreq.c
src/sys/netinet6: icmp6.c in6_pcb.c in6_src.c ip6_output.c raw_ip6.c
udp6_usrreq.c

Log Message:
inpcb: separate inpcb again to reduce the size of PCB for IPv4

The data size of PCB for IPv4 increased because of the merge of
struct in6pcb.  The change decreases the size to the original size by
separating struct inpcb (again).  struct in4pcb and in6pcb that embed
struct inpcb are introduced.

Even after the separation, users don't need to realize the separation
and only have to use some macros to access dedicated data.  For example,
inp->inp_laddr is now accessed through in4p_laddr(inp).


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.72 -r1.73 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.321 -r1.322 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.12 -r1.13 src/sys/netinet/portalgo.c
cvs rdiff -u -r1.182 -r1.183 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.435 -r1.436 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.215 -r1.216 src/sys/netinet/tcp_output.c
cvs rdiff -u -r1.292 -r1.293 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/netinet/tcp_syncache.c
cvs rdiff -u -r1.97 -r1.98 src/sys/netinet/tcp_timer.c
cvs rdiff -u -r1.233 -r1.234 src/sys/netinet/tcp_usrreq.c
cvs rdiff -u -r1.22 -r1.23 src/sys/netinet/tcp_vtw.c
cvs rdiff -u -r1.262 -r1.263 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.253 -r1.254 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.172 -r1.173 src/sys/netinet6/in6_pcb.c
cvs rdiff -u -r1.89 -r1.90 src/sys/netinet6/in6_src.c
cvs rdiff -u -r1.230 -r1.231 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.179 -r1.180 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.151 -r1.152 src/sys/netinet6/udp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:24:08 UTC 2022

Modified Files:
src/usr.bin/fstat: fstat.c
src/usr.bin/netstat: inet.c inet6.c
src/usr.bin/sockstat: sockstat.c
src/usr.bin/systat: extern.h netcmds.c netstat.c

Log Message:
Adjust userland commands for struct inpcb integration

Only kvm users are affected.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/sockstat/sockstat.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/systat/extern.h
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/systat/netcmds.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/systat/netstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.115 src/usr.bin/fstat/fstat.c:1.116
--- src/usr.bin/fstat/fstat.c:1.115	Sun Jun 19 11:31:19 2022
+++ src/usr.bin/fstat/fstat.c	Fri Oct 28 05:24:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.c,v 1.115 2022/06/19 11:31:19 simonb Exp $	*/
+/*	$NetBSD: fstat.c,v 1.116 2022/10/28 05:24:07 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)fstat.c	8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.115 2022/06/19 11:31:19 simonb Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.116 2022/10/28 05:24:07 ozaki-r Exp $");
 #endif
 #endif /* not lint */
 
@@ -1062,9 +1062,6 @@ socktrans(struct file *f, struct socket 
 	struct protosw	proto;
 	struct domain	dom;
 	struct inpcb	inpcb;
-#ifdef INET6
-	struct in6pcb	in6pcb;
-#endif
 	struct unpcb	unpcb;
 	struct ddpcb	ddpcb;
 	int len;
@@ -1150,15 +1147,15 @@ socktrans(struct file *f, struct socket 
 		case IPPROTO_TCP:
 			if (so.so_pcb == NULL)
 break;
-			if (kvm_read(kd, (u_long)so.so_pcb, (char *),
-			sizeof(in6pcb)) != sizeof(in6pcb)) {
-dprintf("can't read in6pcb at %p", so.so_pcb);
+			if (kvm_read(kd, (u_long)so.so_pcb, (char *),
+			sizeof(inpcb)) != sizeof(inpcb)) {
+dprintf("can't read inpcb at %p", so.so_pcb);
 goto bad;
 			}
-			inet6_addrstr(lbuf, sizeof(lbuf), _laddr,
-			ntohs(in6pcb.in6p_lport), isdgram);
-			inet6_addrstr(fbuf, sizeof(fbuf), _faddr,
-			ntohs(in6pcb.in6p_fport), isdgram);
+			inet6_addrstr(lbuf, sizeof(lbuf), _laddr6,
+			ntohs(inpcb.inp_lport), isdgram);
+			inet6_addrstr(fbuf, sizeof(fbuf), _faddr6,
+			ntohs(inpcb.inp_fport), isdgram);
 			break;
 		default:
 			break;

Index: src/usr.bin/netstat/inet.c
diff -u src/usr.bin/netstat/inet.c:1.117 src/usr.bin/netstat/inet.c:1.118
--- src/usr.bin/netstat/inet.c:1.117	Wed Sep 21 07:59:19 2022
+++ src/usr.bin/netstat/inet.c	Fri Oct 28 05:24:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet.c,v 1.117 2022/09/21 07:59:19 msaitoh Exp $	*/
+/*	$NetBSD: inet.c,v 1.118 2022/10/28 05:24:07 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.117 2022/09/21 07:59:19 msaitoh Exp $");
+__RCSID("$NetBSD: inet.c,v 1.118 2022/10/28 05:24:07 ozaki-r Exp $");
 #endif
 #endif /* not lint */
 
@@ -275,7 +275,7 @@ static struct kinfo_pcb *
 getpcblist_kmem(u_long off, const char *name, size_t *len)
 {
 	struct inpcbtable table;
-	struct inpcb_hdr *next, *prev;
+	struct inpcb *next, *prev;
 	struct inpcb inpcb;
 	struct tcpcb tcpcb;
 	struct socket sockb;
@@ -1084,8 +1084,8 @@ tcp_dump(u_long off, const char *name, u
 		printf("State: %d", tcpcb.t_state);
 	else
 		printf("State: %s", tcpstates[tcpcb.t_state]);
-	printf(", flags 0x%x, inpcb 0x%lx, in6pcb 0x%lx\n\n", tcpcb.t_flags,
-	(u_long)tcpcb.t_inpcb, (u_long)tcpcb.t_in6pcb);
+	printf(", flags 0x%x, inpcb 0x%lx\n\n", tcpcb.t_flags,
+	(u_long)tcpcb.t_inpcb);
 
 	printf("rxtshift %d, rxtcur %d, dupacks %d\n", tcpcb.t_rxtshift,
 	tcpcb.t_rxtcur, tcpcb.t_dupacks);

Index: src/usr.bin/netstat/inet6.c
diff -u src/usr.bin/netstat/inet6.c:1.82 src/usr.bin/netstat/inet6.c:1.83
--- src/usr.bin/netstat/inet6.c:1.82	Wed Sep 21 07:59:19 2022
+++ src/usr.bin/netstat/inet6.c	Fri Oct 28 05:24:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet6.c,v 1.82 2022/09/21 07:59:19 msaitoh Exp $	*/
+/*	$NetBSD: inet6.c,v 1.83 2022/10/28 05:24:07 ozaki-r Exp $	*/
 /*	BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp	*/
 
 /*
@@ -64,7 +64,7 @@
 #if 0
 static char sccsid[] = "@(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet6.c,v 1.82 2022/09/21 07:59:19 msaitoh Exp $");
+__RCSID("$NetBSD: inet6.c,v 1.83 2022/10/28 05:24:07 ozaki-r Exp $");
 #endif
 #endif /* not lint */
 
@@ -141,7 +141,7 @@ extern const char * const tcptimers[];
 
 #ifdef INET6
 
-struct	in6pcb in6pcb;
+struct	inpcb inpcb;
 #ifdef TCP6
 struct	tcp6cb 

CVS commit: src/usr.bin

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:24:08 UTC 2022

Modified Files:
src/usr.bin/fstat: fstat.c
src/usr.bin/netstat: inet.c inet6.c
src/usr.bin/sockstat: sockstat.c
src/usr.bin/systat: extern.h netcmds.c netstat.c

Log Message:
Adjust userland commands for struct inpcb integration

Only kvm users are affected.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/sockstat/sockstat.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/systat/extern.h
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/systat/netcmds.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/systat/netstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:23:09 UTC 2022

Modified Files:
src/distrib/sets/lists/comp: mi
src/sys/netinet: Makefile in_pcb.h
src/sys/netipsec: ipsec.h
Removed Files:
src/sys/netinet: in_pcb_hdr.h

Log Message:
Remove in_pcb_hdr.h


To generate a diff of this commit:
cvs rdiff -u -r1.2424 -r1.2425 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.31 -r1.32 src/sys/netinet/Makefile
cvs rdiff -u -r1.71 -r1.72 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.15 -r0 src/sys/netinet/in_pcb_hdr.h
cvs rdiff -u -r1.92 -r1.93 src/sys/netipsec/ipsec.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:23:09 UTC 2022

Modified Files:
src/distrib/sets/lists/comp: mi
src/sys/netinet: Makefile in_pcb.h
src/sys/netipsec: ipsec.h
Removed Files:
src/sys/netinet: in_pcb_hdr.h

Log Message:
Remove in_pcb_hdr.h


To generate a diff of this commit:
cvs rdiff -u -r1.2424 -r1.2425 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.31 -r1.32 src/sys/netinet/Makefile
cvs rdiff -u -r1.71 -r1.72 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.15 -r0 src/sys/netinet/in_pcb_hdr.h
cvs rdiff -u -r1.92 -r1.93 src/sys/netipsec/ipsec.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2424 src/distrib/sets/lists/comp/mi:1.2425
--- src/distrib/sets/lists/comp/mi:1.2424	Tue Sep 20 07:19:14 2022
+++ src/distrib/sets/lists/comp/mi	Fri Oct 28 05:23:09 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2424 2022/09/20 07:19:14 ozaki-r Exp $
+#	$NetBSD: mi,v 1.2425 2022/10/28 05:23:09 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -2706,7 +2706,7 @@
 ./usr/include/netinet/in_l2tp.h			comp-c-include
 ./usr/include/netinet/in_offload.h		comp-c-include
 ./usr/include/netinet/in_pcb.h			comp-c-include
-./usr/include/netinet/in_pcb_hdr.h		comp-c-include
+./usr/include/netinet/in_pcb_hdr.h		comp-obsolete		obsolete
 ./usr/include/netinet/in_route.h		comp-obsolete		obsolete
 ./usr/include/netinet/in_selsrc.h		comp-c-include
 ./usr/include/netinet/in_systm.h		comp-c-include

Index: src/sys/netinet/Makefile
diff -u src/sys/netinet/Makefile:1.31 src/sys/netinet/Makefile:1.32
--- src/sys/netinet/Makefile:1.31	Tue Sep 20 07:19:14 2022
+++ src/sys/netinet/Makefile	Fri Oct 28 05:23:09 2022
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.31 2022/09/20 07:19:14 ozaki-r Exp $
+#	$NetBSD: Makefile,v 1.32 2022/10/28 05:23:09 ozaki-r Exp $
 
 INCSDIR= /usr/include/netinet
 
 INCS=	dccp.h icmp6.h icmp_var.h if_ether.h if_inarp.h igmp.h \
-	igmp_var.h in.h in_gif.h in_l2tp.h in_pcb.h in_pcb_hdr.h \
+	igmp_var.h in.h in_gif.h in_l2tp.h in_pcb.h \
 	in_offload.h in_selsrc.h in_systm.h \
 	in_var.h ip.h ip_carp.h ip6.h ip_ecn.h ip_encap.h \
 	ip_icmp.h ip_mroute.h ip_var.h pim.h pim_var.h portalgo.h \

Index: src/sys/netinet/in_pcb.h
diff -u src/sys/netinet/in_pcb.h:1.71 src/sys/netinet/in_pcb.h:1.72
--- src/sys/netinet/in_pcb.h:1.71	Fri Oct 28 05:18:39 2022
+++ src/sys/netinet/in_pcb.h	Fri Oct 28 05:23:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.h,v 1.71 2022/10/28 05:18:39 ozaki-r Exp $	*/
+/*	$NetBSD: in_pcb.h,v 1.72 2022/10/28 05:23:09 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -68,7 +68,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 

Index: src/sys/netipsec/ipsec.h
diff -u src/sys/netipsec/ipsec.h:1.92 src/sys/netipsec/ipsec.h:1.93
--- src/sys/netipsec/ipsec.h:1.92	Fri Oct 28 05:18:39 2022
+++ src/sys/netipsec/ipsec.h	Fri Oct 28 05:23:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.h,v 1.92 2022/10/28 05:18:39 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec.h,v 1.93 2022/10/28 05:23:09 ozaki-r Exp $	*/
 /*	$FreeBSD: ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $	*/
 
@@ -45,7 +45,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 



CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:20:08 UTC 2022

Modified Files:
src/sys/dist/pf/net: pf.c
src/sys/net: if_wg.c
src/sys/netinet: dccp_usrreq.c dccp_var.h sctp_pcb.h
src/sys/netinet6: dccp6_usrreq.c

Log Message:
Adjust pf, wg, dccp and sctp for struct inpcb integration


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dist/pf/net/pf.c
cvs rdiff -u -r1.69 -r1.70 src/sys/net/if_wg.c
cvs rdiff -u -r1.22 -r1.23 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.6 -r1.7 src/sys/netinet/dccp_var.h
cvs rdiff -u -r1.5 -r1.6 src/sys/netinet/sctp_pcb.h
cvs rdiff -u -r1.12 -r1.13 src/sys/netinet6/dccp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dist/pf/net/pf.c
diff -u src/sys/dist/pf/net/pf.c:1.84 src/sys/dist/pf/net/pf.c:1.85
--- src/sys/dist/pf/net/pf.c:1.84	Mon Aug 10 10:59:34 2020
+++ src/sys/dist/pf/net/pf.c	Fri Oct 28 05:20:08 2022
@@ -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 
-__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 @@ pf_socket_lookup(int direction, struct p
 	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);

Index: src/sys/net/if_wg.c
diff -u src/sys/net/if_wg.c:1.69 src/sys/net/if_wg.c:1.70
--- src/sys/net/if_wg.c:1.69	Fri Mar 25 08:57:50 2022
+++ src/sys/net/if_wg.c	Fri Oct 28 05:20:08 2022
@@ -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 
@@ -41,7 +41,7 @@
  */
 
 #include 
-__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 @@ wg_socreate(struct wg_softc *wg, int af,
 	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 @@ wg_send_udp(struct wg_peer *wgp, struct 
 		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);

Index: src/sys/netinet/dccp_usrreq.c
diff -u src/sys/netinet/dccp_usrreq.c:1.22 src/sys/netinet/dccp_usrreq.c:1.23
--- src/sys/netinet/dccp_usrreq.c:1.22	Sat Dec  4 13:23:04 2021
+++ src/sys/netinet/dccp_usrreq.c	Fri Oct 28 05:20:08 2022
@@ -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 
-__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 @@ dccp_input(struct mbuf *m, int off, int 
 	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 @@ dccp_input(struct mbuf *m, int off, int 
 	 */
 #ifdef INET6
 	if (isipv6) {
-		in6p = in6_pcblookup_connect(, >ip6_src,
+		inp = in6_pcblookup_connect(, >ip6_src,
 		dh->dh_sport, >ip6_dst, dh->dh_dport, 0, 0);
-		if (in6p == 0) {
+		if (inp == NULL) {
 			/* XXX stats increment? */
-			in6p = in6_pcblookup_bind(, >ip6_dst,
+			inp = in6_pcblookup_bind(, >ip6_dst,
 			dh->dh_dport, 0);
 		}
 	} else
@@ -357,12 +356,12 @@ dccp_input(struct mbuf *m, int off, int 
 		}
 	}
 	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 

CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:20:08 UTC 2022

Modified Files:
src/sys/dist/pf/net: pf.c
src/sys/net: if_wg.c
src/sys/netinet: dccp_usrreq.c dccp_var.h sctp_pcb.h
src/sys/netinet6: dccp6_usrreq.c

Log Message:
Adjust pf, wg, dccp and sctp for struct inpcb integration


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dist/pf/net/pf.c
cvs rdiff -u -r1.69 -r1.70 src/sys/net/if_wg.c
cvs rdiff -u -r1.22 -r1.23 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.6 -r1.7 src/sys/netinet/dccp_var.h
cvs rdiff -u -r1.5 -r1.6 src/sys/netinet/sctp_pcb.h
cvs rdiff -u -r1.12 -r1.13 src/sys/netinet6/dccp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2022-10-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Oct 28 05:18:39 UTC 2022

Modified Files:
src/sys/netinet: in_pcb.c in_pcb.h ip_output.c portalgo.c portalgo.h
raw_ip.c tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c
tcp_timer.c tcp_usrreq.c tcp_var.h tcp_vtw.c udp_usrreq.c
src/sys/netinet6: icmp6.c in6_pcb.c in6_pcb.h in6_src.c ip6_input.c
ip6_output.c ip6_var.h raw_ip6.c udp6_usrreq.c udp6_var.h
src/sys/netipsec: ipsec.c ipsec.h ipsec6.h

Log Message:
inpcb: integrate data structures of PCB into one

Data structures of network protocol control blocks (PCBs), i.e.,
struct inpcb, in6pcb and inpcb_hdr, are not organized well.  Users of
the data structures have to handle them separately and thus the code
is cluttered and duplicated.

The commit integrates the data structures into one, struct inpcb.  As a
result, users of PCBs only have to handle just one data structure, so
the code becomes simple.

One drawback is that the data size of PCB for IPv4 increases by 40 bytes
(from 248 bytes to 288 bytes).


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.70 -r1.71 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.320 -r1.321 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.11 -r1.12 src/sys/netinet/portalgo.c
cvs rdiff -u -r1.2 -r1.3 src/sys/netinet/portalgo.h \
src/sys/netinet/tcp_syncache.c
cvs rdiff -u -r1.181 -r1.182 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.434 -r1.435 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.214 -r1.215 src/sys/netinet/tcp_output.c
cvs rdiff -u -r1.291 -r1.292 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.96 -r1.97 src/sys/netinet/tcp_timer.c
cvs rdiff -u -r1.232 -r1.233 src/sys/netinet/tcp_usrreq.c
cvs rdiff -u -r1.197 -r1.198 src/sys/netinet/tcp_var.h
cvs rdiff -u -r1.21 -r1.22 src/sys/netinet/tcp_vtw.c
cvs rdiff -u -r1.261 -r1.262 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.252 -r1.253 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.171 -r1.172 src/sys/netinet6/in6_pcb.c
cvs rdiff -u -r1.53 -r1.54 src/sys/netinet6/in6_pcb.h
cvs rdiff -u -r1.88 -r1.89 src/sys/netinet6/in6_src.c
cvs rdiff -u -r1.226 -r1.227 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.229 -r1.230 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.92 -r1.93 src/sys/netinet6/ip6_var.h
cvs rdiff -u -r1.178 -r1.179 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.150 -r1.151 src/sys/netinet6/udp6_usrreq.c
cvs rdiff -u -r1.30 -r1.31 src/sys/netinet6/udp6_var.h
cvs rdiff -u -r1.173 -r1.174 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.91 -r1.92 src/sys/netipsec/ipsec.h
cvs rdiff -u -r1.30 -r1.31 src/sys/netipsec/ipsec6.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci/ixgbe

2022-10-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 28 01:10:41 UTC 2022

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
Make three "Unsupported SFP+ module..." messages the same.


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/sys/dev/pci/ixgbe/ixgbe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.323 src/sys/dev/pci/ixgbe/ixgbe.c:1.324
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.323	Wed Jul  6 06:31:47 2022
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Oct 28 01:10:41 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.323 2022/07/06 06:31:47 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.324 2022/10/28 01:10:41 msaitoh Exp $ */
 
 /**
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.323 2022/07/06 06:31:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.324 2022/10/28 01:10:41 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1001,7 +1001,8 @@ ixgbe_attach(device_t parent, device_t d
 	if (error == IXGBE_ERR_SFP_NOT_PRESENT)
 		error = IXGBE_SUCCESS;
 	else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-		aprint_error_dev(dev, "Unsupported SFP+ module detected!\n");
+		aprint_error_dev(dev,
+		"Unsupported SFP+ module type was detected.\n");
 		unsupported_sfp = true;
 		error = IXGBE_SUCCESS;
 	} else if (error) {



CVS commit: src/sys/dev/pci/ixgbe

2022-10-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 28 01:10:41 UTC 2022

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
Make three "Unsupported SFP+ module..." messages the same.


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/sys/dev/pci/ixgbe/ixgbe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 22:35:32 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_gpio.c

Log Message:
Fix bit macros


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/xilinx/zynq_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xilinx/zynq_gpio.c
diff -u src/sys/arch/arm/xilinx/zynq_gpio.c:1.1 src/sys/arch/arm/xilinx/zynq_gpio.c:1.2
--- src/sys/arch/arm/xilinx/zynq_gpio.c:1.1	Thu Oct 27 09:41:28 2022
+++ src/sys/arch/arm/xilinx/zynq_gpio.c	Thu Oct 27 22:35:31 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: zynq_gpio.c,v 1.1 2022/10/27 09:41:28 jmcneill Exp $ */
+/* $NetBSD: zynq_gpio.c,v 1.2 2022/10/27 22:35:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq_gpio.c,v 1.1 2022/10/27 09:41:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_gpio.c,v 1.2 2022/10/27 22:35:31 jmcneill Exp $");
 
 #include 
 #include 
@@ -48,11 +48,11 @@ __KERNEL_RCSID(0, "$NetBSD: zynq_gpio.c,
 #define	MASK_DATA_REG(pin)	(0x000 + 0x4 * ((pin) / 16))
 #define	MASK_DATA_SET(pin, val)	pin) % 16) << 16) | ((val) << ((pin) % 16)))
 #define	DATA_RO_REG(pin)	(0x060 + 0x4 * ((pin) / 32))
-#define	DATA_RO_BIT(pin)	((pin) % 32)
+#define	DATA_RO_BIT(pin)	__BIT((pin) % 32)
 #define	DIRM_REG(pin)		(0x204 + 0x40 * ((pin) / 32))
-#define	DIRM_BIT(pin)		((pin) % 32)
+#define	DIRM_BIT(pin)		__BIT((pin) % 32)
 #define	OEN_REG(pin)		(0x208 + 0x40 * ((pin) / 32))
-#define	OEN_BIT(pin)		((pin) % 32)
+#define	OEN_BIT(pin)		__BIT((pin) % 32)
 
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "xlnx,zynq-gpio-1.0" },



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 22:35:32 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_gpio.c

Log Message:
Fix bit macros


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/xilinx/zynq_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 20:37:10 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_platform.c

Log Message:
Add OCM to devmap


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/xilinx/zynq_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xilinx/zynq_platform.c
diff -u src/sys/arch/arm/xilinx/zynq_platform.c:1.7 src/sys/arch/arm/xilinx/zynq_platform.c:1.8
--- src/sys/arch/arm/xilinx/zynq_platform.c:1.7	Thu Oct 27 08:49:08 2022
+++ src/sys/arch/arm/xilinx/zynq_platform.c	Thu Oct 27 20:37:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq_platform.c,v 1.7 2022/10/27 08:49:08 jmcneill Exp $	*/
+/*	$NetBSD: zynq_platform.c,v 1.8 2022/10/27 20:37:10 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "arml2cc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq_platform.c,v 1.7 2022/10/27 08:49:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_platform.c,v 1.8 2022/10/27 20:37:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -77,6 +77,10 @@ __KERNEL_RCSID(0, "$NetBSD: zynq_platfor
 #define ZYNQ_ARMCORE_PBASE	0xf8f0
 #define ZYNQ_ARMCORE_SIZE	0x3000
 
+#define	ZYNQ_OCM_VBASE		(ZYNQ_ARMCORE_VBASE + ZYNQ_ARMCORE_SIZE)
+#define	ZYNQ_OCM_PBASE		0xfff0
+#define	ZYNQ_OCM_SIZE		0x0010
+
 #define	ZYNQ_ARMCORE_SCU_BASE	0x
 #define	ZYNQ_ARMCORE_L2C_BASE	0x2000
 
@@ -101,6 +105,9 @@ zynq_platform_devmap(void)
 		DEVMAP_ENTRY(ZYNQ_ARMCORE_VBASE,
 			 ZYNQ_ARMCORE_PBASE,
 			 ZYNQ_ARMCORE_SIZE),
+		DEVMAP_ENTRY(ZYNQ_OCM_VBASE,
+			 ZYNQ_OCM_PBASE,
+			 ZYNQ_OCM_SIZE),
 		DEVMAP_ENTRY_END
 	};
 



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 20:37:10 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_platform.c

Log Message:
Add OCM to devmap


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/xilinx/zynq_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ddb

2022-10-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Oct 27 20:00:24 UTC 2022

Modified Files:
src/sys/ddb: db_active.h

Log Message:
ddb(4): Declare extern db_active if _KMEMUSER too, not just DDB.

crash(8) is built with _KMEMUSER defined but DDB not defined except
for a few specific files or on MIPS.

Seems to me crash(8) should really be built with DDB defined in all
.c files but that leads to other fallout I'm not really inclined to
diagnose right now.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/ddb/db_active.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ddb

2022-10-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Oct 27 20:00:24 UTC 2022

Modified Files:
src/sys/ddb: db_active.h

Log Message:
ddb(4): Declare extern db_active if _KMEMUSER too, not just DDB.

crash(8) is built with _KMEMUSER defined but DDB not defined except
for a few specific files or on MIPS.

Seems to me crash(8) should really be built with DDB defined in all
.c files but that leads to other fallout I'm not really inclined to
diagnose right now.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/ddb/db_active.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ddb/db_active.h
diff -u src/sys/ddb/db_active.h:1.1 src/sys/ddb/db_active.h:1.2
--- src/sys/ddb/db_active.h:1.1	Wed Oct 26 23:38:09 2022
+++ src/sys/ddb/db_active.h	Thu Oct 27 20:00:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_active.h,v 1.1 2022/10/26 23:38:09 riastradh Exp $	*/
+/*	$NetBSD: db_active.h,v 1.2 2022/10/27 20:00:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 
-#ifdef DDB
+#if defined DDB || defined _KMEMUSER
 extern int db_active;
 #else
 static const int db_active __unused = 0;



CVS commit: src/crypto/external/bsd/openssl/dist/ssl

2022-10-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct 27 16:20:23 UTC 2022

Modified Files:
src/crypto/external/bsd/openssl/dist/ssl: ssl_ciph.c

Log Message:
merge upstream commit 9b3219ba544db82cdad3058b9872058739559944:

If rule_str ended in a "-", "l" was incremented one byte past the
end of the buffer.  This resulted in an out-of-bounds read when "l"
is dereferenced at the end of the loop.  It is safest to just return
early in this case since the condition occurs inside a nested loop.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/crypto/external/bsd/openssl/dist/ssl

2022-10-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct 27 16:20:23 UTC 2022

Modified Files:
src/crypto/external/bsd/openssl/dist/ssl: ssl_ciph.c

Log Message:
merge upstream commit 9b3219ba544db82cdad3058b9872058739559944:

If rule_str ended in a "-", "l" was incremented one byte past the
end of the buffer.  This resulted in an out-of-bounds read when "l"
is dereferenced at the end of the loop.  It is safest to just return
early in this case since the condition occurs inside a nested loop.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c
diff -u src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c:1.21 src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c:1.22
--- src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c:1.21	Fri Jan  7 10:50:11 2022
+++ src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c	Thu Oct 27 12:20:23 2022
@@ -1026,9 +1026,7 @@ static int ssl_cipher_process_rulestr(co
  * alphanumeric, so we call this an error.
  */
 SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR, SSL_R_INVALID_COMMAND);
-retval = found = 0;
-l++;
-break;
+		return 0;
 }
 
 if (rule == CIPHER_SPECIAL) {



CVS commit: [netbsd-8] src/doc

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:19:25 UTC 2022

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Tickets #1778 and #1779


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.157 -r1.1.2.158 src/doc/CHANGES-8.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.157 src/doc/CHANGES-8.3:1.1.2.158
--- src/doc/CHANGES-8.3:1.1.2.157	Wed Oct 26 18:19:42 2022
+++ src/doc/CHANGES-8.3	Thu Oct 27 16:19:25 2022
@@ -1,4 +1,4 @@
- $NetBSD: CHANGES-8.3,v 1.1.2.157 2022/10/26 18:19:42 martin Exp $
+ $NetBSD: CHANGES-8.3,v 1.1.2.158 2022/10/27 16:19:25 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -2973,3 +2973,14 @@ doc/3RDPARTY	(apply patch)
 	Updata tzdata to 2022e.
 	[kre, ticket #1777]
 
+sys/netinet6/frag6.c1.76
+
+	frag6: do not use a spin mutex for frag6_lock.
+	[ozaki-r, ticket #1778]
+
+bin/sh/miscbltin.c1.51,1.52
+
+	PR 56972: fix escape ('\') handling in sh read builtin
+	and cosmetic improvements to error reporting.
+	[kre, ticket #1779]
+



CVS commit: [netbsd-8] src/doc

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:19:25 UTC 2022

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Tickets #1778 and #1779


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.157 -r1.1.2.158 src/doc/CHANGES-8.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-8] src/bin/sh

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:16:50 UTC 2022

Modified Files:
src/bin/sh [netbsd-8]: miscbltin.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #1779):

bin/sh/miscbltin.c: revision 1.51
bin/sh/miscbltin.c: revision 1.52

PR bin/56972  Fix escape ('\') handling in sh read builtin.

In 1.35 (March 2005) (the big read fixup), most escape handling and IFS
processing in the read builtin was corrected.  However 2 cases were missed,
one is a word (something to be assigned to any variable but the last) in
which every character is escaped (the code was relying on a non-escaped char
to set the "in a word" status), and second trailing IFS whitespace at
the end of the line was being deleted, even if the chars had been escaped
(the escape chars are no longer present).

See the PR for more details (including the case that detected the problem).

After fixing this, I looked at the FreeBSD code (normally might do it
before, but these fixes were trivial) to check their implementation.

Their code does similar things to ours now does, but in a completely
different way, their read builtin is more complex than ours needs to
be (they handle more options).   For anyone tempted to simply incorporate
their code, note that it relies upon infrastructure changes elsewhere
in the shell, so would not be a simple cut and drop in exercise.

This needs pullups to -3 -4 -5 -6 -7 -8 and -9 (fortunately this is
happening before -10 is branched, so will never be broken this way there).

 -

Don't output the error for bad usage (no var name given)
after already writing the prompt (set with the -p option).

That results in nonsense like:
$ read -p foo
fooread: arg count

While here, improve the error message so it means something.

Now we will get:
$ read -p foo
read: variable name required
Usage: read [-r] [-p prompt] var...

[Detected by code reading while doing the work for the previous fix]


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/bin/sh/miscbltin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/miscbltin.c
diff -u src/bin/sh/miscbltin.c:1.44 src/bin/sh/miscbltin.c:1.44.2.1
--- src/bin/sh/miscbltin.c:1.44	Sat May 13 15:03:34 2017
+++ src/bin/sh/miscbltin.c	Thu Oct 27 16:16:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: miscbltin.c,v 1.44 2017/05/13 15:03:34 gson Exp $	*/
+/*	$NetBSD: miscbltin.c,v 1.44.2.1 2022/10/27 16:16:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)miscbltin.c	8.4 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: miscbltin.c,v 1.44 2017/05/13 15:03:34 gson Exp $");
+__RCSID("$NetBSD: miscbltin.c,v 1.44.2.1 2022/10/27 16:16:50 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -99,6 +99,7 @@ readcmd(int argc, char **argv)
 	int i;
 	int is_ifs;
 	int saveall = 0;
+	ptrdiff_t wordlen = 0;
 
 	rflag = 0;
 	prompt = NULL;
@@ -109,14 +110,15 @@ readcmd(int argc, char **argv)
 			rflag = 1;
 	}
 
+	if (*(ap = argptr) == NULL)
+		error("variable name required\n"
+			"Usage: read [-r] [-p prompt] var...");
+
 	if (prompt && isatty(0)) {
 		out2str(prompt);
 		flushall();
 	}
 
-	if (*(ap = argptr) == NULL)
-		error("arg count");
-
 	if ((ifs = bltinlookup("IFS", 1)) == NULL)
 		ifs = " \t\n";
 
@@ -136,7 +138,7 @@ readcmd(int argc, char **argv)
 break;
 			}
 			if (c != '\n')
-STPUTC(c, p);
+goto wdch;
 			continue;
 		}
 		if (c == '\n')
@@ -163,12 +165,14 @@ readcmd(int argc, char **argv)
 		}
 
 		if (is_ifs == 0) {
+  wdch:;
 			/* append this character to the current variable */
 			startword = 0;
 			if (saveall)
 /* Not just a spare terminator */
 saveall++;
 			STPUTC(c, p);
+			wordlen = p - stackblock();
 			continue;
 		}
 
@@ -186,11 +190,12 @@ readcmd(int argc, char **argv)
 		setvar(*ap, stackblock(), 0);
 		ap++;
 		STARTSTACKSTR(p);
+		wordlen = 0;
 	}
 	STACKSTRNUL(p);
 
 	/* Remove trailing IFS chars */
-	for (; stackblock() <= --p; *p = 0) {
+	for (; stackblock() + wordlen <= --p; *p = 0) {
 		if (!strchr(ifs, *p))
 			break;
 		if (strchr(" \t\n", *p))



CVS commit: [netbsd-8] src/bin/sh

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:16:50 UTC 2022

Modified Files:
src/bin/sh [netbsd-8]: miscbltin.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #1779):

bin/sh/miscbltin.c: revision 1.51
bin/sh/miscbltin.c: revision 1.52

PR bin/56972  Fix escape ('\') handling in sh read builtin.

In 1.35 (March 2005) (the big read fixup), most escape handling and IFS
processing in the read builtin was corrected.  However 2 cases were missed,
one is a word (something to be assigned to any variable but the last) in
which every character is escaped (the code was relying on a non-escaped char
to set the "in a word" status), and second trailing IFS whitespace at
the end of the line was being deleted, even if the chars had been escaped
(the escape chars are no longer present).

See the PR for more details (including the case that detected the problem).

After fixing this, I looked at the FreeBSD code (normally might do it
before, but these fixes were trivial) to check their implementation.

Their code does similar things to ours now does, but in a completely
different way, their read builtin is more complex than ours needs to
be (they handle more options).   For anyone tempted to simply incorporate
their code, note that it relies upon infrastructure changes elsewhere
in the shell, so would not be a simple cut and drop in exercise.

This needs pullups to -3 -4 -5 -6 -7 -8 and -9 (fortunately this is
happening before -10 is branched, so will never be broken this way there).

 -

Don't output the error for bad usage (no var name given)
after already writing the prompt (set with the -p option).

That results in nonsense like:
$ read -p foo
fooread: arg count

While here, improve the error message so it means something.

Now we will get:
$ read -p foo
read: variable name required
Usage: read [-r] [-p prompt] var...

[Detected by code reading while doing the work for the previous fix]


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/bin/sh/miscbltin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/doc

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:15:58 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.4

Log Message:
Tickets #1548 and #1549


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.27 -r1.1.2.28 src/doc/CHANGES-9.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-9.4
diff -u src/doc/CHANGES-9.4:1.1.2.27 src/doc/CHANGES-9.4:1.1.2.28
--- src/doc/CHANGES-9.4:1.1.2.27	Tue Oct 25 17:54:59 2022
+++ src/doc/CHANGES-9.4	Thu Oct 27 16:15:57 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.4,v 1.1.2.27 2022/10/25 17:54:59 martin Exp $
+# $NetBSD: CHANGES-9.4,v 1.1.2.28 2022/10/27 16:15:57 martin Exp $
 
 A complete list of changes from the NetBSD 9.3 release to the NetBSD 9.4
 release:
@@ -422,3 +422,14 @@ usr.bin/progress/progress.c			1.24,1.25
 	PR 56303: progress(1): fix error handling.
 	[riastradh, ticket #1547]
 
+sys/netinet6/frag6.c1.76
+
+	frag6: do not use a spin mutex for frag6_lock.
+	[ozaki-r, ticket #1548]
+
+bin/sh/miscbltin.c1.51,1.52
+
+	PR 56972: fix escape ('\') handling in sh read builtin
+	and cosmetic improvements to error reporting.
+	[kre, ticket #1549]
+



CVS commit: [netbsd-9] src/doc

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:15:58 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.4

Log Message:
Tickets #1548 and #1549


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.27 -r1.1.2.28 src/doc/CHANGES-9.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/bin/sh

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:14:42 UTC 2022

Modified Files:
src/bin/sh [netbsd-9]: miscbltin.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #1549):

bin/sh/miscbltin.c: revision 1.51
bin/sh/miscbltin.c: revision 1.52

PR bin/56972  Fix escape ('\') handling in sh read builtin.

In 1.35 (March 2005) (the big read fixup), most escape handling and IFS
processing in the read builtin was corrected.  However 2 cases were missed,
one is a word (something to be assigned to any variable but the last) in
which every character is escaped (the code was relying on a non-escaped char
to set the "in a word" status), and second trailing IFS whitespace at
the end of the line was being deleted, even if the chars had been escaped
(the escape chars are no longer present).

See the PR for more details (including the case that detected the problem).

After fixing this, I looked at the FreeBSD code (normally might do it
before, but these fixes were trivial) to check their implementation.

Their code does similar things to ours now does, but in a completely
different way, their read builtin is more complex than ours needs to
be (they handle more options).   For anyone tempted to simply incorporate
their code, note that it relies upon infrastructure changes elsewhere
in the shell, so would not be a simple cut and drop in exercise.

This needs pullups to -3 -4 -5 -6 -7 -8 and -9 (fortunately this is
happening before -10 is branched, so will never be broken this way there).

 -

Don't output the error for bad usage (no var name given)
after already writing the prompt (set with the -p option).

That results in nonsense like:
$ read -p foo
fooread: arg count

While here, improve the error message so it means something.

Now we will get:
$ read -p foo
read: variable name required
Usage: read [-r] [-p prompt] var...

[Detected by code reading while doing the work for the previous fix]


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.12.1 src/bin/sh/miscbltin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/miscbltin.c
diff -u src/bin/sh/miscbltin.c:1.44 src/bin/sh/miscbltin.c:1.44.12.1
--- src/bin/sh/miscbltin.c:1.44	Sat May 13 15:03:34 2017
+++ src/bin/sh/miscbltin.c	Thu Oct 27 16:14:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: miscbltin.c,v 1.44 2017/05/13 15:03:34 gson Exp $	*/
+/*	$NetBSD: miscbltin.c,v 1.44.12.1 2022/10/27 16:14:42 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)miscbltin.c	8.4 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: miscbltin.c,v 1.44 2017/05/13 15:03:34 gson Exp $");
+__RCSID("$NetBSD: miscbltin.c,v 1.44.12.1 2022/10/27 16:14:42 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -99,6 +99,7 @@ readcmd(int argc, char **argv)
 	int i;
 	int is_ifs;
 	int saveall = 0;
+	ptrdiff_t wordlen = 0;
 
 	rflag = 0;
 	prompt = NULL;
@@ -109,14 +110,15 @@ readcmd(int argc, char **argv)
 			rflag = 1;
 	}
 
+	if (*(ap = argptr) == NULL)
+		error("variable name required\n"
+			"Usage: read [-r] [-p prompt] var...");
+
 	if (prompt && isatty(0)) {
 		out2str(prompt);
 		flushall();
 	}
 
-	if (*(ap = argptr) == NULL)
-		error("arg count");
-
 	if ((ifs = bltinlookup("IFS", 1)) == NULL)
 		ifs = " \t\n";
 
@@ -136,7 +138,7 @@ readcmd(int argc, char **argv)
 break;
 			}
 			if (c != '\n')
-STPUTC(c, p);
+goto wdch;
 			continue;
 		}
 		if (c == '\n')
@@ -163,12 +165,14 @@ readcmd(int argc, char **argv)
 		}
 
 		if (is_ifs == 0) {
+  wdch:;
 			/* append this character to the current variable */
 			startword = 0;
 			if (saveall)
 /* Not just a spare terminator */
 saveall++;
 			STPUTC(c, p);
+			wordlen = p - stackblock();
 			continue;
 		}
 
@@ -186,11 +190,12 @@ readcmd(int argc, char **argv)
 		setvar(*ap, stackblock(), 0);
 		ap++;
 		STARTSTACKSTR(p);
+		wordlen = 0;
 	}
 	STACKSTRNUL(p);
 
 	/* Remove trailing IFS chars */
-	for (; stackblock() <= --p; *p = 0) {
+	for (; stackblock() + wordlen <= --p; *p = 0) {
 		if (!strchr(ifs, *p))
 			break;
 		if (strchr(" \t\n", *p))



CVS commit: [netbsd-9] src/bin/sh

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:14:42 UTC 2022

Modified Files:
src/bin/sh [netbsd-9]: miscbltin.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #1549):

bin/sh/miscbltin.c: revision 1.51
bin/sh/miscbltin.c: revision 1.52

PR bin/56972  Fix escape ('\') handling in sh read builtin.

In 1.35 (March 2005) (the big read fixup), most escape handling and IFS
processing in the read builtin was corrected.  However 2 cases were missed,
one is a word (something to be assigned to any variable but the last) in
which every character is escaped (the code was relying on a non-escaped char
to set the "in a word" status), and second trailing IFS whitespace at
the end of the line was being deleted, even if the chars had been escaped
(the escape chars are no longer present).

See the PR for more details (including the case that detected the problem).

After fixing this, I looked at the FreeBSD code (normally might do it
before, but these fixes were trivial) to check their implementation.

Their code does similar things to ours now does, but in a completely
different way, their read builtin is more complex than ours needs to
be (they handle more options).   For anyone tempted to simply incorporate
their code, note that it relies upon infrastructure changes elsewhere
in the shell, so would not be a simple cut and drop in exercise.

This needs pullups to -3 -4 -5 -6 -7 -8 and -9 (fortunately this is
happening before -10 is branched, so will never be broken this way there).

 -

Don't output the error for bad usage (no var name given)
after already writing the prompt (set with the -p option).

That results in nonsense like:
$ read -p foo
fooread: arg count

While here, improve the error message so it means something.

Now we will get:
$ read -p foo
read: variable name required
Usage: read [-r] [-p prompt] var...

[Detected by code reading while doing the work for the previous fix]


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.12.1 src/bin/sh/miscbltin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-8] src/sys/netinet6

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:08:50 UTC 2022

Modified Files:
src/sys/netinet6 [netbsd-8]: frag6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1778):

sys/netinet6/frag6.c: revision 1.76

frag6: don't use spin mutex for frag6_lock

frag6_lock is held during sending a packet (icmp6_error), so we must
not use a spin mutex because we can acquire sleep locks on sending
a packet.

Also we don't need to use spin mutex for frag6_lock anymore because
frag6_lock is now not used from hardware interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.60.6.5 -r1.60.6.6 src/sys/netinet6/frag6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/frag6.c
diff -u src/sys/netinet6/frag6.c:1.60.6.5 src/sys/netinet6/frag6.c:1.60.6.6
--- src/sys/netinet6/frag6.c:1.60.6.5	Thu Sep 27 15:07:35 2018
+++ src/sys/netinet6/frag6.c	Thu Oct 27 16:08:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: frag6.c,v 1.60.6.5 2018/09/27 15:07:35 martin Exp $	*/
+/*	$NetBSD: frag6.c,v 1.60.6.6 2022/10/27 16:08:50 martin Exp $	*/
 /*	$KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.60.6.5 2018/09/27 15:07:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.60.6.6 2022/10/27 16:08:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -80,7 +80,7 @@ frag6_init(void)
 {
 
 	ip6q.ip6q_next = ip6q.ip6q_prev = 
-	mutex_init(_lock, MUTEX_DEFAULT, IPL_NET);
+	mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
 /*



CVS commit: [netbsd-8] src/sys/netinet6

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:08:50 UTC 2022

Modified Files:
src/sys/netinet6 [netbsd-8]: frag6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1778):

sys/netinet6/frag6.c: revision 1.76

frag6: don't use spin mutex for frag6_lock

frag6_lock is held during sending a packet (icmp6_error), so we must
not use a spin mutex because we can acquire sleep locks on sending
a packet.

Also we don't need to use spin mutex for frag6_lock anymore because
frag6_lock is now not used from hardware interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.60.6.5 -r1.60.6.6 src/sys/netinet6/frag6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src

2022-10-27 Thread David H. Gutteridge

Module Name:src
Committed By:   andvar
Date:   Wed Oct 26 21:56:19 UTC 2022

Modified Files:
   src/sys/dev/spi: spiflash.c
   src/usr.sbin/makefs: README
   src/usr.sbin/makemandb: makemandb.c

Log Message:
fix various typos in comments and makefs README file.

[...]

--- a/usr.sbin/makemandb/makemandb.cWed Oct 26 21:18:49 2022 +
+++ b/usr.sbin/makemandb/makemandb.cWed Oct 26 21:56:19 2022 +

[...]

@@ -503,9 +503,9 @@
}

/* build_file_cache --
- *   This function generates an md5 hash of the file passed as its 2nd 
parameter
+ *   This function generates a md5 hash of the file passed as its 2nd 
parameter


Hi,

This was correct before. It should be "an md5", as we'd write "an M".
(The rule is based on pronunciation. That is, everyone I know would say
"em dee five", not "mhd-five".) (If anything could be changed there, it
should perhaps be "MD5".)

Regards,

Dave


CVS commit: [netbsd-9] src/sys/netinet6

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:06:24 UTC 2022

Modified Files:
src/sys/netinet6 [netbsd-9]: frag6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1548):

sys/netinet6/frag6.c: revision 1.76

frag6: don't use spin mutex for frag6_lock

frag6_lock is held during sending a packet (icmp6_error), so we must
not use a spin mutex because we can acquire sleep locks on sending
a packet.

Also we don't need to use spin mutex for frag6_lock anymore because
frag6_lock is now not used from hardware interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.74.6.1 src/sys/netinet6/frag6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/frag6.c
diff -u src/sys/netinet6/frag6.c:1.74 src/sys/netinet6/frag6.c:1.74.6.1
--- src/sys/netinet6/frag6.c:1.74	Tue May 15 19:16:38 2018
+++ src/sys/netinet6/frag6.c	Thu Oct 27 16:06:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: frag6.c,v 1.74 2018/05/15 19:16:38 maxv Exp $	*/
+/*	$NetBSD: frag6.c,v 1.74.6.1 2022/10/27 16:06:24 martin Exp $	*/
 /*	$KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.74 2018/05/15 19:16:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.74.6.1 2022/10/27 16:06:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -117,7 +117,7 @@ frag6_init(void)
 {
 
 	ip6q.ip6q_next = ip6q.ip6q_prev = 
-	mutex_init(_lock, MUTEX_DEFAULT, IPL_NET);
+	mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
 /*



CVS commit: [netbsd-9] src/sys/netinet6

2022-10-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 27 16:06:24 UTC 2022

Modified Files:
src/sys/netinet6 [netbsd-9]: frag6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1548):

sys/netinet6/frag6.c: revision 1.76

frag6: don't use spin mutex for frag6_lock

frag6_lock is held during sending a packet (icmp6_error), so we must
not use a spin mutex because we can acquire sleep locks on sending
a packet.

Also we don't need to use spin mutex for frag6_lock anymore because
frag6_lock is now not used from hardware interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.74.6.1 src/sys/netinet6/frag6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libutil

2022-10-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 27 12:59:59 UTC 2022

Modified Files:
src/tests/lib/libutil: t_sockaddr_snprintf.c

Log Message:
Revert for if_dl.h's change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libutil/t_sockaddr_snprintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libutil

2022-10-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 27 12:59:59 UTC 2022

Modified Files:
src/tests/lib/libutil: t_sockaddr_snprintf.c

Log Message:
Revert for if_dl.h's change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libutil/t_sockaddr_snprintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libutil/t_sockaddr_snprintf.c
diff -u src/tests/lib/libutil/t_sockaddr_snprintf.c:1.2 src/tests/lib/libutil/t_sockaddr_snprintf.c:1.3
--- src/tests/lib/libutil/t_sockaddr_snprintf.c:1.2	Mon Oct 24 13:42:55 2022
+++ src/tests/lib/libutil/t_sockaddr_snprintf.c	Thu Oct 27 12:59:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sockaddr_snprintf.c,v 1.2 2022/10/24 13:42:55 msaitoh Exp $ */
+/* $NetBSD: t_sockaddr_snprintf.c,v 1.3 2022/10/27 12:59:59 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2002, 2004, 2008, 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008, 2010\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sockaddr_snprintf.c,v 1.2 2022/10/24 13:42:55 msaitoh Exp $");
+__RCSID("$NetBSD: t_sockaddr_snprintf.c,v 1.3 2022/10/27 12:59:59 msaitoh Exp $");
 
 #include 		/* AF_ */
 #include 			/* sun */
@@ -169,7 +169,7 @@ ATF_TC_BODY(sockaddr_snprintf_dl, tc)
 		(struct sockaddr *));
 
 	ATF_REQUIRE_EQ_MSG(i, 17, "bad length for sdl");
-	ATF_REQUIRE_STREQ(buf, "18 32 1.2.3.4.5.6");
+	ATF_REQUIRE_STREQ(buf, "18 20 1.2.3.4.5.6");
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/sys/arch

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 09:41:28 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: files.zynq
src/sys/arch/evbarm/conf: GENERIC
Added Files:
src/sys/arch/arm/xilinx: zynq_gpio.c

Log Message:
Add driver for Zynq GPIO controller.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/xilinx/files.zynq
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/xilinx/zynq_gpio.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/evbarm/conf/GENERIC

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 09:41:28 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: files.zynq
src/sys/arch/evbarm/conf: GENERIC
Added Files:
src/sys/arch/arm/xilinx: zynq_gpio.c

Log Message:
Add driver for Zynq GPIO controller.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/xilinx/files.zynq
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/xilinx/zynq_gpio.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/evbarm/conf/GENERIC

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xilinx/files.zynq
diff -u src/sys/arch/arm/xilinx/files.zynq:1.3 src/sys/arch/arm/xilinx/files.zynq:1.4
--- src/sys/arch/arm/xilinx/files.zynq:1.3	Wed Oct 26 10:55:23 2022
+++ src/sys/arch/arm/xilinx/files.zynq	Thu Oct 27 09:41:28 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.zynq,v 1.3 2022/10/26 10:55:23 jmcneill Exp $
+#	$NetBSD: files.zynq,v 1.4 2022/10/27 09:41:28 jmcneill Exp $
 #
 # Configuration info for Xilinx Zynq-7000 SoC
 #
@@ -10,16 +10,16 @@ file	arch/arm/xilinx/zynq_platform.c		so
 defflag	opt_soc.hSOC_ZYNQ
 defflag	opt_soc.hSOC_ZYNQ7000: SOC_ZYNQ
 
-# System Level Control Module
-#device	zynqslcr
-#attach	zynqslcr at fdt
-#file	arch/arm/xilinx/zynq_slcr.c		zynqslcr needs-flag
-
 # PS clock subsystem
 device	zynqclk
 attach	zynqclk at fdt with zynq7000_clkc
 file	arch/arm/xilinx/zynq7000_clkc.c		zynq7000_clkc
 
+# GPIO
+device	zynqgpio: gpiobus
+attach	zynqgpio at fdt
+file	arch/arm/xilinx/zynq_gpio.c		zynqgpio
+
 # UART
 device	zynquart
 attach	zynquart at fdt

Index: src/sys/arch/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.109 src/sys/arch/evbarm/conf/GENERIC:1.110
--- src/sys/arch/evbarm/conf/GENERIC:1.109	Tue Oct 25 22:27:49 2022
+++ src/sys/arch/evbarm/conf/GENERIC	Thu Oct 27 09:41:28 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.109 2022/10/25 22:27:49 jmcneill Exp $
+#	$NetBSD: GENERIC,v 1.110 2022/10/27 09:41:28 jmcneill Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -270,6 +270,7 @@ sunxigpio* 	at fdt? pass 3		# Allwinner 
 rkgpio*		at rkiomux?		# Rockchip GPIO
 tegragpio* 	at fdt? pass 2		# NVIDIA Tegra GPIO
 tigpio* 	at fdt? pass 2		# TI GPIO
+zynqgpio*	at fdt? pass 2		# Xilinx Zynq GPIO
 gpio* 		at gpiobus?
 
 # IOMUX / MPIO / Pinmux

Added files:

Index: src/sys/arch/arm/xilinx/zynq_gpio.c
diff -u /dev/null src/sys/arch/arm/xilinx/zynq_gpio.c:1.1
--- /dev/null	Thu Oct 27 09:41:28 2022
+++ src/sys/arch/arm/xilinx/zynq_gpio.c	Thu Oct 27 09:41:28 2022
@@ -0,0 +1,292 @@
+/* $NetBSD: zynq_gpio.c,v 1.1 2022/10/27 09:41:28 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2022 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: zynq_gpio.c,v 1.1 2022/10/27 09:41:28 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define	ZYNQ_GPIO_NPINS		(4 * 32)
+
+#define	MASK_DATA_REG(pin)	(0x000 + 0x4 * ((pin) / 16))
+#define	MASK_DATA_SET(pin, val)	pin) % 16) << 16) | ((val) << ((pin) % 16)))
+#define	DATA_RO_REG(pin)	(0x060 + 0x4 * ((pin) / 32))
+#define	DATA_RO_BIT(pin)	((pin) % 32)
+#define	DIRM_REG(pin)		(0x204 + 0x40 * ((pin) / 32))
+#define	DIRM_BIT(pin)		((pin) % 32)
+#define	OEN_REG(pin)		(0x208 + 0x40 * ((pin) / 32))
+#define	OEN_BIT(pin)		((pin) % 32)
+
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "xlnx,zynq-gpio-1.0" },
+	DEVICE_COMPAT_EOL
+};
+
+struct zynq_gpio_softc {
+	device_t sc_dev;
+	bus_space_tag_t sc_bst;
+	bus_space_handle_t sc_bsh;
+	kmutex_t sc_lock;
+	struct 

CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 08:49:08 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_platform.c

Log Message:
Add AP startup for Zynq-7000.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/xilinx/zynq_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xilinx/zynq_platform.c
diff -u src/sys/arch/arm/xilinx/zynq_platform.c:1.6 src/sys/arch/arm/xilinx/zynq_platform.c:1.7
--- src/sys/arch/arm/xilinx/zynq_platform.c:1.6	Tue Oct 25 22:59:10 2022
+++ src/sys/arch/arm/xilinx/zynq_platform.c	Thu Oct 27 08:49:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq_platform.c,v 1.6 2022/10/25 22:59:10 jmcneill Exp $	*/
+/*	$NetBSD: zynq_platform.c,v 1.7 2022/10/27 08:49:08 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "arml2cc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq_platform.c,v 1.6 2022/10/25 22:59:10 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_platform.c,v 1.7 2022/10/27 08:49:08 jmcneill Exp $");
 
 #include 
 #include 
@@ -50,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: zynq_platfor
 #include 
 
 #include 
+#include 
 #include 
 
 #include 
@@ -58,8 +59,9 @@ __KERNEL_RCSID(0, "$NetBSD: zynq_platfor
 
 #include 
 
-#define	ZYNQ_REF_FREQ	2400
+#include 
 
+#define	ZYNQ_REF_FREQ	2400
 #define	ZYNQ7000_DDR_PBASE	0x
 #define	ZYNQ7000_DDR_SIZE	0x4000
 
@@ -75,6 +77,12 @@ __KERNEL_RCSID(0, "$NetBSD: zynq_platfor
 #define ZYNQ_ARMCORE_PBASE	0xf8f0
 #define ZYNQ_ARMCORE_SIZE	0x3000
 
+#define	ZYNQ_ARMCORE_SCU_BASE	0x
+#define	ZYNQ_ARMCORE_L2C_BASE	0x2000
+
+#define	ZYNQ7000_CPU1_ENTRY	0xfff0
+#define	ZYNQ7000_CPU1_ENTRY_SZ	4
+
 extern struct bus_space arm_generic_bs_tag;
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 
@@ -135,7 +143,51 @@ zynq_platform_uart_freq(void)
 	return ZYNQ_REF_FREQ;
 }
 
-#define ZYNQ_ARMCORE_L2C_BASE	0x2000
+#ifdef MULTIPROCESSOR
+static int
+zynq_platform_mpstart(void)
+{
+	bus_space_tag_t bst = _generic_bs_tag;
+	bus_space_handle_t bsh;
+	uint32_t val;
+	int error;
+	u_int i;
+
+	/* Invalidate all SCU cache tags and enable SCU. */
+	bsh = ZYNQ_ARMCORE_VBASE + ZYNQ_ARMCORE_SCU_BASE;
+	bus_space_write_4(bst, bsh, SCU_INV_ALL_REG, 0x);
+	val = bus_space_read_4(bst, bsh, SCU_CTL);
+	bus_space_write_4(bst, bsh, SCU_CTL, val | SCU_CTL_SCU_ENA);
+	armv7_dcache_wbinv_all();
+
+	/* Write start address for CPU1. */
+	error = bus_space_map(bst, ZYNQ7000_CPU1_ENTRY,
+	ZYNQ7000_CPU1_ENTRY_SZ, 0, );
+	if (error) {
+		panic("%s: Couldn't map OCM: %d", __func__, error);
+	}
+	bus_space_write_4(bst, bsh, 0, KERN_VTOPHYS((vaddr_t)cpu_mpstart));
+	bus_space_unmap(bst, bsh, ZYNQ7000_CPU1_ENTRY_SZ);
+
+	dsb(sy);
+	sev();
+
+	const u_int cpuindex = 1;
+	for (i = 0x1000; i > 0; i--) {
+		if (cpu_hatched_p(cpuindex)) {
+			break;
+		}
+	}
+	if (i == 0) {
+		aprint_error("cpu%d: WARNING: AP failed to start\n",
+		cpuindex);
+		return EIO;
+	}
+
+	return 0;
+}
+#endif
+
 #define ZYNQ_ARM_PL310_BASE	ZYNQ_ARMCORE_VBASE + ZYNQ_ARMCORE_L2C_BASE
 
 static void
@@ -184,8 +236,8 @@ static const struct arm_platform zynq_pl
 	.ap_reset = zynq_platform_reset,
 	.ap_delay = a9tmr_delay,
 	.ap_uart_freq = zynq_platform_uart_freq,
-#if 0
-	.ap_mpstart = arm_fdt_cpu_mpstart,
+#ifdef MULTIPROCESSOR
+	.ap_mpstart = zynq_platform_mpstart,
 #endif
 };
 



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 27 08:49:08 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_platform.c

Log Message:
Add AP startup for Zynq-7000.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/xilinx/zynq_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 07:57:46 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_uart.c

Log Message:
Fix build.
Sprinkle some consistency


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/xilinx/zynq_uart.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xilinx/zynq_uart.c
diff -u src/sys/arch/arm/xilinx/zynq_uart.c:1.4 src/sys/arch/arm/xilinx/zynq_uart.c:1.5
--- src/sys/arch/arm/xilinx/zynq_uart.c:1.4	Wed Oct 26 23:38:07 2022
+++ src/sys/arch/arm/xilinx/zynq_uart.c	Thu Oct 27 07:57:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq_uart.c,v 1.4 2022/10/26 23:38:07 riastradh Exp $	*/
+/*	$NetBSD: zynq_uart.c,v 1.5 2022/10/27 07:57:46 skrll Exp $	*/
 
 /*
  * Copyright (c) 2012  Genetec Corporation.  All rights reserved.
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq_uart.c,v 1.4 2022/10/26 23:38:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_uart.c,v 1.5 2022/10/27 07:57:46 skrll Exp $");
 
 #include "opt_soc.h"
 #include "opt_console.h"
@@ -1904,10 +1904,9 @@ zynquart_common_getc(dev_t dev, struct z
 
 	c = 0xff & bus_space_read_4(iot, ioh, UART_TX_RX_FIFO);
 
-	{
+	if (!db_active) {
 		int cn_trapped __unused = 0;
-		if (!db_active) {
-			cn_check_magic(dev, c, zynquart_cnm_state);
+		cn_check_magic(dev, c, zynquart_cnm_state);
 	}
 	splx(s);
 	return (c);
@@ -1923,8 +1922,8 @@ zynquart_common_putc(dev_t dev, struct z
 
 	if (!READAHEAD_IS_FULL() &&
 	!(bus_space_read_4(iot, ioh, UART_CHANNEL_STS) & STS_REMPTY)) {
+		int cn_trapped __unused = 0;
 
-		int __attribute__((__unused__))cn_trapped = 0;
 		cin = bus_space_read_4(iot, ioh, UART_TX_RX_FIFO);
 		cn_check_magic(dev, cin & 0xff, zynquart_cnm_state);
 		zynquart_readahead_in = (zynquart_readahead_in + 1) &



CVS commit: src/sys/arch/arm/xilinx

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 07:57:46 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_uart.c

Log Message:
Fix build.
Sprinkle some consistency


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/xilinx/zynq_uart.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/uvm/pmap

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 06:49:51 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
In pmap_pte_reserve ensure we're atomically swapping out an invalid entry
otherwise concurrent updates might both think they've updated the entry.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/uvm/pmap/pmap_segtab.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/pmap/pmap_segtab.c
diff -u src/sys/uvm/pmap/pmap_segtab.c:1.29 src/sys/uvm/pmap/pmap_segtab.c:1.30
--- src/sys/uvm/pmap/pmap_segtab.c:1.29	Wed Oct 26 07:35:20 2022
+++ src/sys/uvm/pmap/pmap_segtab.c	Thu Oct 27 06:49:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_segtab.c,v 1.29 2022/10/26 07:35:20 skrll Exp $	*/
+/*	$NetBSD: pmap_segtab.c,v 1.30 2022/10/27 06:49:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.29 2022/10/26 07:35:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.30 2022/10/27 06:49:51 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -1161,8 +1161,7 @@ pmap_pte_reserve(pmap_t pmap, vaddr_t va
 		pd_entry_t npde = pte_pde_ptpage(pa, pmap == pmap_kernel());
 #endif
 #if defined(PMAP_HWPAGEWALKER) && defined(PMAP_MAP_PDETABPAGE)
-		pd_entry_t opde = *pde_p;
-		opde = pte_pde_cas(pde_p, opde, npde);
+		pd_entry_t opde = pte_pde_cas(pde_p, pte_invalid_pde(), npde);
 		if (__predict_false(pte_pde_valid_p(opde))) {
 			pmap_ptpage_free(pmap, ppg, __func__);
 			ppg = pmap_pde_to_ptpage(opde);



CVS commit: src/sys/uvm/pmap

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 06:49:51 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
In pmap_pte_reserve ensure we're atomically swapping out an invalid entry
otherwise concurrent updates might both think they've updated the entry.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/uvm/pmap/pmap_segtab.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/uvm/pmap

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 06:20:41 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap.c

Log Message:
No need to hold the pmap_tlb_miss_lock when calling pmap_segtab_destroy


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/uvm/pmap/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/pmap/pmap.c
diff -u src/sys/uvm/pmap/pmap.c:1.70 src/sys/uvm/pmap/pmap.c:1.71
--- src/sys/uvm/pmap/pmap.c:1.70	Thu Oct 27 06:19:56 2022
+++ src/sys/uvm/pmap/pmap.c	Thu Oct 27 06:20:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.70 2022/10/27 06:19:56 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.71 2022/10/27 06:20:41 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.70 2022/10/27 06:19:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.71 2022/10/27 06:20:41 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -764,8 +764,8 @@ pmap_destroy(pmap_t pmap)
 	kpreempt_disable();
 	pmap_tlb_miss_lock_enter();
 	pmap_tlb_asid_release_all(pmap);
-	pmap_segtab_destroy(pmap, NULL, 0);
 	pmap_tlb_miss_lock_exit();
+	pmap_segtab_destroy(pmap, NULL, 0);
 
 	KASSERT(TAILQ_EMPTY(>pm_ppg_list));
 



CVS commit: src/sys/uvm/pmap

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 06:20:41 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap.c

Log Message:
No need to hold the pmap_tlb_miss_lock when calling pmap_segtab_destroy


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/uvm/pmap/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/uvm/pmap

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 06:19:56 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap.c pmap.h

Log Message:
Rename pm_count to pm_refcnt


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/uvm/pmap/pmap.c
cvs rdiff -u -r1.23 -r1.24 src/sys/uvm/pmap/pmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/pmap/pmap.c
diff -u src/sys/uvm/pmap/pmap.c:1.69 src/sys/uvm/pmap/pmap.c:1.70
--- src/sys/uvm/pmap/pmap.c:1.69	Wed Oct 26 07:35:20 2022
+++ src/sys/uvm/pmap/pmap.c	Thu Oct 27 06:19:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.69 2022/10/26 07:35:20 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.70 2022/10/27 06:19:56 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.69 2022/10/26 07:35:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.70 2022/10/27 06:19:56 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -223,7 +223,7 @@ pmap_segtab_t	pmap_kern_segtab PMAP_SEGT
 
 struct pmap_kernel kernel_pmap_store = {
 	.kernel_pmap = {
-		.pm_count = 1,
+		.pm_refcnt = 1,
 #ifdef PMAP_HWPAGEWALKER
 		.pm_pdetab = PMAP_INVALID_PDETAB_ADDRESS,
 #endif
@@ -707,7 +707,7 @@ pmap_create(void)
 
 	KASSERT(pmap->pm_pai[0].pai_link.le_prev == NULL);
 
-	pmap->pm_count = 1;
+	pmap->pm_refcnt = 1;
 	pmap->pm_minaddr = VM_MIN_ADDRESS;
 	pmap->pm_maxaddr = VM_MAXUSER_ADDRESS;
 
@@ -751,7 +751,7 @@ pmap_destroy(pmap_t pmap)
 	UVMHIST_CALLARGS(pmapxtabhist, "(pmap=%#jx)", (uintptr_t)pmap, 0, 0, 0);
 
 	membar_release();
-	if (atomic_dec_uint_nv(>pm_count) > 0) {
+	if (atomic_dec_uint_nv(>pm_refcnt) > 0) {
 		PMAP_COUNT(dereference);
 		UVMHIST_LOG(pmaphist, " <-- done (deref)", 0, 0, 0, 0);
 		UVMHIST_LOG(pmapxtabhist, " <-- done (deref)", 0, 0, 0, 0);
@@ -760,7 +760,7 @@ pmap_destroy(pmap_t pmap)
 	membar_acquire();
 
 	PMAP_COUNT(destroy);
-	KASSERT(pmap->pm_count == 0);
+	KASSERT(pmap->pm_refcnt == 0);
 	kpreempt_disable();
 	pmap_tlb_miss_lock_enter();
 	pmap_tlb_asid_release_all(pmap);
@@ -807,7 +807,7 @@ pmap_reference(pmap_t pmap)
 	PMAP_COUNT(reference);
 
 	if (pmap != NULL) {
-		atomic_inc_uint(>pm_count);
+		atomic_inc_uint(>pm_refcnt);
 	}
 
 	UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0);

Index: src/sys/uvm/pmap/pmap.h
diff -u src/sys/uvm/pmap/pmap.h:1.23 src/sys/uvm/pmap/pmap.h:1.24
--- src/sys/uvm/pmap/pmap.h:1.23	Thu Oct 27 05:33:37 2022
+++ src/sys/uvm/pmap/pmap.h	Thu Oct 27 06:19:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.23 2022/10/27 05:33:37 skrll Exp $	*/
+/*	$NetBSD: pmap.h,v 1.24 2022/10/27 06:19:56 skrll Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -189,7 +189,7 @@ extern kmutex_t pmap_segtab_lock;
  */
 struct pmap {
 	struct uvm_object	pm_uobject;
-#define pm_count		pm_uobject.uo_refs /* pmap reference count */
+#define pm_refcnt		pm_uobject.uo_refs /* pmap reference count */
 #define pm_pvp_list		pm_uobject.memq
 
 	krwlock_t		pm_obj_lock;	/* lock for pm_uobject */



CVS commit: src/sys/uvm/pmap

2022-10-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 27 06:19:56 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap.c pmap.h

Log Message:
Rename pm_count to pm_refcnt


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/uvm/pmap/pmap.c
cvs rdiff -u -r1.23 -r1.24 src/sys/uvm/pmap/pmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.