Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin Adjust userland commands for struct inpcb integration



details:   https://anonhg.NetBSD.org/src/rev/841f5a43a67d
branches:  trunk
changeset: 372131:841f5a43a67d
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Oct 28 05:24:07 2022 +0000

description:
Adjust userland commands for struct inpcb integration

Only kvm users are affected.

diffstat:

 usr.bin/fstat/fstat.c       |  21 ++++++---------
 usr.bin/netstat/inet.c      |  10 +++---
 usr.bin/netstat/inet6.c     |  44 +++++++++++++++++-----------------
 usr.bin/sockstat/sockstat.c |   5 +--
 usr.bin/systat/extern.h     |   8 +----
 usr.bin/systat/netcmds.c    |  24 +++--------------
 usr.bin/systat/netstat.c    |  58 ++++++++++++++++++++++----------------------
 7 files changed, 74 insertions(+), 96 deletions(-)

diffs (truncated from 472 to 300 lines):

diff -r 2cd7e680f4f7 -r 841f5a43a67d usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c     Fri Oct 28 05:23:09 2022 +0000
+++ b/usr.bin/fstat/fstat.c     Fri Oct 28 05:24:07 2022 +0000
@@ -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 @@
 #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 @@
        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 @@
                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 -r 2cd7e680f4f7 -r 841f5a43a67d usr.bin/netstat/inet.c
--- a/usr.bin/netstat/inet.c    Fri Oct 28 05:23:09 2022 +0000
+++ b/usr.bin/netstat/inet.c    Fri Oct 28 05:24:07 2022 +0000
@@ -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 @@
 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 @@
                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 -r 2cd7e680f4f7 -r 841f5a43a67d usr.bin/netstat/inet6.c
--- a/usr.bin/netstat/inet6.c   Fri Oct 28 05:23:09 2022 +0000
+++ b/usr.bin/netstat/inet6.c   Fri Oct 28 05:24:07 2022 +0000
@@ -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 @@
 
 #ifdef INET6
 
-struct in6pcb in6pcb;
+struct inpcb inpcb;
 #ifdef TCP6
 struct tcp6cb tcp6cb;
 #else
@@ -287,7 +287,7 @@
 {
        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 @@
 
        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 @@
  */
 
 char *
-inet6name(const struct in6_addr *in6p)
+inet6name(const struct in6_addr *inp)
 {
        char *cp;
        static char line[NI_MAXHOST];
@@ -1451,8 +1451,8 @@
                        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 @@
                        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 @@
                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 @@
                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 -r 2cd7e680f4f7 -r 841f5a43a67d usr.bin/sockstat/sockstat.c
--- a/usr.bin/sockstat/sockstat.c       Fri Oct 28 05:23:09 2022 +0000
+++ b/usr.bin/sockstat/sockstat.c       Fri Oct 28 05:24:07 2022 +0000
@@ -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 <sys/cdefs.h>
 #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 @@
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <netinet/in_pcb.h>
-#include <netinet/in_pcb_hdr.h>
 #include <netinet/tcp_fsm.h>
 
 #define _KMEMUSER
diff -r 2cd7e680f4f7 -r 841f5a43a67d usr.bin/systat/extern.h
--- a/usr.bin/systat/extern.h   Fri Oct 28 05:23:09 2022 +0000
+++ b/usr.bin/systat/extern.h   Fri Oct 28 05:24:07 2022 +0000
@@ -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 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 -r 2cd7e680f4f7 -r 841f5a43a67d usr.bin/systat/netcmds.c
--- a/usr.bin/systat/netcmds.c  Fri Oct 28 05:23:09 2022 +0000
+++ b/usr.bin/systat/netcmds.c  Fri Oct 28 05:24:07 2022 +0000
@@ -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 @@
        return (1);
 }
 
-#ifdef INET6
-int
-checkport6(struct in6pcb *in6p)
-{
-       struct pitem *p;
-
-       if (ports)



Home | Main Index | Thread Index | Old Index