On 10/31/11 06:18, Andreas Bartelt wrote:
...
> I think there's still an inconsistency there. According to the
> netstat(1) man page, Table 0 is the default table. This is the behavior
> of "netstat -anf inet" with your patch applied.
>
> However, when a user/process is in rdomain 1 (i.e. via "route -T 1 exec
> su -" or logging in via sshd running in rdomain 1), "netstat -rn" shows
> the routing table of (the effectively used) rdomain 1. Although this
> differs from the man page, it's the behavior I would expect for "netstat
> -rn" -- and also for "netstat -anf inet".
>

the attached diff should implement the behavior from above.

I've further noticed that rdomains are currently not fully transparent 
to some daemons (i.e., transmission-cli). In case a daemon doesn't 
provide an option for binding to a specific interface/ip-address, it 
usually tries to bind to all available interfaces -- regardless if the 
respective interface is in the same rdomain or not...
Index: src/usr.bin/netstat//main.c
===================================================================
RCS file: /usr/cvsync/cvs/src/usr.bin/netstat/main.c,v
retrieving revision 1.90
diff -u -r1.90 main.c
--- src/usr.bin/netstat//main.c 1 Nov 2011 00:00:01 -0000       1.90
+++ src/usr.bin/netstat//main.c 1 Nov 2011 09:28:20 -0000
@@ -371,6 +371,8 @@
                intpr(interval, repeatcount);
                exit(0);
        }
+       if (!Tflag)
+               tableid = getrtable();
        if (rflag) {
                if (sflag)
                        rt_stats();
@@ -379,7 +381,7 @@
                            nl[N_AF2RTAFIDX].n_value, nl[N_RTBLIDMAX].n_value,
                            tableid);
                else
-                       p_rttables(af, tableid, Tflag);
+                       p_rttables(af, tableid);
                exit(0);
        }
        if (gflag) {
Index: src/usr.bin/netstat//netstat.1
===================================================================
RCS file: /usr/cvsync/cvs/src/usr.bin/netstat/netstat.1,v
retrieving revision 1.66
diff -u -r1.66 netstat.1
--- src/usr.bin/netstat//netstat.1      3 Sep 2011 22:59:07 -0000       1.66
+++ src/usr.bin/netstat//netstat.1      1 Nov 2011 09:36:28 -0000
@@ -273,7 +273,6 @@
 If this option is repeated, counters with a value of zero are suppressed.
 .It Fl T Ar tableid
 Select an alternate routing table to modify or query.
-Table 0 is the default table.
 .It Fl t
 With the
 .Fl i
Index: src/usr.bin/netstat//netstat.h
===================================================================
RCS file: /usr/cvsync/cvs/src/usr.bin/netstat/netstat.h,v
retrieving revision 1.61
diff -u -r1.61 netstat.h
--- src/usr.bin/netstat//netstat.h      1 Nov 2011 00:00:01 -0000       1.61
+++ src/usr.bin/netstat//netstat.h      1 Nov 2011 09:05:23 -0000
@@ -116,7 +116,7 @@
 char   *routename6(struct sockaddr_in6 *);
 char   *netname6(struct sockaddr_in6 *, struct sockaddr_in6 *);
 
-void   p_rttables(int, u_int, int);
+void   p_rttables(int, u_int);
 void   p_flags(int, char *);
 void   p_addr(struct sockaddr *, struct sockaddr *, int);
 void   p_gwaddr(struct sockaddr *, int);
Index: src/usr.bin/netstat//show.c
===================================================================
RCS file: /usr/cvsync/cvs/src/usr.bin/netstat/show.c,v
retrieving revision 1.34
diff -u -r1.34 show.c
--- src/usr.bin/netstat//show.c 11 Oct 2010 12:33:36 -0000      1.34
+++ src/usr.bin/netstat//show.c 1 Nov 2011 09:06:46 -0000
@@ -116,7 +116,7 @@
  * Print routing tables.
  */
 void
-p_rttables(int af, u_int tableid, int hastable)
+p_rttables(int af, u_int tableid)
 {
        struct rt_msghdr *rtm;
        struct sadb_msg *msg;
@@ -131,11 +131,8 @@
        mib[3] = af;
        mib[4] = NET_RT_DUMP;
        mib[5] = 0;
-       if (hastable) {
-               mib[6] = tableid;
-               mcnt = 7;
-       } else
-               mcnt = 6;
+       mib[6] = tableid;
+       mcnt = 7;
 
        if (sysctl(mib, mcnt, NULL, &needed, NULL, 0) < 0)
                err(1, "route-sysctl-estimate");

Reply via email to