mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-14 05:10:35 +01:00
device: merge branch 'th/udev-auto-link-local-only'
https://github.com/systemd/systemd/issues/29768 https://github.com/systemd/systemd/pull/29782 https://github.com/systemd/systemd/pull/29767 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1413 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1414 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1780 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1779
This commit is contained in:
commit
1cf36c9ed7
6 changed files with 114 additions and 48 deletions
6
NEWS
6
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
|
||||
|
|
|
|||
|
|
@ -193,6 +193,42 @@
|
|||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ID_NET_MANAGED_BY</varname></term>
|
||||
<listitem><para>
|
||||
If <varname>NM_UNMANAGED</varname> is set, this has no effect. Otherwise,
|
||||
if the attribute is set to anything but
|
||||
<literal>"org.freedesktop.NetworkManager"</literal>, the device is unmanaged.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>NM_AUTO_DEFAULT_LINK_LOCAL_ONLY</varname></term>
|
||||
<listitem><para>
|
||||
If set to <literal>"1"</literal> or <literal>"true"</literal>, 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.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ID_NET_AUTO_LINK_LOCAL_ONLY</varname></term>
|
||||
<listitem><para>
|
||||
Honored and treated the same as if <varname>NM_AUTO_DEFAULT_LINK_LOCAL_ONLY</varname>
|
||||
were set.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ID_NET_DHCP_BROADCAST</varname></term>
|
||||
<listitem><para>
|
||||
If set to <literal>"1"</literal> or <literal>"true"</literal>, use
|
||||
broadcast requests for DHCPv4 offers. This can make sense of devices
|
||||
that can't handle unicast messages until being configured.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <linux/rtnetlink.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
#include <libudev.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue