platform: add flags parameter to NMPlatformLink

This commit is contained in:
Thomas Haller
2015-04-25 16:42:26 +02:00
parent 619f660a3e
commit b307abc010
3 changed files with 23 additions and 3 deletions

View File

@@ -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);

View File

@@ -2440,6 +2440,7 @@ nm_platform_link_to_string (const NMPlatformLink *link)
{
char master[20];
char parent[20];
char str_flags[64];
char *driver, *udi;
GString *str;
@@ -2456,6 +2457,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
@@ -2763,6 +2769,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);

View File

@@ -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;
};