device,config: don't write fake MAC address to "no-auto-default.state" file

For one, nm_config_get_no_auto_default_for_device() uses
nm_device_spec_match_list(). This ignores fake MAC addresses.
Maybe it should not do that, but it's also not clear what it
would mean for the function to consider them.

As such, it makes not sense trying to persist such MAC addresses
to "/var/lib/NetworkManager/no-auto-default.state". For the moment,
just do nothing.

This still leaves the problem how we prevent the device from generating
a auto-default connection. But this patch is no change in behavior, because
it didn't work anyway.
This commit is contained in:
Thomas Haller 2019-07-18 13:42:28 +02:00
parent f13454cb1c
commit 8437cd0895

View file

@ -416,6 +416,7 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device)
const char *hw_address;
const char *const*no_auto_default_current;
GPtrArray *no_auto_default_new = NULL;
gboolean is_fake;
guint i;
g_return_if_fail (NM_IS_CONFIG (self));
@ -423,10 +424,23 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device)
priv = NM_CONFIG_GET_PRIVATE (self);
hw_address = nm_device_get_permanent_hw_address (device);
hw_address = nm_device_get_permanent_hw_address_full (device, TRUE, &is_fake);
if (!hw_address)
return;
if (is_fake) {
/* this is a problem. The MAC address is fake, it's possibly only valid
* until reboot (or even less).
*
* Also, nm_device_spec_match_list() ignores fake addresses, so even if
* we would persist it, it wouldn't work (well, maybe it should?).
*
* Anyway, let's do nothing here. NMSettings needs to remember this
* in memory. */
return;
}
no_auto_default_current = nm_config_data_get_no_auto_default (priv->config_data);
if (nm_utils_strv_find_first ((char **) no_auto_default_current, -1, hw_address) >= 0) {