diff mbox

iproute: "ip mroute show" doesn't show all output interfaces

Message ID 20091123095231.GA14210@amd64.fatal.se
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Andreas Henriksson Nov. 23, 2009, 9:52 a.m. UTC
From: Mark Borst <mark@borst.org>

The command "ip mroute show" will only show the first Oif. 

mark@flappie:~$ ip mroute show
(192.168.1.1, 224.0.0.123)       Iif: _rename    Oifs: eth1 

mark@flappie:~$ cat /proc/net/ip_mr_cache 
Group    Origin   Iif     Pkts    Bytes    Wrong Oifs
7B0000E0 0101A8C0 2          0        0        0  0:1    1:1  

This shows 2 Oifs here. However, ipmroute.c, function read_mroute_list(), uses sscanf() with a %s mask for oiflist, which stops after the first whitespace (i.e. after Oif 0:1). The patch below fixes this to read until the newline (though I'm not sure whether this is the proper way to fix it).

After this patch:
mark@flappie:~/iproute-20090324/ip$ ./ip mroute show
(192.168.1.1, 224.0.0.123)       Iif: _rename    Oifs: eth1 eth0 


This patch originally submitted as http://bugs.debian.org/550097

Signed-off-by: Andreas Henriksson <andreas@fatal.se>

the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

stephen hemminger Dec. 2, 2009, 12:16 a.m. UTC | #1
On Mon, 23 Nov 2009 10:52:31 +0100
Andreas Henriksson <andreas@fatal.se> wrote:

> From: Mark Borst <mark@borst.org>
> 
> The command "ip mroute show" will only show the first Oif. 
> 
> mark@flappie:~$ ip mroute show
> (192.168.1.1, 224.0.0.123)       Iif: _rename    Oifs: eth1 
> 
> mark@flappie:~$ cat /proc/net/ip_mr_cache 
> Group    Origin   Iif     Pkts    Bytes    Wrong Oifs
> 7B0000E0 0101A8C0 2          0        0        0  0:1    1:1  
> 
> This shows 2 Oifs here. However, ipmroute.c, function read_mroute_list(), uses sscanf() with a %s mask for oiflist, which stops after the first whitespace (i.e. after Oif 0:1). The patch below fixes this to read until the newline (though I'm not sure whether this is the proper way to fix it).
> 
> After this patch:
> mark@flappie:~/iproute-20090324/ip$ ./ip mroute show
> (192.168.1.1, 224.0.0.123)       Iif: _rename    Oifs: eth1 eth0 
> 
> 
> This patch originally submitted as http://bugs.debian.org/550097
> 
> Signed-off-by: Andreas Henriksson <andreas@fatal.se>

Applied with small modification, sscanf... %u%[^\n] would not
skip leading whitespace like the original %u%s but adding a blank
in the format will correct that.
diff mbox

Patch

--- iproute-20090324-origdeb/ip/ipmroute.c	2009-10-07 17:21:00.000000000 +0200
+++ iproute-20090324/ip/ipmroute.c	2009-10-07 17:34:01.000000000 +0200
@@ -95,7 +95,7 @@ 
 		char obuf[256];
 
 		oiflist[0] = 0;
-		if (sscanf(buf, "%x%x%d%u%u%u%s", maddr.data, msrc.data, &vifi,
+		if (sscanf(buf, "%x%x%d%u%u%u%[^\n]", maddr.data, msrc.data, &vifi,
 			   &pkts, &b, &w, oiflist) < 6)
 			continue;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in