Skip to contentSkip to conversation

two fields are missing in brctl output when using /sys

Bridge Jeremy Jackson 2 participants 2 messages Apr 5, 2007 – May 8, 2007 Ethernet bridge

lore
Share & tools
lore
#0 lore raw

I've noticed for a while that

# brctl showstp

output is showing 0 for port_no and port_id

It seems that somewhere in 2.6 sysfs land the following items got printed in hexadecimal, and brctl code was parsing for decimal only

doug:/sys/class/net/eth0/brport# cat port_id
0x8001
doug:/sys/class/net/eth0/brport# cat port_no
0x1

The following patch to bridge-utils (git and 1.2 release) lets it do the right thing:

diff -ur bridge-utils-1.2/libbridge/libbridge_devif.c bridge-utils/libbridge/lib
bridge_devif.c
--- bridge-utils-1.2/libbridge/libbridge_devif.c 2007-04-05
16:02:58.2870
22220 -0400
+++ bridge-utils/libbridge/libbridge_devif.c 2007-04-05
14:51:19.362040447 -0
400
@@ -56,7 +56,7 @@

        if (!f) 
                fprintf(stderr, "%s: %s\n", dev, strerror(errno));
        else {
-               fscanf(f, "%i", &value);
+               fscanf(f, "%d", &value);
                fclose(f);
        }
        return value;

Please CC replies as I'm not subscribed.

Signature · 5 lines
Jeremy Jackson
[email protected] Email/Jabber/Google Talk/MSN
(519)489-4903
Coplanar Networks
http://www.coplanar.net
#1 lore raw
Quoted 28 lines · On Thu, 05 Apr 2007 16:10:59 -0400 Jeremy Jackson <[email protected]> wrote:

I've noticed for a while that

# brctl showstp

output is showing 0 for port_no and port_id

It seems that somewhere in 2.6 sysfs land the following items got printed in hexadecimal, and brctl code was parsing for decimal only

doug:/sys/class/net/eth0/brport# cat port_id
0x8001
doug:/sys/class/net/eth0/brport# cat port_no
0x1

The following patch to bridge-utils (git and 1.2 release) lets it do the right thing:

diff -ur bridge-utils-1.2/libbridge/libbridge_devif.c bridge-utils/libbridge/lib
bridge_devif.c
--- bridge-utils-1.2/libbridge/libbridge_devif.c 2007-04-05
16:02:58.2870
22220 -0400
+++ bridge-utils/libbridge/libbridge_devif.c 2007-04-05
14:51:19.362040447 -0
400

Review line 62

Quoted 8 lines
(quoted diff) +1 -1
@@ -56,7 +56,7 @@
        if (!f) 
                fprintf(stderr, "%s: %s\n", dev, strerror(errno));
        else {
-               fscanf(f, "%i", &value);
+               fscanf(f, "%d", &value);
                fclose(f);
        }
        return value;

Applied manually, (your patch was backwards)

Signature · 1 line
Stephen Hemminger <[email protected]>