platform: remove redundant NMPlatformLink fields "arp" and "up"
This commit is contained in:
@@ -1406,15 +1406,15 @@ device_link_changed (NMDevice *self, NMPlatformLink *info)
|
||||
if (ip_ifname_changed)
|
||||
update_for_ip_ifname_change (self);
|
||||
|
||||
if (priv->up != info->up) {
|
||||
priv->up = info->up;
|
||||
if (priv->up != NM_FLAGS_HAS (info->flags, IFF_UP)) {
|
||||
priv->up = NM_FLAGS_HAS (info->flags, IFF_UP);
|
||||
|
||||
/* Manage externally-created software interfaces only when they are IFF_UP */
|
||||
g_assert (priv->ifindex > 0);
|
||||
if (NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)) {
|
||||
gboolean external_down = nm_device_get_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN);
|
||||
|
||||
if (external_down && info->up) {
|
||||
if (external_down && NM_FLAGS_HAS (info->flags, IFF_UP)) {
|
||||
if (nm_device_get_state (self) < NM_DEVICE_STATE_DISCONNECTED) {
|
||||
/* Ensure the assume check is queued before any queued state changes
|
||||
* from the transition to UNAVAILABLE.
|
||||
@@ -1437,7 +1437,7 @@ device_link_changed (NMDevice *self, NMPlatformLink *info)
|
||||
*/
|
||||
priv->unmanaged_flags &= ~NM_UNMANAGED_EXTERNAL_DOWN;
|
||||
}
|
||||
} else if (!external_down && !info->up && nm_device_get_state (self) <= NM_DEVICE_STATE_DISCONNECTED) {
|
||||
} else if (!external_down && !NM_FLAGS_HAS (info->flags, IFF_UP) && nm_device_get_state (self) <= NM_DEVICE_STATE_DISCONNECTED) {
|
||||
/* If the device is already disconnected and is set !IFF_UP,
|
||||
* unmanage it.
|
||||
*/
|
||||
@@ -8942,7 +8942,7 @@ set_property (GObject *object, guint prop_id,
|
||||
g_free (priv->iface);
|
||||
priv->iface = g_strdup (platform_device->name);
|
||||
priv->ifindex = platform_device->ifindex;
|
||||
priv->up = platform_device->up;
|
||||
priv->up = NM_FLAGS_HAS (platform_device->flags, IFF_UP);
|
||||
g_free (priv->driver);
|
||||
priv->driver = g_strdup (platform_device->driver);
|
||||
priv->platform_link_initialized = platform_device->initialized;
|
||||
|
@@ -136,10 +136,11 @@ link_init (NMFakePlatformLink *device, int ifindex, int type, const char *name)
|
||||
strcpy (device->link.name, name);
|
||||
switch (device->link.type) {
|
||||
case NM_LINK_TYPE_DUMMY:
|
||||
device->link.arp = FALSE;
|
||||
device->link.flags = NM_FLAGS_SET (device->link.flags, IFF_NOARP);
|
||||
break;
|
||||
default:
|
||||
device->link.arp = TRUE;
|
||||
device->link.flags = NM_FLAGS_UNSET (device->link.flags, IFF_NOARP);
|
||||
break;
|
||||
}
|
||||
device->address = NULL;
|
||||
}
|
||||
@@ -386,9 +387,9 @@ link_set_up (NMPlatform *platform, int ifindex)
|
||||
g_error ("Unexpected device type: %d", device->link.type);
|
||||
}
|
||||
|
||||
if ( device->link.up != up
|
||||
if ( NM_FLAGS_HAS (device->link.flags, IFF_UP) != !!up
|
||||
|| device->link.connected != connected) {
|
||||
device->link.up = up;
|
||||
device->link.flags = NM_FLAGS_ASSIGN (device->link.flags, IFF_UP, up);
|
||||
device->link.connected = connected;
|
||||
link_changed (platform, device, TRUE);
|
||||
}
|
||||
@@ -404,8 +405,8 @@ link_set_down (NMPlatform *platform, int ifindex)
|
||||
if (!device)
|
||||
return FALSE;
|
||||
|
||||
if (device->link.up || device->link.connected) {
|
||||
device->link.up = FALSE;
|
||||
if (NM_FLAGS_HAS (device->link.flags, IFF_UP) || device->link.connected) {
|
||||
device->link.flags = NM_FLAGS_UNSET (device->link.flags, IFF_UP);
|
||||
device->link.connected = FALSE;
|
||||
|
||||
link_changed (platform, device, TRUE);
|
||||
@@ -422,7 +423,7 @@ link_set_arp (NMPlatform *platform, int ifindex)
|
||||
if (!device)
|
||||
return FALSE;
|
||||
|
||||
device->link.arp = TRUE;
|
||||
device->link.flags = NM_FLAGS_UNSET (device->link.flags, IFF_NOARP);
|
||||
|
||||
link_changed (platform, device, TRUE);
|
||||
|
||||
@@ -437,7 +438,7 @@ link_set_noarp (NMPlatform *platform, int ifindex)
|
||||
if (!device)
|
||||
return FALSE;
|
||||
|
||||
device->link.arp = FALSE;
|
||||
device->link.flags = NM_FLAGS_SET (device->link.flags, IFF_NOARP);
|
||||
|
||||
link_changed (platform, device, TRUE);
|
||||
|
||||
@@ -449,7 +450,7 @@ link_is_up (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
NMFakePlatformLink *device = link_get (platform, ifindex);
|
||||
|
||||
return device ? device->link.up : FALSE;
|
||||
return device ? NM_FLAGS_HAS (device->link.flags, IFF_UP) : FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -465,7 +466,7 @@ link_uses_arp (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
NMFakePlatformLink *device = link_get (platform, ifindex);
|
||||
|
||||
return device ? device->link.arp : FALSE;
|
||||
return device ? !NM_FLAGS_HAS (device->link.flags, IFF_NOARP) : FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -616,7 +617,7 @@ link_enslave (NMPlatform *platform, int master, int slave)
|
||||
device->link.master = master;
|
||||
|
||||
if (NM_IN_SET (master_device->link.type, NM_LINK_TYPE_BOND, NM_LINK_TYPE_TEAM)) {
|
||||
device->link.up = TRUE;
|
||||
device->link.flags = NM_FLAGS_SET (device->link.flags, IFF_UP);
|
||||
device->link.connected = TRUE;
|
||||
}
|
||||
|
||||
|
@@ -913,9 +913,7 @@ _nmp_vt_cmd_plobj_init_from_nl_link (NMPlatform *platform, NMPlatformObject *_ob
|
||||
obj->type = link_extract_type (platform, nlo, complete_from_cache, &kind);
|
||||
obj->kind = g_intern_string (kind);
|
||||
obj->flags = rtnl_link_get_flags (nlo);
|
||||
obj->up = NM_FLAGS_HAS (obj->flags, IFF_UP);
|
||||
obj->connected = NM_FLAGS_HAS (obj->flags, IFF_LOWER_UP);
|
||||
obj->arp = !NM_FLAGS_HAS (obj->flags, IFF_NOARP);
|
||||
obj->master = rtnl_link_get_master (nlo);
|
||||
obj->parent = rtnl_link_get_link (nlo);
|
||||
obj->mtu = rtnl_link_get_mtu (nlo);
|
||||
|
@@ -2466,9 +2466,9 @@ nm_platform_link_to_string (const NMPlatformLink *link)
|
||||
return "(unknown link)";
|
||||
|
||||
str_flags = g_string_new (NULL);
|
||||
if (!link->arp)
|
||||
if (NM_FLAGS_HAS (link->flags, IFF_NOARP))
|
||||
g_string_append (str_flags, "NOARP,");
|
||||
if (link->up)
|
||||
if (NM_FLAGS_HAS (link->flags, IFF_UP))
|
||||
g_string_append (str_flags, "UP");
|
||||
else
|
||||
g_string_append (str_flags, "DOWN");
|
||||
@@ -2844,11 +2844,9 @@ nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b)
|
||||
_CMP_FIELD_STR (a, b, name);
|
||||
_CMP_FIELD (a, b, master);
|
||||
_CMP_FIELD (a, b, parent);
|
||||
_CMP_FIELD (a, b, up);
|
||||
_CMP_FIELD (a, b, vlan_id);
|
||||
_CMP_FIELD (a, b, flags);
|
||||
_CMP_FIELD (a, b, connected);
|
||||
_CMP_FIELD (a, b, arp);
|
||||
_CMP_FIELD (a, b, mtu);
|
||||
_CMP_FIELD_BOOL (a, b, initialized);
|
||||
_CMP_FIELD (a, b, arptype);
|
||||
|
@@ -135,16 +135,10 @@ struct _NMPlatformLink {
|
||||
* 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;
|
||||
};
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include "nm-platform.h"
|
||||
#include "nm-linux-platform.h"
|
||||
#include "nm-fake-platform.h"
|
||||
#include "nm-macros-internal.h"
|
||||
|
||||
static void
|
||||
dump_interface (NMPlatformLink *link)
|
||||
@@ -26,14 +27,14 @@ dump_interface (NMPlatformLink *link)
|
||||
size_t addrlen;
|
||||
int i;
|
||||
|
||||
g_assert (link->up || !link->connected);
|
||||
g_assert (NM_FLAGS_HAS (link->flags, IFF_UP) || !link->connected);
|
||||
|
||||
printf ("%d: %s: %s", link->ifindex, link->name, nm_link_type_to_string (link->type));
|
||||
if (link->up)
|
||||
if (NM_FLAGS_HAS (link->flags, IFF_UP))
|
||||
printf (" %s", link->connected ? "CONNECTED" : "DISCONNECTED");
|
||||
else
|
||||
printf (" DOWN");
|
||||
if (!link->arp)
|
||||
if (NM_FLAGS_HAS (link->flags, IFF_NOARP))
|
||||
printf (" noarp");
|
||||
if (link->master)
|
||||
printf (" master %d", link->master);
|
||||
|
Reference in New Issue
Block a user