Bug 27280

Summary: netstat -rn prints "kvm_read: Bad Address"
Product: Base System Reporter: kar_alerts <kar_alerts>
Component: i386Assignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   

Description kar_alerts 2001-05-12 10:20:00 UTC
when i give "netstat -rn", the system prints:

inet4 section:

*** -- message start -- ****
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use     Netif Expire
default            161.142.113.3      UGSc       54      993     tun0
127.0.0.1          127.0.0.1          UH          0      947      lo0
161.142.113.3      202.187.194.33     UH         52        0     tun0
192.168            link#1             UC          0        0      xl0 =>
netstat: kvm_read: Bad address
192.168.0.1        0:50:4:d2:ec:5     UHLW        2      918      lo0
netstat: kvm_read: Bad address
192.168.0.101      0:10:a4:e8:45:3    UHLW        5   521930      xl0    999
netstat: kvm_read: Bad address
192.168.0.102      0:0:b4:85:a2:f6    UHLW        0     1481      xl0    610
netstat: kvm_read: Bad address
192.168.0.201      0:0:b4:9d:5:4a     UHLW        1     1473      xl0    465
netstat: kvm_read: Bad address
192.168.0.202      0:50:4:b8:16:f3    UHLW        1  2015523      xl0     55
netstat: kvm_read: Bad address
192.168.0.255      ff:ff:ff:ff:ff:ff  UHLWb       2       39      xl0          

*** -- message end -- ****

please note the message "netstat: kvm_read: Bad address" in the above output.

Fix: 

don't know
How-To-Repeat: type netstat -rn
Comment 1 Peter Pentchev 2001-05-12 10:34:14 UTC
On Sat, May 12, 2001 at 02:15:43AM -0700, kar_alerts@mglorysb.com wrote:
> 
> >Number:         27280
> >Category:       i386
> >Synopsis:       netstat -rn prints "kvm_read: Bad Address"
> >Originator:     Karthik
> >Release:        4.3-STABLE
> >Organization:
> MGSB
> >Environment:
> FreeBSD svr.mgsb.domain 4.3-STABLE FreeBSD 4.3-STABLE #0: Fri May 11 22:41:02 GM
> T 2001     root@svr.mgsb.domain:/usr/src/sys/compile/SVRFW  i386
> >Description:
> when i give "netstat -rn", the system prints:
> 
> inet4 section:
> 
> *** -- message start -- ****
> Routing tables
> 
> Internet:
> Destination        Gateway            Flags     Refs     Use     Netif Expire
> default            161.142.113.3      UGSc       54      993     tun0
> 127.0.0.1          127.0.0.1          UH          0      947      lo0
> 161.142.113.3      202.187.194.33     UH         52        0     tun0
> 192.168            link#1             UC          0        0      xl0 =>
> netstat: kvm_read: Bad address
> 192.168.0.1        0:50:4:d2:ec:5     UHLW        2      918      lo0
> netstat: kvm_read: Bad address
> 192.168.0.101      0:10:a4:e8:45:3    UHLW        5   521930      xl0    999
> netstat: kvm_read: Bad address
> 192.168.0.102      0:0:b4:85:a2:f6    UHLW        0     1481      xl0    610
> netstat: kvm_read: Bad address
> 192.168.0.201      0:0:b4:9d:5:4a     UHLW        1     1473      xl0    465
> netstat: kvm_read: Bad address
> 192.168.0.202      0:50:4:b8:16:f3    UHLW        1  2015523      xl0     55
> netstat: kvm_read: Bad address
> 192.168.0.255      ff:ff:ff:ff:ff:ff  UHLWb       2       39      xl0          
> 
> *** -- message end -- ****
> 
> please note the message "netstat: kvm_read: Bad address" in the above output.

Confirmed here, on a 4.3-STABLE system rebuilt yesterday.

Can you try the attached patch and see if it helps?

G'luck,
Peter

-- 
I've heard that this sentence is a rumor.

Index: src/usr.bin/netstat/route.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/netstat/route.c,v
retrieving revision 1.41.2.6
diff -u -r1.41.2.6 route.c
--- src/usr.bin/netstat/route.c	2001/05/10 08:26:46	1.41.2.6
+++ src/usr.bin/netstat/route.c	2001/05/12 09:33:20
@@ -591,7 +591,7 @@
 	/*
 	 * Don't print protocol-cloned routes unless -a.
 	 */
-	if (rt->rt_flags & RTF_WASCLONED && !aflag) {
+	if (rt->rt_flags & RTF_WASCLONED && rt->rt_parent != NULL && !aflag) {
 		kget(rt->rt_parent, parent);
 		if (parent.rt_flags & RTF_PRCLONING)
 			return;
Comment 2 Peter Pentchev freebsd_committer freebsd_triage 2001-05-12 11:39:29 UTC
Responsible Changed
From-To: freebsd-bugs->ru

Ruslan touched this part of the code in his last route cloning handling commit. 
Apparently, there are cases when a route is marked as cloned, yet has no parent 
set.  The originator reported (in a mail CC'd to -bugs, not GNATS) that 
the patch in the audit trail solved his problem (as it did mine).
Comment 3 Peter Pentchev 2001-05-12 11:42:22 UTC
Just for the record, let GNATS have this, too.

G'luck,
Peter

-- 
This inert sentence is my body, but my soul is alive, dancing in the sparks of your brain.

----- Forwarded message from K Karthik <kar_alerts@mglorysb.com> -----

From: K Karthik <kar_alerts@mglorysb.com>
Reply-To: kar_alerts@mglorysb.com
To: Peter Pentchev <roam@orbitel.bg>
Subject: Re: i386/27280: netstat -rn prints "kvm_read: Bad Address"
Date: Sat, 12 May 2001 17:56:38 +0000
Cc: freebsd-bugs@FreeBSD.ORG

Patch worked well. Problem SOLVED.

Thank you very much.
Comment 4 sgreear 2001-05-13 18:28:04 UTC
Tested, works.
Comment 5 ru freebsd_committer freebsd_triage 2001-05-14 09:24:23 UTC
State Changed
From-To: open->closed

Fixed in sys/net/route.c,v 1.59.2.2.
Comment 6 Peter Pentchev 2001-05-14 15:59:50 UTC
On Mon, May 14, 2001 at 11:27:36AM +0300, Ruslan Ermilov wrote:
[snip]
> Fixed now, I didn't realize I have uncommitted code running on my -STABLE box.

Yes, netstat -r works just fine now on RELENG_4 for me, even without
the patch in the audit trail.  Thanks!

Now I guess it's up to the PR originator to confirm netstat works
fine for him, too :)

G'luck,
Peter

-- 
If there were no counterfactuals, this sentence would not have been paradoxical.