On Tue, Nov 01, 2011 at 11:13 +0100, Andreas Bartelt wrote:
> 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...
i've missed the getrtable bit, you're right. it's in now.
the rest of your diff is cleanup and doesn't change the behavior,
nevertheless lets consider it for the sake of completeness.
ok?
Index: netstat.1
===================================================================
RCS file: /cvs/src/usr.bin/netstat/netstat.1,v
retrieving revision 1.66
diff -u -p -u -p -r1.66 netstat.1
--- netstat.1 3 Sep 2011 22:59:07 -0000 1.66
+++ netstat.1 1 Nov 2011 10:32:42 -0000
@@ -272,8 +272,8 @@ option, also print routing labels.
Show per-protocol statistics.
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.
+Select an alternate routing table to query.
+Otherwise the current one is used.
.It Fl t
With the
.Fl i
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/main.c,v
retrieving revision 1.91
diff -u -p -u -p -r1.91 main.c
--- main.c 1 Nov 2011 10:14:06 -0000 1.91
+++ main.c 1 Nov 2011 10:32:42 -0000
@@ -380,7 +380,7 @@ main(int argc, char *argv[])
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: netstat.h
===================================================================
RCS file: /cvs/src/usr.bin/netstat/netstat.h,v
retrieving revision 1.61
diff -u -p -u -p -r1.61 netstat.h
--- netstat.h 1 Nov 2011 00:00:01 -0000 1.61
+++ netstat.h 1 Nov 2011 10:32:42 -0000
@@ -116,7 +116,7 @@ void mrt6_stats(void);
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: show.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/show.c,v
retrieving revision 1.34
diff -u -p -u -p -r1.34 show.c
--- show.c 11 Oct 2010 12:33:36 -0000 1.34
+++ show.c 1 Nov 2011 10:32:42 -0000
@@ -116,7 +116,7 @@ void index_pfk(struct sadb_msg *, void
* 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 @@ p_rttables(int af, u_int tableid, int ha
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");