mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 08:58:28 +02:00
device: add and use function set_interface_flags_full()
When device update `interface_flags`, call the function `set_interface_flags_full()`. Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
5bc511203e
commit
816bcac129
2 changed files with 42 additions and 13 deletions
|
|
@ -2600,6 +2600,30 @@ _active_connection_set_state_flags(NMDevice *self, NMActivationStateFlags flags)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
set_interface_flags_full(NMDevice * self,
|
||||
NMDeviceInterfaceFlags mask,
|
||||
NMDeviceInterfaceFlags interface_flags,
|
||||
gboolean notify)
|
||||
{
|
||||
NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self);
|
||||
NMDeviceInterfaceFlags f;
|
||||
|
||||
nm_assert(!!mask);
|
||||
nm_assert(!NM_FLAGS_ANY(mask, ~_NM_DEVICE_INTERFACE_FLAG_ALL));
|
||||
nm_assert(!NM_FLAGS_ANY(interface_flags, ~mask));
|
||||
|
||||
f = (priv->interface_flags & ~mask) | (interface_flags & mask);
|
||||
|
||||
if (f == priv->interface_flags)
|
||||
return FALSE;
|
||||
|
||||
priv->interface_flags = f;
|
||||
if (notify)
|
||||
_notify(self, PROP_INTERFACE_FLAGS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nm_device_assume_state_get(NMDevice * self,
|
||||
gboolean * out_assume_state_guess_assume,
|
||||
|
|
@ -5030,18 +5054,16 @@ nm_device_set_carrier(NMDevice *self, gboolean carrier)
|
|||
|
||||
if (NM_FLAGS_ALL(priv->capabilities,
|
||||
NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NONSTANDARD_CARRIER)) {
|
||||
if (carrier)
|
||||
priv->interface_flags |= NM_DEVICE_INTERFACE_FLAG_CARRIER;
|
||||
else
|
||||
priv->interface_flags &= ~NM_DEVICE_INTERFACE_FLAG_CARRIER;
|
||||
notify_flags = TRUE;
|
||||
notify_flags = set_interface_flags_full(self,
|
||||
NM_DEVICE_INTERFACE_FLAG_CARRIER,
|
||||
carrier ? NM_DEVICE_INTERFACE_FLAG_CARRIER
|
||||
: NM_DEVICE_INTERFACE_FLAG_NONE,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
priv->carrier = carrier;
|
||||
if (notify_flags)
|
||||
nm_gobject_notify_together(self, PROP_CARRIER, PROP_INTERFACE_FLAGS);
|
||||
else
|
||||
_notify(self, PROP_CARRIER);
|
||||
|
||||
nm_gobject_notify_together(self, PROP_CARRIER, notify_flags ? PROP_INTERFACE_FLAGS : PROP_0);
|
||||
|
||||
if (priv->carrier) {
|
||||
_LOGI(LOGD_DEVICE, "carrier: link connected");
|
||||
|
|
@ -5282,10 +5304,11 @@ device_update_interface_flags(NMDevice *self, const NMPlatformLink *plink)
|
|||
flags |= NM_DEVICE_INTERFACE_FLAG_CARRIER;
|
||||
}
|
||||
|
||||
if (flags != priv->interface_flags) {
|
||||
priv->interface_flags = flags;
|
||||
_notify(self, PROP_INTERFACE_FLAGS);
|
||||
}
|
||||
set_interface_flags_full(self,
|
||||
NM_DEVICE_INTERFACE_FLAG_UP | NM_DEVICE_INTERFACE_FLAG_LOWER_UP
|
||||
| NM_DEVICE_INTERFACE_FLAG_CARRIER,
|
||||
flags,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ gboolean nm_utils_vlan_priority_map_parse_str(NMVlanPriorityMap map_type,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NM_DEVICE_INTERFACE_FLAG_ALL \
|
||||
((NMDeviceInterfaceFlags)(NM_DEVICE_INTERFACE_FLAG_UP | NM_DEVICE_INTERFACE_FLAG_LOWER_UP \
|
||||
| NM_DEVICE_INTERFACE_FLAG_CARRIER))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_OVS_EXTERNAL_ID_NM_PREFIX "NM."
|
||||
#define NM_OVS_EXTERNAL_ID_NM_CONNECTION_UUID "NM.connection.uuid"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue