`netstat -r' uses 34 columns for "Destination" and 30 for "Gateway".  As
these two columns have the same notation, these columns could also have the
same length.

30 is too short for SLAAC addresses with longer interface names:

% echo -n 'fe80::aaaa:bbbb:cccc:dddd%vether99' | wc
       0       1      34

Thus let's use 34 for both (WID_DST / WID_GW) columns.

OK?

Index: usr.bin/netstat/show.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/show.c,v
retrieving revision 1.49
diff -u -p -U15 -r1.49 show.c
--- usr.bin/netstat/show.c      11 Sep 2015 20:10:26 -0000      1.49
+++ usr.bin/netstat/show.c      14 Jun 2016 07:30:39 -0000
@@ -156,31 +156,31 @@ p_rttables(int af, u_int tableid)
                        rtm = (struct rt_msghdr *)next;
                        if (rtm->rtm_version != RTM_VERSION)
                                continue;
                        sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
                        p_rtentry(rtm);
                }
        }
        free(buf);
 }
 
 /*
  * column widths; each followed by one space
  * width of destination/gateway column
  * strlen("fe80::aaaa:bbbb:cccc:dddd@gif0") == 30, strlen("/128") == 4
  */
-#define        WID_GW(af)      ((af) == AF_INET6 ? (nflag ? 30 : 18) : 18)
+#define        WID_GW(af)      ((af) == AF_INET6 ? (nflag ? 34 : 18) : 18)
 
 int
 WID_DST(int af)
 {
 
        if (nflag)
                switch (af) {
                case AF_MPLS:
                        return 9;
                case AF_INET6:
                        return 34;
                default:
                        return 18;
                }
        else

Reply via email to