diff mbox series

systemd: Allow overriding PNI name policies

Message ID 20250409101545.5936-1-eichest@gmail.com
State New
Headers show
Series systemd: Allow overriding PNI name policies | expand

Commit Message

Stefan Eichenberger April 9, 2025, 10:15 a.m. UTC
From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

Add two new variables, PNI_NAME_POLICY and PNI_ALTNAMES_POLICY, to allow
overriding the default Predictable Network Interface (PNI) name and
alternative name policies respectively.

This allows setting different name policies via a .bbappend file if the
defaults are not suitable for a specific use case.

Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 meta/recipes-core/systemd/systemd_257.4.bb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Koen Kooi April 10, 2025, 7:34 a.m. UTC | #1
> Op 9 apr 2025, om 12:15 heeft Stefan Eichenberger via lists.openembedded.org <eichest=gmail.com@lists.openembedded.org> het volgende geschreven:
> 
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> Add two new variables, PNI_NAME_POLICY and PNI_ALTNAMES_POLICY, to allow
> overriding the default Predictable Network Interface (PNI) name and
> alternative name policies respectively.
> 
> This allows setting different name policies via a .bbappend file if the
> defaults are not suitable for a specific use case.

Nice! This scratches an itch I had for a looooong time now :)

regards,

Koen

> 
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> ---
> meta/recipes-core/systemd/systemd_257.4.bb | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/recipes-core/systemd/systemd_257.4.bb b/meta/recipes-core/systemd/systemd_257.4.bb
> index 24aad11c0a..00edd702fb 100644
> --- a/meta/recipes-core/systemd/systemd_257.4.bb
> +++ b/meta/recipes-core/systemd/systemd_257.4.bb
> @@ -273,6 +273,10 @@ WATCHDOG_TIMEOUT ??= "60"
> # and the watchdog is enabled. (defaults is no hardware watchdog use)
> WATCHDOG_RUNTIME_SEC ??= ""
> 
> +# Predictable network interface name policies
> +PNI_NAME_POLICY ??= "keep kernel database onboard slot path mac"
> +PNI_ALTERNATIVE_NAMES_POLICY ??= "database onboard slot path mac"
> +
> do_install() {
> meson_do_install
> 
> @@ -398,12 +402,8 @@ do_install() {
> fi
> 
> if ${@bb.utils.contains('PACKAGECONFIG', 'pni-names', 'true', 'false', d)}; then
> - if ! grep -q '^NamePolicy=.*mac' ${D}${nonarch_libdir}/systemd/network/99-default.link; then
> - sed -i '/^NamePolicy=/s/$/ mac/' ${D}${nonarch_libdir}/systemd/network/99-default.link
> - fi
> - if ! grep -q 'AlternativeNamesPolicy=.*mac' ${D}${nonarch_libdir}/systemd/network/99-default.link; then
> - sed -i '/AlternativeNamesPolicy=/s/$/ mac/' ${D}${nonarch_libdir}/systemd/network/99-default.link
> - fi
> + sed -i 's/^NamePolicy=.*/NamePolicy=${PNI_NAME_POLICY}/' ${D}${nonarch_libdir}/systemd/network/99-default.link
> + sed -i 's/^AlternativeNamesPolicy=.*/AlternativeNamesPolicy=${PNI_ALTERNATIVE_NAMES_POLICY}/' ${D}${nonarch_libdir}/systemd/network/99-default.link
> else
> # Actively disable Predictable Network Interface Names
> sed -i 's/^NamePolicy=.*/NamePolicy=/;s/^AlternativeNamesPolicy=.*/AlternativeNamesPolicy=/' ${D}${nonarch_libdir}/systemd/network/99-default.link
> -- 
> 2.45.2
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#214582): https://lists.openembedded.org/g/openembedded-core/message/214582
> Mute This Topic: https://lists.openembedded.org/mt/112169516/9418801
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [koen.kooi@oss.qualcomm.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd_257.4.bb b/meta/recipes-core/systemd/systemd_257.4.bb
index 24aad11c0a..00edd702fb 100644
--- a/meta/recipes-core/systemd/systemd_257.4.bb
+++ b/meta/recipes-core/systemd/systemd_257.4.bb
@@ -273,6 +273,10 @@  WATCHDOG_TIMEOUT ??= "60"
 # and the watchdog is enabled. (defaults is no hardware watchdog use)
 WATCHDOG_RUNTIME_SEC ??= ""
 
+# Predictable network interface name policies
+PNI_NAME_POLICY ??= "keep kernel database onboard slot path mac"
+PNI_ALTERNATIVE_NAMES_POLICY ??= "database onboard slot path mac"
+
 do_install() {
 	meson_do_install
 
@@ -398,12 +402,8 @@  do_install() {
 	fi
 
 	if ${@bb.utils.contains('PACKAGECONFIG', 'pni-names', 'true', 'false', d)}; then
-		if ! grep -q '^NamePolicy=.*mac' ${D}${nonarch_libdir}/systemd/network/99-default.link; then
-			sed -i '/^NamePolicy=/s/$/ mac/' ${D}${nonarch_libdir}/systemd/network/99-default.link
-		fi
-		if ! grep -q 'AlternativeNamesPolicy=.*mac' ${D}${nonarch_libdir}/systemd/network/99-default.link; then
-			sed -i '/AlternativeNamesPolicy=/s/$/ mac/' ${D}${nonarch_libdir}/systemd/network/99-default.link
-		fi
+		sed -i 's/^NamePolicy=.*/NamePolicy=${PNI_NAME_POLICY}/' ${D}${nonarch_libdir}/systemd/network/99-default.link
+		sed -i 's/^AlternativeNamesPolicy=.*/AlternativeNamesPolicy=${PNI_ALTERNATIVE_NAMES_POLICY}/' ${D}${nonarch_libdir}/systemd/network/99-default.link
 	else
 		# Actively disable Predictable Network Interface Names
 		sed -i 's/^NamePolicy=.*/NamePolicy=/;s/^AlternativeNamesPolicy=.*/AlternativeNamesPolicy=/' ${D}${nonarch_libdir}/systemd/network/99-default.link