From 4e2ef48a212b35a761cdcb30f01637200cae97e8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Apr 2015 16:42:26 +0200 Subject: [PATCH] platform: add flags parameter to NMPlatformLink (cherry picked from commit b307abc0106ec0c556d581949d1fe92d57874239) --- src/platform/nm-linux-platform.c | 7 ++++--- src/platform/nm-platform.c | 7 +++++++ src/platform/nm-platform.h | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 958a7c97ab..d305c71528 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -941,9 +941,10 @@ init_link (NMPlatform *platform, NMPlatformLink *info, struct rtnl_link *rtnllin info->name[0] = '\0'; info->type = link_extract_type (platform, rtnllink); info->kind = g_intern_string (rtnl_link_get_type (rtnllink)); - info->up = !!(rtnl_link_get_flags (rtnllink) & IFF_UP); - info->connected = !!(rtnl_link_get_flags (rtnllink) & IFF_LOWER_UP); - info->arp = !(rtnl_link_get_flags (rtnllink) & IFF_NOARP); + info->flags = rtnl_link_get_flags (rtnllink); + info->up = NM_FLAGS_HAS (info->flags, IFF_UP); + info->connected = NM_FLAGS_HAS (info->flags, IFF_LOWER_UP); + info->arp = !NM_FLAGS_HAS (info->flags, IFF_NOARP); info->master = rtnl_link_get_master (rtnllink); info->parent = rtnl_link_get_link (rtnllink); info->mtu = rtnl_link_get_mtu (rtnllink); diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 8772e45aed..ad683846e2 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2637,6 +2637,7 @@ nm_platform_link_to_string (const NMPlatformLink *link) { char master[20]; char parent[20]; + char str_flags[64]; char *driver, *udi; GString *str; @@ -2653,6 +2654,11 @@ nm_platform_link_to_string (const NMPlatformLink *link) if (link->connected) g_string_append (str, ",LOWER_UP"); + if (link->flags) { + rtnl_link_flags2str (link->flags, str_flags, sizeof (str_flags)); + g_string_append_printf (str, ";%s", str_flags); + } + if (link->master) g_snprintf (master, sizeof (master), " master %d", link->master); else @@ -2960,6 +2966,7 @@ nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b) _CMP_FIELD (a, b, master); _CMP_FIELD (a, b, parent); _CMP_FIELD (a, b, up); + _CMP_FIELD (a, b, flags); _CMP_FIELD (a, b, connected); _CMP_FIELD (a, b, arp); _CMP_FIELD (a, b, mtu); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 7f4cdbe0a2..07588e6417 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -100,9 +100,21 @@ struct _NMPlatformLink { gboolean initialized; int master; int parent; + + /* IFF_* flags as u32. Note that ifi_flags in 'struct ifinfomsg' is declared as 'unsigned', + * but libnl stores the flag internally as u32. */ + guint32 flags; + + /* FIXME: @up is redundant to (@flags & IFF_UP) */ gboolean up; + + /* @connected is mostly identical to (@flags & IFF_UP). Except for bridge/bond masters, + * where we coerce the link as disconnect if it has no slaves. */ gboolean connected; + + /* FIXME: @arp is redundant to !(@flags & IFF_NOARP) */ gboolean arp; + guint mtu; };