rtnl: Ignore netlink messages generated by wext 31/1831/1
authorJohannes Berg <johannes.berg@intel.com>
Fri, 21 Sep 2012 07:38:15 +0000 (10:38 +0300)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Tue, 25 Sep 2012 14:24:28 +0000 (17:24 +0300)
This is a back-port, commit ID in connman upstream is
baca46719603974ed6849996c50a66f4ebeb5ff1
Partially fixes TIVI-164.

ConnMan should just ignore netlink messages generated by wext
as described in commit 4997f6e38f34effc00179e849dee0dc2e2263d3a.

Handle wext message detection using the IFLA_WIRELESS type
because the ifinfomsg ifi_change field is reserved for future
use and code using it for wext detection has been removed.

src/rtnl.c

index 4e7ef4d..7f2fb63 100644 (file)
@@ -356,10 +356,10 @@ static const char *operstate2str(unsigned char operstate)
        return "";
 }
 
-static void extract_link(struct ifinfomsg *msg, int bytes,
+static connman_bool_t extract_link(struct ifinfomsg *msg, int bytes,
                                struct ether_addr *address, const char **ifname,
                                unsigned int *mtu, unsigned char *operstate,
-                                               struct rtnl_link_stats *stats)
+                               struct rtnl_link_stats *stats)
 {
        struct rtattr *attr;
 
@@ -389,8 +389,12 @@ static void extract_link(struct ifinfomsg *msg, int bytes,
                        break;
                case IFLA_LINKMODE:
                        break;
+               case IFLA_WIRELESS:
+                       return FALSE;
                }
        }
+
+       return TRUE;
 }
 
 static void process_newlink(unsigned short type, int index, unsigned flags,
@@ -407,7 +411,9 @@ static void process_newlink(unsigned short type, int index, unsigned flags,
        GSList *list;
 
        memset(&stats, 0, sizeof(stats));
-       extract_link(msg, bytes, &address, &ifname, &mtu, &operstate, &stats);
+       if (extract_link(msg, bytes, &address, &ifname, &mtu, &operstate,
+                                       &stats) == FALSE)
+               return;
 
        snprintf(ident, 13, "%02x%02x%02x%02x%02x%02x",
                                                address.ether_addr_octet[0],
@@ -488,7 +494,9 @@ static void process_dellink(unsigned short type, int index, unsigned flags,
        GSList *list;
 
        memset(&stats, 0, sizeof(stats));
-       extract_link(msg, bytes, NULL, &ifname, NULL, &operstate, &stats);
+       if (extract_link(msg, bytes, NULL, &ifname, NULL, &operstate,
+                                       &stats) == FALSE)
+               return;
 
        if (operstate != 0xff)
                connman_info("%s {dellink} index %d operstate %u <%s>",