]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
Ignore carrier state on bridge device
authordv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Mon, 21 Nov 2011 10:14:03 +0000 (10:14 +0000)
committerdv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Mon, 21 Nov 2011 10:14:03 +0000 (10:14 +0000)
git-svn-id: svn://svn.code.sf.net/p/mstpd/code/trunk@17 fbe50366-0c72-4402-a84b-5d246361dba7

bridge_ctl.h
bridge_track.c
brmon.c
netif_utils.c
netif_utils.h

index 8b4e3b28d5024a747d3e34a53125c19f8182ae49..79dfe02c28ed58577981279014cfb4845d729bf7 100644 (file)
@@ -81,7 +81,7 @@ extern struct rtnl_handle rth_state;
 
 int init_bridge_ops(void);
 
-int bridge_notify(int br_index, int if_index, bool newlink, bool up);
+int bridge_notify(int br_index, int if_index, bool newlink, unsigned flags);
 
 void bridge_bpdu_rcv(int ifindex, const unsigned char *data, int len);
 
index 9eae78ced555a1ddbce9bb7652d57187fa31fb4f..5dfc879d1b08d67a9dd0a1f29dd19b70f60544ea 100644 (file)
@@ -279,13 +279,15 @@ static void set_if_up(port_t * ifc, bool up)
 }
 
 /* br_index == if_index means: interface is bridge master */
-int bridge_notify(int br_index, int if_index, bool newlink, bool up)
+int bridge_notify(int br_index, int if_index, bool newlink, unsigned flags)
 {
     port_t *ifc;
     bridge_t *br = NULL, *other_br;
+    bool up = !!(flags & IFF_UP);
+    bool running = up && (flags & IFF_RUNNING);
 
-    LOG("br_index %d, if_index %d, newlink %d, up %d",
-        br_index, if_index, newlink, up);
+    LOG("br_index %d, if_index %d, newlink %d, up %d, running %d",
+        br_index, if_index, newlink, up, running);
 
     if((br_index >= 0) && (br_index != if_index))
     {
@@ -296,9 +298,9 @@ int bridge_notify(int br_index, int if_index, bool newlink, bool up)
             ERROR("Couldn't create data for bridge interface %d", br_index);
             return -1;
         }
-        int br_up = ethtool_get_link(br->sysdeps.name);
-        if(br_up >= 0)
-            set_br_up(br, !!br_up);
+        int br_flags = get_flags(br->sysdeps.name);
+        if(br_flags >= 0)
+            set_br_up(br, !!(flags & IFF_UP));
     }
 
     if(br)
@@ -336,7 +338,7 @@ int bridge_notify(int br_index, int if_index, bool newlink, bool up)
             delete_if(ifc);
             return 0;
         }
-        set_if_up(ifc, up);    /* And speed and duplex */
+        set_if_up(ifc, running); /* And speed and duplex */
     }
     else
     { /* Interface is not a bridge slave */
diff --git a/brmon.c b/brmon.c
index 796d347a487477d244634fc4c7d33155e23c5d1e..e5954f0746b1ba855739e84342c52b70f16ddc47 100644 (file)
--- a/brmon.c
+++ b/brmon.c
@@ -66,7 +66,7 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
     int len = n->nlmsg_len;
     char b1[IFNAMSIZ];
     int af_family = ifi->ifi_family;
-    bool newlink, up;
+    bool newlink;
     int br_index;
 
     if(n->nlmsg_type == NLMSG_DONE)
@@ -154,12 +154,6 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
     fflush(fp);
 
     newlink = (n->nlmsg_type == RTM_NEWLINK);
-    up = false;
-    if(newlink && tb[IFLA_OPERSTATE])
-    {
-        int state = *(uint8_t*)RTA_DATA(tb[IFLA_OPERSTATE]);
-        up = (state == IF_OPER_UP) || (state == IF_OPER_UNKNOWN);
-    }
 
     if(tb[IFLA_MASTER])
         br_index = *(int*)RTA_DATA(tb[IFLA_MASTER]);
@@ -168,7 +162,7 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
     else
         br_index = -1;
 
-    bridge_notify(br_index, ifi->ifi_index, newlink, up);
+    bridge_notify(br_index, ifi->ifi_index, newlink, ifi->ifi_flags);
 
     return 0;
 }
index 2ca251e82f22cf8889c31717df3cd00b0a84447a..159be86df41fc51569964d85d0d08729729a28ad 100644 (file)
@@ -65,23 +65,17 @@ int get_hwaddr(char *ifname, __u8 *hwaddr)
     return 0;
 }
 
-int ethtool_get_link(char *ifname)
+int get_flags(char *ifname)
 {
     struct ifreq ifr;
     memset(&ifr, 0, sizeof(ifr));
     strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
-    struct ethtool_value eval;
-
-    eval.cmd = ETHTOOL_GLINK;
-    ifr.ifr_data = (caddr_t)&eval;
-    if(0 > ioctl(netsock, SIOCETHTOOL, &ifr))
+    if(0 > ioctl(netsock, SIOCGIFFLAGS, &ifr))
     {
-        ERROR("Cannot get link status for %s: %m\n", ifname);
+        ERROR("%s: get interface flags failed: %m", ifname);
         return -1;
     }
-    if(eval.data)
-        return 1;
-    return 0;
+    return ifr.ifr_flags;
 }
 
 int ethtool_get_speed_duplex(char *ifname, int *speed, int *duplex)
index b2919c8c4721dc0d65b374303784ad5f7efa6365..915af84136cbd300eafd224a8adbc03e00709f42 100644 (file)
@@ -31,9 +31,9 @@
 int netsock_init(void);
 
 int get_hwaddr(char *ifname, unsigned char *hwaddr);
+int get_flags(char *ifname);
 
 int ethtool_get_speed_duplex(char *ifname, int *speed, int *duplex);
-int ethtool_get_link(char *ifname);
 
 bool is_bridge(char *if_name);