Source-Changes-D archive

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

Re: CVS commit: src/usr.bin/netstat



hi,

(04/25/14 04:02), Christos Zoulas wrote:> In article 
<20140424191900.GP20347%snowdrop.l8s.co.uk@localhost>,
David Laight  <david%l8s.co.uk@localhost> wrote:
On Thu, Apr 24, 2014 at 10:56:29AM -0400, Christos Zoulas wrote:
Module Name:    src
Committed By:   christos
Date:           Thu Apr 24 14:56:29 UTC 2014

Modified Files:
        src/usr.bin/netstat: main.c route.c

Log Message:
The sysctl code does not support verbose route printing that prints the
internal route statistics. Restore the old kmem route printing code that
was not just used for post-mortem displays. Reported by kardel@, test by
netstat -nrvf inet

That seems a large backwards step...

No, the sysctl code is still used in the same cases as before. It
is only for the parts that are not supported by the sysctl code
that fail back to the kmem code (where the functionality was lost
when the code was deleted).

Are you guys interested in use_sysctl version of netstat -nrv code?
I think that's useful if kmem is not available.

Both struct rtentry from kmem and struct rt_msghdr from sysctl
has struct rt_metrics.  This code splits printing rt_metrics
and allows call from both paths.
To check both paths, try netstat -nrv -X and netstat -nrv -g.
(side effect of -g causes use_sysctl=0)

Index: src/usr.bin/netstat/main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/netstat/main.c,v
retrieving revision 1.89
diff -u -p -r1.89 main.c
--- src/usr.bin/netstat/main.c    24 Apr 2014 14:56:29 -0000    1.89
+++ src/usr.bin/netstat/main.c    25 Apr 2014 20:19:28 -0000
@@ -356,7 +356,6 @@ prepare(const char *nf, const char *mf,
 #ifndef SMALL
            gflag ||
 #endif
-           (rflag && vflag) ||
            (pflag && tp->pr_sindex == N_PIMSTAT) ||
            Pflag) {
         /* These flags are not yet supported via sysctl(3). */
Index: src/usr.bin/netstat/netstat.h
===================================================================
RCS file: /cvsroot/src/usr.bin/netstat/netstat.h,v
retrieving revision 1.49
diff -u -p -r1.49 netstat.h
--- src/usr.bin/netstat/netstat.h    24 Apr 2014 14:54:51 -0000    1.49
+++ src/usr.bin/netstat/netstat.h    25 Apr 2014 20:19:28 -0000
@@ -116,6 +116,8 @@ void    impstats(u_long, u_long);
void pr_rthdr(int, int);
 void    pr_family(int);
+struct rt_metrics;
+void    pr_rtrmx(struct rt_metrics *);
 void    rt_stats(u_long);
 char    *ns_phost(struct sockaddr *);
Index: src/usr.bin/netstat/route.c
===================================================================
RCS file: /cvsroot/src/usr.bin/netstat/route.c,v
retrieving revision 1.81
diff -u -p -r1.81 route.c
--- src/usr.bin/netstat/route.c    24 Apr 2014 14:56:29 -0000    1.81
+++ src/usr.bin/netstat/route.c    25 Apr 2014 20:19:28 -0000
@@ -286,27 +286,36 @@ p_krtentry(struct rtentry *rt)
             rt->rt_nodes[0].rn_dupedkey ? " =>" : "");
     }
     putchar('\n');
-     if (vflag) {
-         printf("\texpire   %10"PRId64"%c  recvpipe %10"PRIu64"%c  "
-               "sendpipe %10"PRIu64"%c\n",
-             (int64_t)rt->rt_rmx.rmx_expire,
-             (rt->rt_rmx.rmx_locks & RTV_EXPIRE) ? 'L' : ' ',
-             rt->rt_rmx.rmx_recvpipe,
-             (rt->rt_rmx.rmx_locks & RTV_RPIPE) ? 'L' : ' ',
-             rt->rt_rmx.rmx_sendpipe,
-             (rt->rt_rmx.rmx_locks & RTV_SPIPE) ? 'L' : ' ');
-         printf("\tssthresh %10"PRIu64"%c  rtt      %10"PRIu64"%c  "
-               "rttvar   %10"PRIu64"%c\n",
-             rt->rt_rmx.rmx_ssthresh,
-             (rt->rt_rmx.rmx_locks & RTV_SSTHRESH) ? 'L' : ' ',
-             rt->rt_rmx.rmx_rtt,
-             (rt->rt_rmx.rmx_locks & RTV_RTT) ? 'L' : ' ',
-             rt->rt_rmx.rmx_rttvar,
-            (rt->rt_rmx.rmx_locks & RTV_RTTVAR) ? 'L' : ' ');
-         printf("\thopcount %10"PRIu64"%c\n",
-             rt->rt_rmx.rmx_hopcount,
-            (rt->rt_rmx.rmx_locks & RTV_HOPCOUNT) ? 'L' : ' ');
-     }
+    if (vflag) {
+        pr_rtrmx(&rt->rt_rmx);
+    }
+}
+
+void
+pr_rtrmx(struct rt_metrics *rmx)
+{
+    if (rmx == NULL)
+        return;
+
+    printf("\texpire   %10"PRId64"%c  recvpipe %10"PRIu64"%c  "
+           "sendpipe %10"PRIu64"%c\n",
+        (int64_t)rmx->rmx_expire,
+        (rmx->rmx_locks & RTV_EXPIRE) ? 'L' : ' ',
+        rmx->rmx_recvpipe,
+        (rmx->rmx_locks & RTV_RPIPE) ? 'L' : ' ',
+        rmx->rmx_sendpipe,
+        (rmx->rmx_locks & RTV_SPIPE) ? 'L' : ' ');
+    printf("\tssthresh %10"PRIu64"%c  rtt      %10"PRIu64"%c  "
+           "rttvar   %10"PRIu64"%c\n",
+        rmx->rmx_ssthresh,
+        (rmx->rmx_locks & RTV_SSTHRESH) ? 'L' : ' ',
+        rmx->rmx_rtt,
+        (rmx->rmx_locks & RTV_RTT) ? 'L' : ' ',
+        rmx->rmx_rttvar,
+        (rmx->rmx_locks & RTV_RTTVAR) ? 'L' : ' ');
+    printf("\thopcount %10"PRIu64"%c\n",
+        rmx->rmx_hopcount,
+        (rmx->rmx_locks & RTV_HOPCOUNT) ? 'L' : ' ');
 }
/*
Index: src/usr.bin/netstat/show.c
===================================================================
RCS file: /cvsroot/src/usr.bin/netstat/show.c,v
retrieving revision 1.18
diff -u -p -r1.18 show.c
--- src/usr.bin/netstat/show.c    19 Oct 2013 15:56:06 -0000    1.18
+++ src/usr.bin/netstat/show.c    25 Apr 2014 20:19:28 -0000
@@ -273,6 +276,9 @@ p_rtentry(struct rt_msghdr *rtm)
         p_tag(rti_info[RTAX_TAG]);
     printf(" %.16s", if_indextoname(rtm->rtm_index, ifbuf));
     putchar('\n');
+    if (vflag) {
+        pr_rtrmx(&rtm->rtm_rmx);
+    }
 }
/*


--
t-hash


Home | Main Index | Thread Index | Old Index