summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kellner <christian@kellner.me>2018-04-19 14:05:52 +0200
committerChristian Kellner <christian@kellner.me>2018-04-19 14:20:04 +0200
commit89af7fbfa6cc4f43446b2f38c3ddd885b5be79f1 (patch)
tree5a0a2a15e1445968a8b4c84f151dbf409ae35ff4
parent8cbce0e18fda921bf0e20b28e9b7a7dd7cdbf9b4 (diff)
all: add support for thunderbolt networking
Load the thunderbolt-net module if we see a host-to-host connection and configure the resulting ethernet connection automatically to be a link-local only one. The latter is done by setting a new udev property "NM_AUTO_DEFAULT_LINK_LOCAL_ONLY" which is picked up when we configure the connection for the device. https://github.com/NetworkManager/NetworkManager/pull/97
-rw-r--r--Makefile.am4
-rw-r--r--data/90-nm-thunderbolt.rules13
-rw-r--r--data/meson.build3
-rw-r--r--src/devices/nm-device-ethernet.c23
4 files changed, 41 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index eb4afde8ca..024559c7c3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3805,7 +3805,8 @@ if WITH_UDEV_DIR
udevrulesdir = $(UDEV_DIR)/rules.d
udevrules_DATA = \
data/84-nm-drivers.rules \
- data/85-nm-unmanaged.rules
+ data/85-nm-unmanaged.rules \
+ data/90-nm-thunderbolt.rules
endif
data/server.conf: $(srcdir)/data/server.conf.in
@@ -3820,6 +3821,7 @@ EXTRA_DIST += \
data/org.freedesktop.NetworkManager.service.in \
data/84-nm-drivers.rules \
data/85-nm-unmanaged.rules \
+ data/90-nm-thunderbolt.rules \
data/server.conf.in \
data/meson.build
diff --git a/data/90-nm-thunderbolt.rules b/data/90-nm-thunderbolt.rules
new file mode 100644
index 0000000000..52d8bb410f
--- /dev/null
+++ b/data/90-nm-thunderbolt.rules
@@ -0,0 +1,13 @@
+# Do not modify this file, it will get overwritten on updates.
+# To override or extend the rules place a file in /etc/udev/rules.d
+
+ACTION!="add", GOTO="nm_thunderbolt_end"
+
+# Load he thunderbolt-net driver if we a device of type thunderbolt_xdomain
+# is added.
+SUBSYSTEM=="thunderbolt", ENV{DEVTYPE}=="thunderbolt_xdomain", RUN{builtin}+="kmod load thunderbolt-net"
+
+# For all thunderbolt network devices, we want to enable link-local configuration
+SUBSYSTEM=="net", ENV{ID_NET_DRIVER}=="thunderbolt-net", ENV{NM_AUTO_DEFAULT_LINK_LOCAL_ONLY}="1"
+
+LABEL="nm_thunderbolt_end"
diff --git a/data/meson.build b/data/meson.build
index e493e5154b..636db92197 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -50,7 +50,8 @@ endif
if install_udev_dir
data = files(
'84-nm-drivers.rules',
- '85-nm-unmanaged.rules'
+ '85-nm-unmanaged.rules',
+ '90-nm-thunderbolt.rules'
)
install_data(
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index eb8620a877..9b46545b98 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -50,6 +50,7 @@
#include "nm-device-factory.h"
#include "nm-core-internal.h"
#include "NetworkManagerUtils.h"
+#include "nm-utils/nm-udev-utils.h"
#include "nm-device-logging.h"
_LOG_DECLARE_SELF(NMDeviceEthernet);
@@ -1436,7 +1437,9 @@ new_default_connection (NMDevice *self)
NMConnection *connection;
NMSettingsConnection *const*connections;
NMSetting *setting;
+ struct udev_device *dev;
const char *perm_hw_addr;
+ const char *uprop = "0";
gs_free char *defname = NULL;
gs_free char *uuid = NULL;
gs_free char *machine_id = NULL;
@@ -1481,6 +1484,26 @@ new_default_connection (NMDevice *self)
g_object_set (setting, NM_SETTING_WIRED_MAC_ADDRESS, perm_hw_addr, NULL);
nm_connection_add_setting (connection, setting);
+ /* 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_udev_utils_property_as_boolean (uprop)) {
+ 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;
}