mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 13:40:39 +01:00
device: let device specs match on permanent MAC address
Using the current, possibly non-permanent MAC address doesn't really make sense. Also, NM_DEVICE_HW_ADDRESS used to be writable and was set by NMDeviceBt to the bdaddr. That is wrong, because bdaddr should not be the current address, but the permanent one.
This commit is contained in:
parent
da3f608802
commit
481cdc2706
5 changed files with 24 additions and 21 deletions
|
|
@ -1042,7 +1042,7 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
|
|||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>HWADDR</term>
|
||||
<listitem><para>Match the MAC address of the device. Globbing is not supported</para></listitem>
|
||||
<listitem><para>Match the permanent MAC address of the device. Globbing is not supported</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>interface-name:IFNAME</term>
|
||||
|
|
@ -1057,7 +1057,7 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
|
|||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>mac:HWADDR</term>
|
||||
<listitem><para>Match the MAC address of the device. Globbing is not supported</para></listitem>
|
||||
<listitem><para>Match the permanent MAC address of the device. Globbing is not supported</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>s390-subchannels:HWADDR</term>
|
||||
|
|
|
|||
|
|
@ -1002,7 +1002,7 @@ nm_device_bt_new (NMBluezDevice *bt_device,
|
|||
NM_DEVICE_UDI, udi,
|
||||
NM_DEVICE_IFACE, bdaddr,
|
||||
NM_DEVICE_DRIVER, "bluez",
|
||||
NM_DEVICE_HW_ADDRESS, bdaddr,
|
||||
NM_DEVICE_PERM_HW_ADDRESS, bdaddr,
|
||||
NM_DEVICE_BT_DEVICE, bt_device,
|
||||
NM_DEVICE_BT_NAME, name,
|
||||
NM_DEVICE_BT_CAPABILITIES, capabilities,
|
||||
|
|
|
|||
|
|
@ -11632,9 +11632,9 @@ nm_device_spec_match_list (NMDevice *self, const GSList *specs)
|
|||
static NMMatchSpecMatchType
|
||||
spec_match_list (NMDevice *self, const GSList *specs)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMMatchSpecMatchType matched = NM_MATCH_SPEC_NO_MATCH, m;
|
||||
const GSList *iter;
|
||||
const char *hw_addr_perm;
|
||||
|
||||
for (iter = specs; iter; iter = g_slist_next (iter)) {
|
||||
if (!strcmp ((const char *) iter->data, "*")) {
|
||||
|
|
@ -11642,8 +11642,10 @@ spec_match_list (NMDevice *self, const GSList *specs)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (priv->hw_addr_len && priv->hw_addr) {
|
||||
m = nm_match_spec_hwaddr (specs, priv->hw_addr);
|
||||
|
||||
hw_addr_perm = nm_device_get_permanent_hw_address (self, FALSE);
|
||||
if (hw_addr_perm) {
|
||||
m = nm_match_spec_hwaddr (specs, hw_addr_perm);
|
||||
matched = MAX (matched, m);
|
||||
}
|
||||
if (matched != NM_MATCH_SPEC_NEG_MATCH) {
|
||||
|
|
@ -11717,7 +11719,6 @@ constructor (GType type,
|
|||
NMDevice *self;
|
||||
NMDevicePrivate *priv;
|
||||
const NMPlatformLink *pllink;
|
||||
guint count;
|
||||
|
||||
klass = G_OBJECT_CLASS (nm_device_parent_class);
|
||||
object = klass->constructor (type, n_construct_params, construct_params);
|
||||
|
|
@ -11737,15 +11738,15 @@ constructor (GType type,
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->hw_addr) {
|
||||
count = _nm_utils_hwaddr_length (priv->hw_addr);
|
||||
if (count <= 0) {
|
||||
_LOGW (LOGD_DEVICE, "hw-addr: could not parse hw-address '%s'", priv->hw_addr);
|
||||
g_clear_pointer (&priv->hw_addr, g_free);
|
||||
} else {
|
||||
priv->hw_addr_len = count;
|
||||
_LOGT (LOGD_DEVICE, "hw-addr: set current hw-address '%s'", priv->hw_addr);
|
||||
if (priv->hw_addr_perm) {
|
||||
priv->hw_addr_len = _nm_utils_hwaddr_length (priv->hw_addr_perm);
|
||||
if (!priv->hw_addr_len) {
|
||||
g_clear_pointer (&priv->hw_addr_perm, g_free);
|
||||
g_return_val_if_reached (object);
|
||||
}
|
||||
|
||||
priv->hw_addr = g_strdup (priv->hw_addr_perm);
|
||||
_LOGT (LOGD_DEVICE, "hw-addr: has permanent hw-address '%s'", priv->hw_addr_perm);
|
||||
}
|
||||
|
||||
return object;
|
||||
|
|
@ -11982,9 +11983,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_IS_MASTER:
|
||||
priv->is_master = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_HW_ADDRESS:
|
||||
case PROP_PERM_HW_ADDRESS:
|
||||
/* construct only */
|
||||
priv->hw_addr = g_value_dup_string (value);
|
||||
priv->hw_addr_perm = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -12354,12 +12355,12 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
obj_properties[PROP_HW_ADDRESS] =
|
||||
g_param_spec_string (NM_DEVICE_HW_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_PERM_HW_ADDRESS] =
|
||||
g_param_spec_string (NM_DEVICE_PERM_HW_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_HAS_PENDING_ACTION] =
|
||||
g_param_spec_boolean (NM_DEVICE_HAS_PENDING_ACTION, "", "",
|
||||
|
|
|
|||
|
|
@ -399,7 +399,9 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device)
|
|||
|
||||
priv = NM_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
hw_address = nm_device_get_hw_address (device);
|
||||
hw_address = nm_device_get_permanent_hw_address (device, FALSE);
|
||||
if (!hw_address)
|
||||
return;
|
||||
|
||||
no_auto_default_current = nm_config_data_get_no_auto_default (priv->config_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,6 @@ nm_test_device_new (const char *hwaddr)
|
|||
{
|
||||
return g_object_new (NM_TYPE_TEST_DEVICE,
|
||||
NM_DEVICE_IFACE, "dummy",
|
||||
NM_DEVICE_HW_ADDRESS, hwaddr,
|
||||
NM_DEVICE_PERM_HW_ADDRESS, hwaddr,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue