From fb917262103f199fe26ffa8c8ea0cff8b6df1e31 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 14 Jan 1996 23:42:19 +0000 Subject: A couple of changes of mine that I've been using for a while: route.c: look up the netname as-is first before the shifted name. this makes a big speed difference, as the lookups are generally local DNS. The shifted names can be very wrong (there is still guessing and fudging involved) and usually go remote, taking a long time to fail. If you have the RFC reccomended netnames in your reverse lookups, this is even faster still. main.c: dont do a sethostent(1) - this is causing the resolver to use a VC (tcp) connection to the resolver, which has more overheads and is slower than the default UDP case. This once made sense when everything was based on text host tables. --- usr.bin/netstat/main.c | 8 ++++++++ usr.bin/netstat/route.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'usr.bin/netstat') diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index ed02642..d51489a 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -364,12 +364,20 @@ main(argc, argv) printf("%s: no stats routine\n", tp->pr_name); exit(0); } +#if 0 /* * Keep file descriptors open to avoid overhead * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); +#else + /* + * This does not make sense any more with DNS being default over + * the files. Doing a setXXXXent(1) causes a tcp connection to be + * used for the queries, which is slower. + */ +#endif if (iflag) { intpr(interval, nl[N_IFNET].n_value); exit(0); diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 82b4eff..0f9d1a5 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -36,7 +36,7 @@ static char sccsid[] = "From: @(#)route.c 8.6 (Berkeley) 4/28/95"; #endif static const char rcsid[] = - "$Id: route.c,v 1.8 1995/12/05 07:29:15 julian Exp $"; + "$Id: route.c,v 1.9 1996/01/14 23:33:13 peter Exp $"; #endif /* not lint */ #include @@ -662,8 +662,8 @@ netname(in, mask) net = i & mask; while ((mask & 1) == 0) mask >>= 1, net >>= 1; - if (!(np = getnetbyaddr(net, AF_INET))) - np = getnetbyaddr(i, AF_INET); + if (!(np = getnetbyaddr(i, AF_INET))) + np = getnetbyaddr(net, AF_INET); if (np) cp = np->n_name; } -- cgit v1.1