diff --git a/NEWS b/NEWS
index 6d479faa75..e7838bd35f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,15 @@
=============================================
NetworkManager-1.46
-Overview of changes since NetworkManager-1.46
+Overview of changes since NetworkManager-1.44
=============================================
* Change internal ABI of NMSetting types and NMSimpleConnection. The layout of
these structs was already hidden from public headers since 1.34 and this change
should not be noticeable.
+* Honor udev property ID_NET_AUTO_LINK_LOCAL_ONLY=1 for enabling
+ link local addresses on default wired connection.
+* Honor udev property ID_NET_MANAGED_BY to only manage an interface
+ when set to "org.freedesktop.NetworkManager".
=============================================
NetworkManager-1.44
diff --git a/man/NetworkManager.xml b/man/NetworkManager.xml
index bd5429952f..ff1635cd29 100644
--- a/man/NetworkManager.xml
+++ b/man/NetworkManager.xml
@@ -193,6 +193,42 @@
+
+ ID_NET_MANAGED_BY
+
+ If NM_UNMANAGED is set, this has no effect. Otherwise,
+ if the attribute is set to anything but
+ "org.freedesktop.NetworkManager", the device is unmanaged.
+
+
+
+
+ NM_AUTO_DEFAULT_LINK_LOCAL_ONLY
+
+ If set to "1" or "true", the
+ automatically generated connections "Wired connection N" will only
+ enable link local addressing for IPv4 and IPv6. This can be useful
+ on thunderbolt devices or host-to-host USB devices.
+
+
+
+
+ ID_NET_AUTO_LINK_LOCAL_ONLY
+
+ Honored and treated the same as if NM_AUTO_DEFAULT_LINK_LOCAL_ONLY
+ were set.
+
+
+
+
+ ID_NET_DHCP_BROADCAST
+
+ If set to "1" or "true", use
+ broadcast requests for DHCPv4 offers. This can make sense of devices
+ that can't handle unicast messages until being configured.
+
+
+
diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c
index aedacc248b..5d58b69d67 100644
--- a/src/core/devices/nm-device-ethernet.c
+++ b/src/core/devices/nm-device-ethernet.c
@@ -1711,10 +1711,8 @@ new_default_connection(NMDevice *self)
NMSettingsConnection *const *connections;
NMSetting *setting;
gs_unref_hashtable GHashTable *existing_ids = NULL;
- struct udev_device *dev;
const char *perm_hw_addr;
const char *iface;
- const char *uprop = "0";
gs_free char *defname = NULL;
gs_free char *uuid = NULL;
guint i, n_connections;
@@ -1760,30 +1758,6 @@ new_default_connection(NMDevice *self)
iface,
NULL);
- /* Check if we should create a Link-Local only connection */
- dev = nm_platform_link_get_udev_device(nm_device_get_platform(NM_DEVICE(self)),
- nm_device_get_ip_ifindex(self));
- if (dev)
- uprop = udev_device_get_property_value(dev, "NM_AUTO_DEFAULT_LINK_LOCAL_ONLY");
-
- if (_nm_utils_ascii_str_to_bool(uprop, FALSE)) {
- setting = nm_setting_ip4_config_new();
- g_object_set(setting,
- NM_SETTING_IP_CONFIG_METHOD,
- NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
- NULL);
- nm_connection_add_setting(connection, setting);
-
- setting = nm_setting_ip6_config_new();
- g_object_set(setting,
- NM_SETTING_IP_CONFIG_METHOD,
- NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
- NM_SETTING_IP_CONFIG_MAY_FAIL,
- TRUE,
- NULL);
- nm_connection_add_setting(connection, setting);
- }
-
return connection;
}
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index b8c2f88cc7..8031bd5dd4 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include "libnm-std-aux/unaligned.h"
#include "libnm-glib-aux/nm-uuid.h"
@@ -8098,6 +8099,40 @@ nm_device_owns_iface(NMDevice *self, const char *iface)
return FALSE;
}
+static void
+apply_udev_auto_default_configs(NMDevice *self, NMConnection *connection)
+{
+ struct udev_device *dev;
+ const char *uprop;
+ NMSetting *setting;
+
+ dev = nm_platform_link_get_udev_device(nm_device_get_platform(NM_DEVICE(self)),
+ nm_device_get_ip_ifindex(self));
+ if (!dev)
+ return;
+
+ uprop = udev_device_get_property_value(dev, "NM_AUTO_DEFAULT_LINK_LOCAL_ONLY");
+ uprop = uprop ?: udev_device_get_property_value(dev, "ID_NET_AUTO_LINK_LOCAL_ONLY");
+
+ if (_nm_utils_ascii_str_to_bool(uprop, FALSE)) {
+ setting = nm_setting_ip4_config_new();
+ g_object_set(setting,
+ NM_SETTING_IP_CONFIG_METHOD,
+ NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
+ NULL);
+ nm_connection_add_setting(connection, setting);
+
+ setting = nm_setting_ip6_config_new();
+ g_object_set(setting,
+ NM_SETTING_IP_CONFIG_METHOD,
+ NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
+ NM_SETTING_IP_CONFIG_MAY_FAIL,
+ TRUE,
+ NULL);
+ nm_connection_add_setting(connection, setting);
+ }
+}
+
NMConnection *
nm_device_new_default_connection(NMDevice *self)
{
@@ -8111,6 +8146,8 @@ nm_device_new_default_connection(NMDevice *self)
if (!connection)
return NULL;
+ apply_udev_auto_default_configs(self, connection);
+
if (!nm_connection_normalize(connection, NULL, NULL, &error)) {
_LOGD(LOGD_DEVICE, "device generated an invalid default connection: %s", error->message);
g_error_free(error);
@@ -15097,20 +15134,23 @@ nm_device_set_unmanaged_by_user_settings(NMDevice *self, gboolean now)
void
nm_device_set_unmanaged_by_user_udev(NMDevice *self)
{
- int ifindex;
- gboolean platform_unmanaged = FALSE;
+ NMOptionBool platform_unmanaged;
+ int ifindex;
ifindex = self->_priv->ifindex;
- if (ifindex <= 0
- || !nm_platform_link_get_unmanaged(nm_device_get_platform(self),
- ifindex,
- &platform_unmanaged))
+ if (ifindex <= 0)
+ return;
+
+ platform_unmanaged = nm_platform_link_get_unmanaged(nm_device_get_platform(self), ifindex);
+ if (platform_unmanaged == NM_OPTION_BOOL_DEFAULT)
return;
nm_device_set_unmanaged_by_flags(self,
NM_UNMANAGED_USER_UDEV,
- platform_unmanaged,
+ platform_unmanaged == NM_OPTION_BOOL_TRUE
+ ? NM_UNMAN_FLAG_OP_SET_UNMANAGED
+ : NM_UNMAN_FLAG_OP_SET_MANAGED,
NM_DEVICE_STATE_REASON_USER_REQUESTED);
}
diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c
index 1b513d34be..d5acec98f5 100644
--- a/src/libnm-platform/nm-platform.c
+++ b/src/libnm-platform/nm-platform.c
@@ -1636,7 +1636,7 @@ nm_platform_link_get_udev_property(NMPlatform *self,
const char *name,
const char **out_value)
{
- struct udev_device *udevice = NULL;
+ struct udev_device *udevice;
const char *uproperty;
udevice = nm_platform_link_get_udev_device(self, ifindex);
@@ -1655,22 +1655,34 @@ nm_platform_link_get_udev_property(NMPlatform *self,
* nm_platform_link_get_unmanaged:
* @self: platform instance
* @ifindex: interface index
- * @unmanaged: management status (in case %TRUE is returned)
*
- * Returns: %TRUE if platform overrides NM default-unmanaged status,
- * %FALSE otherwise (with @unmanaged unmodified).
+ * Returns: %NM_OPTION_BOOL_DEFAULT if the udev property NM_UNMANAGED
+ * is not set. Otherwise, return NM_UNMANAGED as boolean.
*/
-gboolean
-nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex, gboolean *unmanaged)
+NMOptionBool
+nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex)
{
- const char *value;
+ struct udev_device *udevice;
+ const char *val;
- if (nm_platform_link_get_udev_property(self, ifindex, "NM_UNMANAGED", &value)) {
- NM_SET_OUT(unmanaged, _nm_utils_ascii_str_to_bool(value, FALSE));
- return TRUE;
+ udevice = nm_platform_link_get_udev_device(self, ifindex);
+ if (!udevice)
+ return NM_OPTION_BOOL_DEFAULT;
+
+ val = udev_device_get_property_value(udevice, "NM_UNMANAGED");
+ if (val)
+ return _nm_utils_ascii_str_to_bool(val, FALSE);
+
+ val = udev_device_get_property_value(udevice, "ID_NET_MANAGED_BY");
+ if (val) {
+ if (!nm_streq(val, "org.freedesktop.NetworkManager")) {
+ /* There is another manager. UNMANAGED. */
+ return TRUE;
+ }
+ return FALSE;
}
- return FALSE;
+ return NM_OPTION_BOOL_DEFAULT;
}
/**
diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h
index bc5bc5e8b4..81d2b9d6fe 100644
--- a/src/libnm-platform/nm-platform.h
+++ b/src/libnm-platform/nm-platform.h
@@ -1941,9 +1941,9 @@ int nm_platform_link_get_master(NMPlatform *self, int slave);
gboolean nm_platform_link_can_assume(NMPlatform *self, int ifindex);
-gboolean nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex, gboolean *unmanaged);
-gboolean nm_platform_link_supports_slaves(NMPlatform *self, int ifindex);
-const char *nm_platform_link_get_type_name(NMPlatform *self, int ifindex);
+NMOptionBool nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex);
+gboolean nm_platform_link_supports_slaves(NMPlatform *self, int ifindex);
+const char *nm_platform_link_get_type_name(NMPlatform *self, int ifindex);
gboolean nm_platform_link_refresh(NMPlatform *self, int ifindex);
void nm_platform_process_events(NMPlatform *self);