diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index ac60673beeaf..0190d5acc704 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -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, 1993\ #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 *sock, int i) 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 *sock, int i) case IPPROTO_TCP: if (so.so_pcb == NULL) break; - if (kvm_read(kd, (u_long)so.so_pcb, (char *)&in6pcb, - sizeof(in6pcb)) != sizeof(in6pcb)) { - dprintf("can't read in6pcb at %p", so.so_pcb); + if (kvm_read(kd, (u_long)so.so_pcb, (char *)&inpcb, + sizeof(inpcb)) != sizeof(inpcb)) { + dprintf("can't read inpcb at %p", so.so_pcb); goto bad; } - inet6_addrstr(lbuf, sizeof(lbuf), &in6pcb.in6p_laddr, - ntohs(in6pcb.in6p_lport), isdgram); - inet6_addrstr(fbuf, sizeof(fbuf), &in6pcb.in6p_faddr, - ntohs(in6pcb.in6p_fport), isdgram); + inet6_addrstr(lbuf, sizeof(lbuf), &inpcb.inp_laddr6, + ntohs(inpcb.inp_lport), isdgram); + inet6_addrstr(fbuf, sizeof(fbuf), &inpcb.inp_faddr6, + ntohs(inpcb.inp_fport), isdgram); break; default: break; diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 4b0c79b96d8a..ad72bed94993 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -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_long pcbaddr) 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); diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index c36a21d03283..6ed794a3a17e 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -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 tcp6cb; #else @@ -287,7 +287,7 @@ getpcblist_kmem(u_long off, const char *name, size_t *len) { struct socket sockb; struct inpcbtable table; - struct inpcb_hdr *next, *prev; + struct inpcb *next, *prev; int istcp = strcmp(name, "tcp6") == 0; struct kinfo_pcb *pcblist; size_t size = 100, i; @@ -309,33 +309,33 @@ getpcblist_kmem(u_long off, const char *name, size_t *len) i = 0; while (next != TAILQ_END(head)) { - kread((u_long)next, (char *)&in6pcb, sizeof in6pcb); - next = TAILQ_NEXT(&in6pcb, in6p_queue); + kread((u_long)next, (char *)&inpcb, sizeof inpcb); + next = TAILQ_NEXT(&inpcb, inp_queue); prev = next; - if (in6pcb.in6p_af != AF_INET6) + if (inpcb.inp_af != AF_INET6) continue; - kread((u_long)in6pcb.in6p_socket, (char *)&sockb, + kread((u_long)inpcb.inp_socket, (char *)&sockb, sizeof (sockb)); if (istcp) { #ifdef TCP6 - kread((u_long)in6pcb.in6p_ppcb, + kread((u_long)inpcb.inp_ppcb, (char *)&tcp6cb, sizeof (tcp6cb)); #else - kread((u_long)in6pcb.in6p_ppcb, + kread((u_long)inpcb.inp_ppcb, (char *)&tcpcb, sizeof (tcpcb)); #endif } pcblist[i].ki_ppcbaddr = - istcp ? (uintptr_t) in6pcb.in6p_ppcb : (uintptr_t) prev; + istcp ? (uintptr_t) inpcb.inp_ppcb : (uintptr_t) prev; pcblist[i].ki_rcvq = (uint64_t)sockb.so_rcv.sb_cc; pcblist[i].ki_sndq = (uint64_t)sockb.so_snd.sb_cc; - sin6.sin6_addr = in6pcb.in6p_laddr; - sin6.sin6_port = in6pcb.in6p_lport; + sin6.sin6_addr = inpcb.inp_laddr6; + sin6.sin6_port = inpcb.inp_lport; memcpy(&pcblist[i].ki_s, &sin6, sizeof(sin6)); - sin6.sin6_addr = in6pcb.in6p_faddr; - sin6.sin6_port = in6pcb.in6p_fport; + sin6.sin6_addr = inpcb.inp_faddr6; + sin6.sin6_port = inpcb.inp_fport; memcpy(&pcblist[i].ki_d, &sin6, sizeof(sin6)); pcblist[i].ki_tstate = tcpcb.t_state; if (i++ == size) { @@ -1431,7 +1431,7 @@ inet6print(const struct in6_addr *in6, int port, const char *proto) */ char * -inet6name(const struct in6_addr *in6p) +inet6name(const struct in6_addr *inp) { char *cp; static char line[NI_MAXHOST]; @@ -1451,8 +1451,8 @@ inet6name(const struct in6_addr *in6p) domain[0] = 0; } cp = 0; - if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { - hp = gethostbyaddr((const char *)in6p, sizeof(*in6p), AF_INET6); + if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(inp)) { + hp = gethostbyaddr((const char *)inp, sizeof(*inp), AF_INET6); if (hp) { if ((cp = strchr(hp->h_name, '.')) && !strcmp(cp + 1, domain)) @@ -1460,7 +1460,7 @@ inet6name(const struct in6_addr *in6p) cp = hp->h_name; } } - if (IN6_IS_ADDR_UNSPECIFIED(in6p)) + if (IN6_IS_ADDR_UNSPECIFIED(inp)) strlcpy(line, "*", sizeof(line)); else if (cp) strlcpy(line, cp, sizeof(line)); @@ -1468,7 +1468,7 @@ inet6name(const struct in6_addr *in6p) memset(&sin6, 0, sizeof(sin6)); sin6.sin6_len = sizeof(sin6); sin6.sin6_family = AF_INET6; - sin6.sin6_addr = *in6p; + sin6.sin6_addr = *inp; inet6_getscopeid(&sin6, INET6_IS_ADDR_LINKLOCAL | INET6_IS_ADDR_MC_LINKLOCAL); if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len, @@ -1529,8 +1529,8 @@ tcp6_dump(u_long off, const char *name, u_long pcbaddr) printf("State: %d", mypcb.t_state); else printf("State: %s", tcp6states[mypcb.t_state]); - printf(", flags 0x%x, in6pcb 0x%lx\n\n", mypcb.t_flags, - (u_long)mypcb.t_in6pcb); + printf(", flags 0x%x, inpcb 0x%lx\n\n", mypcb.t_flags, + (u_long)mypcb.t_inpcb); printf("rxtshift %d, rxtcur %d, dupacks %d\n", mypcb.t_rxtshift, mypcb.t_rxtcur, mypcb.t_dupacks); diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index b6dd75f097a3..c68d04237ba7 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -1,4 +1,4 @@ -/* $NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $ */ +/* $NetBSD: sockstat.c,v 1.25 2022/10/28 05:24:07 ozaki-r Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $"); +__RCSID("$NetBSD: sockstat.c,v 1.25 2022/10/28 05:24:07 ozaki-r Exp $"); #endif #define _KMEMUSER @@ -47,7 +47,6 @@ __RCSID("$NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $"); #include #include #include -#include #include #define _KMEMUSER diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h index 2ccdcc9cc168..8529ba42ce1f 100644 --- a/usr.bin/systat/extern.h +++ b/usr.bin/systat/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.48 2021/08/21 13:22:19 christos Exp $ */ +/* $NetBSD: extern.h,v 1.49 2022/10/28 05:24:08 ozaki-r Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -67,15 +67,11 @@ extern double etime; extern bool showzero; struct inpcb; -#ifdef INET6 -struct in6pcb; -#endif int checkhost(struct inpcb *); int checkport(struct inpcb *); #ifdef INET6 -int checkhost6(struct in6pcb *); -int checkport6(struct in6pcb *); +int checkhost6(struct inpcb *); #endif void closebufcache(WINDOW *); void closedf(WINDOW *); diff --git a/usr.bin/systat/netcmds.c b/usr.bin/systat/netcmds.c index 123c2381f273..baccca50069d 100644 --- a/usr.bin/systat/netcmds.c +++ b/usr.bin/systat/netcmds.c @@ -1,4 +1,4 @@ -/* $NetBSD: netcmds.c,v 1.22 2021/10/30 11:31:51 nia Exp $ */ +/* $NetBSD: netcmds.c,v 1.23 2022/10/28 05:24:08 ozaki-r Exp $ */ /*- * Copyright (c) 1980, 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: netcmds.c,v 1.22 2021/10/30 11:31:51 nia Exp $"); +__RCSID("$NetBSD: netcmds.c,v 1.23 2022/10/28 05:24:08 ozaki-r Exp $"); #endif /* not lint */ /* @@ -245,20 +245,6 @@ checkport(struct inpcb *inp) return (1); } -#ifdef INET6 -int -checkport6(struct in6pcb *in6p) -{ - struct pitem *p; - - if (ports) - for (p = ports; p < ports+nports; p++) - if (p->port == in6p->in6p_lport || p->port == in6p->in6p_fport) - return (p->onoff); - return (1); -} -#endif - static void showports(void) { @@ -354,7 +340,7 @@ checkhost(struct inpcb *inp) #ifdef INET6 int -checkhost6(struct in6pcb *in6p) +checkhost6(struct inpcb *inp) { struct hitem *p; struct sockaddr_in6 *sin6; @@ -364,8 +350,8 @@ checkhost6(struct in6pcb *in6p) if (((struct sockaddr *)&p->addr)->sa_family != AF_INET6) continue; sin6 = (struct sockaddr_in6 *)&p->addr; - if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &in6p->in6p_laddr) || - IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &in6p->in6p_faddr)) + if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &inp->inp_laddr6) || + IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &inp->inp_faddr6)) return (p->onoff); } return (1); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index d908dabb7935..b02692430e48 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -1,4 +1,4 @@ -/* $NetBSD: netstat.c,v 1.30 2018/05/03 07:13:48 maxv Exp $ */ +/* $NetBSD: netstat.c,v 1.31 2022/10/28 05:24:08 ozaki-r Exp $ */ /*- * Copyright (c) 1980, 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: netstat.c,v 1.30 2018/05/03 07:13:48 maxv Exp $"); +__RCSID("$NetBSD: netstat.c,v 1.31 2022/10/28 05:24:08 ozaki-r Exp $"); #endif /* not lint */ /* @@ -83,7 +83,7 @@ static const char *inetname(struct in_addr); static void inetprint(struct in_addr *, int, const char *); #ifdef INET6 static void fetchnetstat6(void *, int); -static void enter6(struct in6pcb *, struct socket *, int, const char *); +static void enter6(struct inpcb *, struct socket *, int, const char *); static const char *inet6name(struct in6_addr *); static void inet6print(struct in6_addr *, int, const char *); #endif @@ -213,7 +213,7 @@ static void fetchnetstat4(void *off, int istcp) { struct inpcbtable pcbtable; - struct inpcb_hdr **pprev, *next; + struct inpcb **pprev, *next; struct netinfo *p; struct inpcb inpcb, *inpcbp; struct socket sockb; @@ -231,7 +231,7 @@ fetchnetstat4(void *off, int istcp) error("Kernel state in transition"); return; } - pprev = &next->inph_queue.tqe_next; + pprev = &next->inp_queue.tqe_next; next = inpcb.inp_queue.tqe_next; if (inpcb.inp_af != AF_INET) @@ -256,41 +256,41 @@ static void fetchnetstat6(void *off, int istcp) { struct inpcbtable pcbtable; - struct inpcb_hdr **pprev, *next; + struct inpcb **pprev, *next; struct netinfo *p; struct socket sockb; struct tcpcb tcpcb; - struct in6pcb in6pcb, *in6pcbp; + struct inpcb inpcb, *inpcbp; KREAD(off, &pcbtable, sizeof pcbtable); pprev = &((struct inpcbtable *)off)->inpt_queue.tqh_first; next = TAILQ_FIRST(&pcbtable.inpt_queue); while (next != TAILQ_END(&pcbtable.inpt_queue)) { - in6pcbp = (struct in6pcb *)next; - KREAD(in6pcbp, &in6pcb, sizeof (in6pcb)); - if (in6pcb.in6p_queue.tqe_prev != pprev) { + inpcbp = (struct inpcb *)next; + KREAD(inpcbp, &inpcb, sizeof (inpcb)); + if (inpcb.inp_queue.tqe_prev != pprev) { for (p = netcb.ni_forw; p != nhead; p = p->ni_forw) p->ni_seen = 1; error("Kernel state in transition"); return; } - pprev = &next->inph_queue.tqe_next; - next = in6pcb.in6p_queue.tqe_next; + pprev = &next->inp_queue.tqe_next; + next = inpcb.inp_queue.tqe_next; - if (in6pcb.in6p_af != AF_INET6) + if (inpcb.inp_af != AF_INET6) continue; - if (!aflag && IN6_IS_ADDR_UNSPECIFIED(&in6pcb.in6p_laddr)) + if (!aflag && IN6_IS_ADDR_UNSPECIFIED(&inpcb.inp_laddr6)) continue; - if (nhosts && !checkhost6(&in6pcb)) + if (nhosts && !checkhost(&inpcb)) continue; - if (nports && !checkport6(&in6pcb)) + if (nports && !checkport(&inpcb)) continue; - KREAD(in6pcb.in6p_socket, &sockb, sizeof (sockb)); + KREAD(inpcb.inp_socket, &sockb, sizeof (sockb)); if (istcp) { - KREAD(in6pcb.in6p_ppcb, &tcpcb, sizeof (tcpcb)); - enter6(&in6pcb, &sockb, tcpcb.t_state, "tcp"); + KREAD(inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb)); + enter6(&inpcb, &sockb, tcpcb.t_state, "tcp"); } else - enter6(&in6pcb, &sockb, 0, "udp"); + enter6(&inpcb, &sockb, 0, "udp"); } } #endif /*INET6*/ @@ -345,7 +345,7 @@ enter(struct inpcb *inp, struct socket *so, int state, const char *proto) #ifdef INET6 static void -enter6(struct in6pcb *in6p, struct socket *so, int state, const char *proto) +enter6(struct inpcb *inp, struct socket *so, int state, const char *proto) { struct netinfo *p; @@ -361,11 +361,11 @@ enter6(struct in6pcb *in6p, struct socket *so, int state, const char *proto) continue; if (!streq(proto, p->ni_proto)) continue; - if (p->ni_lport != in6p->in6p_lport || - !IN6_ARE_ADDR_EQUAL(&p->ni_laddr6, &in6p->in6p_laddr)) + if (p->ni_lport != inp->inp_lport || + !IN6_ARE_ADDR_EQUAL(&p->ni_laddr6, &inp->inp_laddr6)) continue; - if (IN6_ARE_ADDR_EQUAL(&p->ni_faddr6, &in6p->in6p_faddr) && - p->ni_fport == in6p->in6p_fport) + if (IN6_ARE_ADDR_EQUAL(&p->ni_faddr6, &inp->inp_faddr6) && + p->ni_fport == inp->inp_fport) break; } if (p == nhead) { @@ -378,10 +378,10 @@ enter6(struct in6pcb *in6p, struct socket *so, int state, const char *proto) netcb.ni_forw->ni_prev = p; netcb.ni_forw = p; p->ni_line = -1; - p->ni_laddr6 = in6p->in6p_laddr; - p->ni_lport = in6p->in6p_lport; - p->ni_faddr6 = in6p->in6p_faddr; - p->ni_fport = in6p->in6p_fport; + p->ni_laddr6 = inp->inp_laddr6; + p->ni_lport = inp->inp_lport; + p->ni_faddr6 = inp->inp_faddr6; + p->ni_fport = inp->inp_fport; p->ni_proto = proto; p->ni_flags = NIF_LACHG | NIF_FACHG; p->ni_family = AF_INET6;