DHCP configuration via networkd
cover DHCP configuration via networkd
This small series removes the current limitation of not allowing the user to have a network interface configured automatically via DHCP when systemd-networkd is used.
To do so, the systemd package is updated to generate a .network file for the configured interface.
Also add an option to enable or disable predictable network interface names when udev is used. It is disabled by default, so the end user gets the same interface names across busybox/systemd configurations.
Eric Le Bihan (3):
systemd: configure DHCP via networkd
system: allow auto net configuration with networkd
system: enable predictable net interface names
package/skeleton/skeleton.mk | 11 +++++++++++ package/systemd/systemd.mk | 13 +++++++++++++ system/Config.in | 20 ++++++++++++++------ 3 files changed, 38 insertions(+), 6 deletions(-)
Signature · 1 line
2.4.11
RFC PATCH 1/3 systemd: configure DHCP via networkd
If systemd-networkd is enabled and $BR2_SYSTEM_DHCP is set, then create a .network file to configure the selected network interface via DHCP.
--- package/systemd/systemd.mk | 13 +++++++++++++ 1 file changed, 13 insertions(+)
package/systemd/systemd.mk +13 -0
@@ -275,6 +275,18 @@ define SYSTEMD_INSTALL_RESOLVCONF_HOOK ln -sf ../run/systemd/resolve/resolv.conf \ $(TARGET_DIR)/etc/resolv.conf endef +SYSTEMD_NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP)) +ifneq ($(SYSTEMD_NETWORK_DHCP_IFACE),) +define SYSTEMD_INSTALL_NETWORK_CONFS + ( \ + echo "[Match]"; \ + echo "Name=$(SYSTEMD_NETWORK_DHCP_IFACE)"; \ + echo; \ + echo "[Network]"; \ + echo "DHCP=ipv4"; \ + ) > $(TARGET_DIR)/etc/systemd/network/dhcp.network +endef +endif else SYSTEMD_CONF_OPTS += --disable-networkd define SYSTEMD_INSTALL_SERVICE_NETWORK
@@ -377,6 +389,7 @@ define SYSTEMD_INSTALL_INIT_SYSTEMD $(SYSTEMD_INSTALL_SERVICE_TTY) $(SYSTEMD_INSTALL_SERVICE_NETWORK) $(SYSTEMD_INSTALL_SERVICE_TIMESYNC) + $(SYSTEMD_INSTALL_NETWORK_CONFS) endef $(eval $(autotools-package))
Signature · 1 line
2.4.11
RFC PATCH 1/3 systemd: configure DHCP via networkd
Hello,
(Adding in Cc more people interested in systemd)
Quoted 4 lines · Eric Le Bihan
If systemd-networkd is enabled and $BR2_SYSTEM_DHCP is set, then create a .network file to configure the selected network interface via DHCP.
Signed-off-by Eric Le Bihan <[email protected]>
The idea looks good to me, so unless the people interested in systemd raise their voice, I'm going to apply something like this. However, I have one suggestion below.
Quoted 13 lines
--- package/systemd/systemd.mk | 13 +++++++++++++ 1 file changed, 13 insertions(+)package/systemd/systemd.mk +1
-0@@ -275,6 +275,18 @@ define SYSTEMD_INSTALL_RESOLVCONF_HOOK ln -sf ../run/systemd/resolve/resolv.conf \ $(TARGET_DIR)/etc/resolv.conf endef +SYSTEMD_NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
package/systemd/systemd.mk define SYSTEMD_INSTALL_RESOLVCONF_HOOK · line 288
Quoted 10 lines
package/systemd/systemd.mk +10
-0+ifneq ($(SYSTEMD_NETWORK_DHCP_IFACE),) +define SYSTEMD_INSTALL_NETWORK_CONFS + ( \ + echo "[Match]"; \ + echo "Name=$(SYSTEMD_NETWORK_DHCP_IFACE)"; \ + echo; \ + echo "[Network]"; \ + echo "DHCP=ipv4"; \ + ) > $(TARGET_DIR)/etc/systemd/network/dhcp.network +endef
I find having all those echo lines in the middle of the .mk file not very pretty. What about instead:
package/systemd/dhcp.network containing:
[Match]
Name=SYSTEMD_NETWORK_DHCP_IFACE
[Network]
DHCP=ipv4
package/systemd/systemd.mk doing:
define SYSTEMD_INSTALL_NETWORK_CONF
sed s/SYSTEMD_NETWORK_DHCP_IFACE/$(SYSTEMD_NETWORK_DHCP_IFACE)/ \ package/systemd/dhcp.network > \ $(TARGET_DIR)/etc/systemd/network/dhcp.network
endef
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Thomas Petazzoni
AppliedRFC PATCH 1/3 systemd: configure DHCP via networkd
In reply to Eric Le BihanHello,
Quoted 7 lines · Eric Le Bihan
If systemd-networkd is enabled and $BR2_SYSTEM_DHCP is set, then create a .network file to configure the selected network interface via DHCP.
Signed-off-by Eric Le Bihan <[email protected]>--- package/systemd/systemd.mk | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Applied to master, with the change I suggested a while ago (i.e generate the file from a template).
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
RFC PATCH 2/3 system: allow auto net configuration with networkd
In reply to Eric Le BihanAllow automatic network configuration via systemd-networkd if selected.
--- system/Config.in | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
system/Config.in +3 -6
@@ -365,7 +365,7 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW config BR2_SYSTEM_DHCP string "Network interface to configure through DHCP" default "" - depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && (BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN) + depends on (BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || BR2_PACKAGE_SYSTEMD_NETWORKD) help Enter here the name of the network interface (E.G. eth0) to automatically configure through DHCP at bootup.
@@ -375,11 +375,8 @@ config BR2_SYSTEM_DHCP For more complicated network setups use an overlay to overwrite /etc/network/interfaces or add a networkd configuration file. -comment "automatic network configuration via DHCP is not compatible with networkd" - depends on BR2_PACKAGE_SYSTEMD_NETWORKD - -comment "automatic network configuration via DHCP needs ifupdown or busybox" - depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN) +comment "automatic network configuration via DHCP needs ifupdown or busybox or networkd" + depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || BR2_PACKAGE_SYSTEMD_NETWORKD) endif # BR2_ROOTFS_SKELETON_DEFAULT
Signature · 1 line
2.4.11
RFC PATCH 2/3 system: allow auto net configuration with networkd
Hello,
Quoted 3 lines · Eric Le Bihan
Allow automatic network configuration via systemd-networkd if selected.
Signed-off-by Eric Le Bihan <[email protected]>
Looks good to me, with one possible suggestion.
system/Config.in config BR2_SYSTEM_DHCP · line 379
Quoted 4 lines
system/Config.in +2
-2-comment "automatic network configuration via DHCP needs ifupdown or busybox" - depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN) +comment "automatic network configuration via DHCP needs ifupdown or busybox or networkd" + depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || BR2_PACKAGE_SYSTEMD_NETWORKD)
I think I'd remove this comment entirely, I'm not sure it's very useful.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
RFC PATCH 2/3 system: allow auto net configuration with networkd
In reply to Eric Le BihanHello,
Quoted 6 lines · Eric Le Bihan
Allow automatic network configuration via systemd-networkd if selected.
Signed-off-by Eric Le Bihan <[email protected]>--- system/Config.in | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
I've applied, but in fact squashed into the previous patch as it really is the same change.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
RFC PATCH 3/3 system: enable predictable net interface names
In reply to Eric Le BihanSince v197, udev and eudev automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces.
This is a departure from the traditional interface naming scheme (eth0, eth1, etc).
Add a configuration option to enable or disable this feature, which is disabled by default to be coherent with the behavior set when udev is not used.
See https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
for details.
--- package/skeleton/skeleton.mk | 11 +++++++++++ system/Config.in | 11 +++++++++++ 2 files changed, 22 insertions(+)
package/skeleton/skeleton.mk +11 -0
@@ -242,6 +242,17 @@ endif TARGET_FINALIZE_HOOKS += SKELETON_REMOUNT_RW endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV +ifeq ($(BR2_SYSTEM_PREDICTABLE_NETIF_NAMES),y) +define SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + rm -f $(TARGET_DIR)/etc/udev/rules.d/80-net-setup-links.rules +endef +else +define SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + touch $(TARGET_DIR)/etc/udev/rules.d/80-net-setup-links.rules +endef +endif +TARGET_FINALIZE_HOOKS += SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + endif # BR2_ROOTFS_SKELETON_DEFAULT $(eval $(generic-package))
system/Config.in +11 -0
@@ -172,6 +172,17 @@ endchoice comment "/dev management using udev (from systemd)" depends on BR2_INIT_SYSTEMD +config BR2_SYSTEM_PREDICTABLE_NETIF_NAMES + bool "Predictable network interface names" + depends on BR2_PACKAGE_HAS_UDEV + default n + help + udev can assign predictable, stable network interface names for all + local Ethernet, WLAN and WWAN interfaces. This is a departure from + the traditional interface naming scheme (eth0, eth1, etc). + + Say yes to active this naming scheme. + config BR2_ROOTFS_DEVICE_TABLE string "Path to the permission tables" default "system/device_table.txt"
Signature · 1 line
2.4.11
RFC PATCH 3/3 system: enable predictable net interface names
Hello,
Quoted 7 lines · Eric Le Bihan
Since v197, udev and eudev automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces.
This is a departure from the traditional interface naming scheme (eth0, eth1, etc).
Quoted 8 lines
Add a configuration option to enable or disable this feature, which is disabled by default to be coherent with the behavior set when udev is not used.
See https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
for details.Signed-off-by Eric Le Bihan <[email protected]>
While I am happy with the principles of patches 1/3 and 2/3, I'm a lot less convinced by this one. Indeed, the "System configuration" menu already has a good number of options, and I'm not a fan of adding yet another option for just a relatively minor system configuration detail. I'd prefer to leave this to per-project customization through post-build scripts, and just use the upstream default (i.e predictable interface names).
I'll keep this patch in patchwork for some time in order to allow others to raise their voice. I've also Cc'ed a bunch of people so they can give their opinion.
package/skeleton/skeleton.mk endif · line 251
Quoted 7 lines
package/skeleton/skeleton.mk +7
-0+ifeq ($(BR2_SYSTEM_PREDICTABLE_NETIF_NAMES),y) +define SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + rm -f $(TARGET_DIR)/etc/udev/rules.d/80-net-setup-links.rules +endef +else +define SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + touch $(TARGET_DIR)/etc/udev/rules.d/80-net-setup-links.rules
Why are you touching the file here?
system/Config.in endchoice · line 178
Quoted 4 lines
system/Config.in +4
-0+config BR2_SYSTEM_PREDICTABLE_NETIF_NAMES + bool "Predictable network interface names" + depends on BR2_PACKAGE_HAS_UDEV + default n
"default n" is never needed: the default for an option is to be disabled.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
RFC PATCH 3/3 system: enable predictable net interface names
In reply to Eric Le BihanOn Sat, Sep 17, 2016 at 1:58 PM, Eric Le Bihan
<[email protected]> wrote:
Hi and sorry for the slow response.
Quoted 3 lines
Since v197, udev and eudev automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces.
Are you sure about eudev? I don't seem to find any references to that rules file (or anything related) in eudev-3.2.1.
Quoted 9 lines
This is a departure from the traditional interface naming scheme (eth0, eth1, etc).
Add a configuration option to enable or disable this feature, which is disabled by default to be coherent with the behavior set when udev is not used.
See https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
for details.
This document talks about adding a symlink to /dev/null from /etc/systemd/network/99-default.link, but that is not what you are doing. Why?
Quoted 7 lines
package/skeleton/skeleton.mk +0
-0@@ -242,6 +242,17 @@ endif TARGET_FINALIZE_HOOKS += SKELETON_REMOUNT_RW endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
package/skeleton/skeleton.mk endif · line 253
Quoted 10 lines
package/skeleton/skeleton.mk +9
-0+ifeq ($(BR2_SYSTEM_PREDICTABLE_NETIF_NAMES),y) +define SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + rm -f $(TARGET_DIR)/etc/udev/rules.d/80-net-setup-links.rules +endef +else +define SKELETON_MANAGE_PREDITABLE_NETIF_NAMES + touch $(TARGET_DIR)/etc/udev/rules.d/80-net-setup-links.rules +endef +endif
I take it that the idea is for this file to "shadow" a file of the same name in /lib/udev/rules? Looking in systemd-232 there is only a 80-net-setup-link.rules file (link not links)?
If it all boils down to it being a systemd specific option that can be handled by a single symlink in an overlay/post-build script, then I don't think it is worth to have it.
Signature · 1 line
Bye, Peter Korsgaard
RFC PATCH 3/3 system: enable predictable net interface names
Hello,
Quoted 3 lines · Peter Korsgaard
If it all boils down to it being a systemd specific option that can be handled by a single symlink in an overlay/post-build script, then I don't think it is worth to have it.
Considering the lack of feedback from Eric on the topic, I've marked his patch as Rejected in patchwork.
Please do not hesitate to resubmit with a better explanation that answers the questions asked during the review. Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com