From ec541c569bd19bbb81791139371111a9a7f1a3d8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 30 Oct 2023 16:53:59 +0100 Subject: [PATCH 1/3] hwdb,rules: mark host-to-host network devices as only requiring link local addressing This is a generalization of this logic: https://github.com/NetworkManager/NetworkManager/blob/main/data/90-nm-thunderbolt.rules It applies not just to thunderbolt, but to any kind of device, even matched by vendor/product, via hwdb. I added two entries for Prolific PC-to-PC devices (of which I have one lying around). --- hwdb.d/82-net-auto-link-local.hwdb | 12 ++++++++++++ rules.d/82-net-auto-link-local.rules | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 hwdb.d/82-net-auto-link-local.hwdb create mode 100644 rules.d/82-net-auto-link-local.rules diff --git a/hwdb.d/82-net-auto-link-local.hwdb b/hwdb.d/82-net-auto-link-local.hwdb new file mode 100644 index 00000000000..4057378f4f2 --- /dev/null +++ b/hwdb.d/82-net-auto-link-local.hwdb @@ -0,0 +1,12 @@ +# This file is part of systemd. + +# Network interfaces for which only Link-Local communication (i.e. IPv4LL, …) +# makes sense, because they almost certainy will point to another host, not an +# internet router. + +# (Note: matches against drivers go into 82-net-auto-link-local.rules instead) + +# Prolific USB-to-USB links (https://www.prolific.com.tw/US/ShowProduct.aspx?pcid=43) +usb:v067Bp25A1* +usb:v067Bp27A1* + ID_NET_AUTO_LINK_LOCAL_ONLY=1 diff --git a/rules.d/82-net-auto-link-local.rules b/rules.d/82-net-auto-link-local.rules new file mode 100644 index 00000000000..88ac7bc1be0 --- /dev/null +++ b/rules.d/82-net-auto-link-local.rules @@ -0,0 +1,15 @@ +# do not edit this file, it will be overwritten on update + +ACTION=="remove", GOTO="net_link_local_end" +SUBSYSTEM!="net", GOTO="net_link_local_end" + +# Network interfaces for which only Link-Local communication (i.e. IPv4LL, …) +# makes sense, because they almost certainy will point to another host, not an +# internet router. + +# (Note: matches against VID/PID go into 82-net-auto-link-local.hwdb instead) + +# Thunderbolt host-to-host connections +DRIVERS=="thunderbolt-net", ENV{ID_NET_AUTO_LINK_LOCAL_ONLY}="1" + +LABEL="net_link_local_end" From e6ba085398866ab05511fe748b8e9f7cbe85148e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 30 Oct 2023 17:12:56 +0100 Subject: [PATCH 2/3] network: add default .network file matching ID_NET_AUTO_LINK_LOCAL_ONLY=1 This is name ".network.example" for now, to match the existing 80-ethernet.network file. I think it would make sense to actually install this by default if told so via a meson file (and then hopefully this would happen even on Fedora, though in a split off RPM or so). However, we aren't there yet, hence for now, just ship the .network files as example, like the others. --- network/80-auto-link-local.network.example | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 network/80-auto-link-local.network.example diff --git a/network/80-auto-link-local.network.example b/network/80-auto-link-local.network.example new file mode 100644 index 00000000000..7f6a14ac419 --- /dev/null +++ b/network/80-auto-link-local.network.example @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: MIT-0 +# +# This example config file is installed as part of systemd. +# It may be freely copied and edited (following the MIT No Attribution license). +# +# To use the file, one of the following methods may be used: +# 1. add a symlink from /etc/systemd/network to the current location of this file, +# 2. copy the file into /etc/systemd/network or one of the other paths checked +# by systemd-networkd and edit it there. +# This file should not be edited in place, because it'll be overwritten on upgrades. + +# Enable IPv4LL + IPv6LL (but no DHCP/IPv6RA) for local links +[Match] +Type=ether +Property=ID_NET_AUTO_LINK_LOCAL_ONLY=1 + +[Network] +LinkLocalAddressing=yes +DHCP=no +IPv6AcceptRA=no +MulticastDNS=yes From 779a1837e5866afaa818ccacda7ceba71c56c0cf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 30 Oct 2023 17:25:18 +0100 Subject: [PATCH 3/3] update TODO --- TODO | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 1d90eefbbb3..ca2c33c72c0 100644 --- a/TODO +++ b/TODO @@ -133,16 +133,11 @@ Deprecations and removals: Features: -* hwdb: add a new field that can be used to mark network devices where only - ipv4ll/ipv6ll makes sense, i.e. which should not expect to be connected to - the internet, i.e. for direct host-to-host connection. Set it for thunderbolt - networking, and for "laplink"-style network cables. Then make netword match - against that prop in a .network file we ship by default. Would be - particularly useful in storage target mode (i.e. NVME-TCP) modes. i.e. do - what https://christian.kellner.me/2018/05/24/thunderbolt-networking-on-linux/ - and - https://github.com/NetworkManager/NetworkManager/blob/main/data/90-nm-thunderbolt.rules#L11 - do for NM, but generically. +* networkd: controlled by build-time options install some of the + *.network.example files we install currently as regular files *.network. For + many cases it's what you want: just configure the damn network. Hopefully + this can be enabled on Fedora even, though into a separate sub-RPM, so that + we don't conflict with NM. * add support for activating nvme-oF devices at boot automatically via kernel cmdline, and maybe even support a syntax such as