]> git.ipfire.org Git - people/ms/rstp.git/commitdiff
Ignore carrier state on bridge device
authorStephen Hemminger <shemminger@vyatta.com>
Mon, 4 Jul 2011 21:37:25 +0000 (14:37 -0700)
committerStephen Hemminger <shemminger@vyatta.com>
Mon, 4 Jul 2011 21:37:25 +0000 (14:37 -0700)
The carrier of bridge device reflects underlying devices in later
kernels. Therefor RSTP daemon should ignore carrier (IFF_RUNNING)
and only look at IFF_UP on bridge device.

bridge_ctl.h
bridge_track.c
brmon.c

index 283833083b7c05668cb06b013334ae5744714e44..b0449ca0487d4e8b4562e962e48456152da26f31 100644 (file)
@@ -33,7 +33,7 @@ void bridge_get_configuration(void);
 
 int bridge_set_state(int ifindex, int state);
 
-int bridge_notify(int br_index, int if_index, int newlink, int up);
+int bridge_notify(int br_index, int if_index, int newlink, unsigned flags);
 
 void bridge_bpdu_rcv(int ifindex, const unsigned char *data, int len);
 
index efc23e5522de937b955e1856336d8a6eb06d1970..289fc412497387fa2a43a8ae31af82cce2672938 100644 (file)
@@ -476,13 +476,14 @@ static void set_if_up(struct ifdata *ifc, int up)
 
 /*------------------------------------------------------------*/
 
-int bridge_notify(int br_index, int if_index, int newlink, int up)
+int bridge_notify(int br_index, int if_index, int newlink, 
+                 unsigned flags)
 {
-       if (up)
-               up = 1;
-       LOG("br_index %d, if_index %d, up %d", br_index, if_index, up);
-
        struct ifdata *br = NULL;
+
+       LOG("br_index %d, if_index %d, up %d running %d",
+           br_index, if_index, (flags & IFF_UP), flags & IFF_RUNNING);
+
        if (br_index >= 0) {
                br = find_if(br_index);
                if (br && !br->is_bridge) {
@@ -536,6 +537,8 @@ int bridge_notify(int br_index, int if_index, int newlink, int up)
                        delete_if(ifc);
                        return 0;
                }
+               int up = (flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING);
+
                if (ifc->up != up)
                        set_if_up(ifc, up);     /* And speed and duplex */
        } else {                /* No br_index */
@@ -565,11 +568,18 @@ int bridge_notify(int br_index, int if_index, int newlink, int up)
                                delete_if(ifc);
                                return 0;
                        }
-                       if (ifc && ifc->up != up) {
-                               if (ifc->is_bridge)
-                                       set_br_up(ifc, up);
-                               else
-                                       set_if_up(ifc, up);
+
+                       if (ifc) {
+                               if (ifc->is_bridge) {
+                                       int up = (flags & IFF_UP) != 0;
+                                       if (ifc->up != up)
+                                               set_br_up(ifc, up);
+                               } else {
+                                       int up = (flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING);
+
+                                       if (ifc->up != up)
+                                               set_if_up(ifc, up);
+                               }
                        }
                }
        }
diff --git a/brmon.c b/brmon.c
index fd4dacd44f4a68728dc9d7ab5fb762a11a17b552..4c4e49012ddcba1bde9715b2011af2b1aa8e142c 100644 (file)
--- a/brmon.c
+++ b/brmon.c
 
 static const char SNAPSHOT[] = "v0.1";
 
-static int is_up(const struct ifinfomsg *ifi)
-{
-       return (ifi->ifi_flags & IFF_UP) && (ifi->ifi_flags & IFF_RUNNING);
-}
-
 static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
                    void *arg)
 {
@@ -95,7 +90,7 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
 
        bridge_notify(master, ifi->ifi_index,
                      (n->nlmsg_type == RTM_NEWLINK),
-                     is_up(ifi));
+                     ifi->ifi_flags);
 
        return 0;
 }