From 58f7813283c8daf04c20b3f0fbb6bdf0a710fbb2 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Wed, 10 May 2017 22:27:34 -0400 Subject: [PATCH] platform: ignore RTM_GETLINK messages sent by wireless extentions We listen to all RTM_GETLINK messages to get updates on interfaces statuses. Unfortunately wireless code in the kernel sends those messages with wireless information included and all other information excluded. When we receive such message we wipe out our valid cached entry with new object that is almost empty because netlink message didn't contain any information. Solution to this is to check that incoming message contains MTU field: this field is always set for complete messages about interfaces and is not set by wireless code. Signed-off-by: Nikolay Martynov https://github.com/NetworkManager/NetworkManager/pull/17 --- src/platform/nm-linux-platform.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 252f054d43..487725e416 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1529,6 +1529,23 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr if (!obj->link.name[0]) goto errout; + if (!tb[IFLA_MTU]) { + /* Kernel has two places that send RTM_GETLINK messages: + * net/core/rtnetlink.c and net/wireless/ext-core.c. + * Unfotunatelly ext-core.c sets only IFLA_WIRELESS and + * IFLA_IFNAME. This confuses code in this function, because + * it cannot get complete set of data for the interface and + * later incomplete object this function creates is used to + * overwrite existing data in NM's cache. + * Since ext-core.c doesn't set IFLA_MTU we can use it as a + * signal to ignore incoming message. + * To some extent this is a hack and correct approach is to + * merge objects per-field. + */ + goto errout; + } + obj->link.mtu = nla_get_u32 (tb[IFLA_MTU]); + if (tb[IFLA_LINKINFO]) { err = nla_parse_nested (li, IFLA_INFO_MAX, tb[IFLA_LINKINFO], policy_link_info); if (err < 0) @@ -1609,9 +1626,6 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr } } - if (tb[IFLA_MTU]) - obj->link.mtu = nla_get_u32 (tb[IFLA_MTU]); - switch (obj->link.type) { case NM_LINK_TYPE_GRE: lnk_data = _parse_lnk_gre (nl_info_kind, nl_info_data);