public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] systemd: Allow overriding PNI name policies
@ 2025-04-09 10:15 Stefan Eichenberger
  2025-04-10  7:34 ` [OE-core] " Koen Kooi
  2025-04-14 17:03 ` Joshua Watt
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Eichenberger @ 2025-04-09 10:15 UTC (permalink / raw)
  To: openembedded-core; +Cc: Stefan Eichenberger

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(-)

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] systemd: Allow overriding PNI name policies
  2025-04-09 10:15 [PATCH] systemd: Allow overriding PNI name policies Stefan Eichenberger
@ 2025-04-10  7:34 ` Koen Kooi
  2025-04-14 17:03 ` Joshua Watt
  1 sibling, 0 replies; 6+ messages in thread
From: Koen Kooi @ 2025-04-10  7:34 UTC (permalink / raw)
  To: eichest; +Cc: openembedded-core, Stefan Eichenberger



> 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]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] systemd: Allow overriding PNI name policies
  2025-04-09 10:15 [PATCH] systemd: Allow overriding PNI name policies Stefan Eichenberger
  2025-04-10  7:34 ` [OE-core] " Koen Kooi
@ 2025-04-14 17:03 ` Joshua Watt
  2025-04-15  6:56   ` Koen Kooi
  1 sibling, 1 reply; 6+ messages in thread
From: Joshua Watt @ 2025-04-14 17:03 UTC (permalink / raw)
  To: eichest; +Cc: openembedded-core, Stefan Eichenberger

On Wed, Apr 9, 2025 at 4:15 AM Stefan Eichenberger via
lists.openembedded.org <eichest=gmail.com@lists.openembedded.org>
wrote:
>
> 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.

It's very difficult to configured systemd in a way that is acceptable
to everyone, and I'm not sure adding variable "knobs" for every
possible configuration option is feasible for systemd.

You could do the exact same thing by putting your sed command in a
do_install:append() function (since you want to set them from a
bbappend anyway), and in that case it's irrelevant if pni-names is set
in PACKAGECONFIG or not.

>
> 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/3616693
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] systemd: Allow overriding PNI name policies
  2025-04-14 17:03 ` Joshua Watt
@ 2025-04-15  6:56   ` Koen Kooi
  2025-04-15  7:21     ` Stefan Eichenberger
  2025-05-29 20:03     ` Ross Burton
  0 siblings, 2 replies; 6+ messages in thread
From: Koen Kooi @ 2025-04-15  6:56 UTC (permalink / raw)
  To: JPEWhacker; +Cc: eichest, openembedded-core, Stefan Eichenberger



> Op 14 apr 2025, om 19:03 heeft Joshua Watt via lists.openembedded.org <JPEWhacker=gmail.com@lists.openembedded.org> het volgende geschreven:
> 
> On Wed, Apr 9, 2025 at 4:15 AM Stefan Eichenberger via
> lists.openembedded.org <eichest=gmail.com@lists.openembedded.org>
> wrote:
>> 
>> 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.
> 
> It's very difficult to configured systemd in a way that is acceptable
> to everyone, and I'm not sure adding variable "knobs" for every
> possible configuration option is feasible for systemd.

For me, the issue is that OE-core adds the MAC naming feature that upstream has disabled by default, which gives me unpredictable names for various on-SoC network interfaces[1]. Having a way, supported by OE-core, to disable the addition that results in predictable names not being predictable would be great. It would make PNI function as intended :)

> You could do the exact same thing by putting your sed command in a
> do_install:append() function (since you want to set them from a
> bbappend anyway), and in that case it's irrelevant if pni-names is set
> in PACKAGECONFIG or not.

I know and I hate it:

https://github.com/qualcomm-linux/meta-qcom-distro/commit/1820fefb6c67506726277f7f789fd5a4538ea33f

It's fragile and noone on the oe-core side will realize that changing do_install() might break DISTROs that use such bbappend. A proper variable like Stefan proposes would be more obvious and less fragile.

Or we could just drop the bit that adds 'mac' and have DISTROs that want that write a bbappend!

regards,

Koen

[1] The interfaces lacking a MAC in hardware is a separate, but equally frustrating issue.

> 
>> 
>> 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 (#214806): https://lists.openembedded.org/g/openembedded-core/message/214806
> 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]
> -=-=-=-=-=-=-=-=-=-=-=-




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] systemd: Allow overriding PNI name policies
  2025-04-15  6:56   ` Koen Kooi
@ 2025-04-15  7:21     ` Stefan Eichenberger
  2025-05-29 20:03     ` Ross Burton
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Eichenberger @ 2025-04-15  7:21 UTC (permalink / raw)
  To: Koen Kooi; +Cc: JPEWhacker, openembedded-core, Stefan Eichenberger

Hi Joshua and Koen,

On Tue, Apr 15, 2025 at 08:56:26AM +0200, Koen Kooi wrote:
> 
> 
> > Op 14 apr 2025, om 19:03 heeft Joshua Watt via lists.openembedded.org <JPEWhacker=gmail.com@lists.openembedded.org> het volgende geschreven:
> > 
> > On Wed, Apr 9, 2025 at 4:15 AM Stefan Eichenberger via
> > lists.openembedded.org <eichest=gmail.com@lists.openembedded.org>
> > wrote:
> >> 
> >> 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.
> > 
> > It's very difficult to configured systemd in a way that is acceptable
> > to everyone, and I'm not sure adding variable "knobs" for every
> > possible configuration option is feasible for systemd.
> 
> For me, the issue is that OE-core adds the MAC naming feature that upstream has disabled by default, which gives me unpredictable names for various on-SoC network interfaces[1]. Having a way, supported by OE-core, to disable the addition that results in predictable names not being predictable would be great. It would make PNI function as intended :)

This is the exact same issue we have.

> > You could do the exact same thing by putting your sed command in a
> > do_install:append() function (since you want to set them from a
> > bbappend anyway), and in that case it's irrelevant if pni-names is set
> > in PACKAGECONFIG or not.
> 
> I know and I hate it:
> 
> https://github.com/qualcomm-linux/meta-qcom-distro/commit/1820fefb6c67506726277f7f789fd5a4538ea33f
> 
> It's fragile and noone on the oe-core side will realize that changing do_install() might break DISTROs that use such bbappend. A proper variable like Stefan proposes would be more obvious and less fragile.
> 
> Or we could just drop the bit that adds 'mac' and have DISTROs that want that write a bbappend!

I also don't like the sed approach because exactly of what Koen says. I
agree that one of the base problem is that we already modify the policy
and not just use systemds default. If we just remove the "mac" part that
would be good for us as well.

Regards,
Stefan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] systemd: Allow overriding PNI name policies
  2025-04-15  6:56   ` Koen Kooi
  2025-04-15  7:21     ` Stefan Eichenberger
@ 2025-05-29 20:03     ` Ross Burton
  1 sibling, 0 replies; 6+ messages in thread
From: Ross Burton @ 2025-05-29 20:03 UTC (permalink / raw)
  To: openembedded-core@lists.openembedded.org
  Cc: Joshua Watt, koen.kooi@oss.qualcomm.com, eichest@gmail.com,
	Stefan Eichenberger

On 15 Apr 2025, at 07:56, Koen Kooi via lists.openembedded.org <koen.kooi=oss.qualcomm.com@lists.openembedded.org> wrote:
> 
> > It's very difficult to configured systemd in a way that is acceptable
> > to everyone, and I'm not sure adding variable "knobs" for every
> > possible configuration option is feasible for systemd.

My 2c is that I agree with Josh.

I think that we need some helper classes to make it simple to configure systemd at a higher level in a separate recipe, by dropping in configuration fragments and links as needed. This separate recipe could be machine-specific, unlike the systemd recipe itself.  We could then remove the PNI logic from systemd itself (and any other half-attempts at configuration too).

> For me, the issue is that OE-core adds the MAC naming feature that upstream has disabled by default, which gives me unpredictable names for various on-SoC network interfaces[1]. Having a way, supported by OE-core, to disable the addition that results in predictable names not being predictable would be great. It would make PNI function as intended :)

Amusingly, the mac naming was added for some SoCs that don’t have anything else (oe-core 4a7b42fc and 37bd8e8d).  It’s almost like this is a machine-specific configuration that shouldn’t be part of the core systemd recipe at all…

I’m more than half tempted to revert the bulk of the PNI policy patches (leaving just the on/off toggle, without altering the behaviour otherwise), and if someone wants to override them on a per-machine basis then they can, using a per-machine recipe that writes a drop file to /usr/lib/systemd/network/99-default.link.d/pni.conf. 

Ross

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-29 20:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-09 10:15 [PATCH] systemd: Allow overriding PNI name policies Stefan Eichenberger
2025-04-10  7:34 ` [OE-core] " Koen Kooi
2025-04-14 17:03 ` Joshua Watt
2025-04-15  6:56   ` Koen Kooi
2025-04-15  7:21     ` Stefan Eichenberger
2025-05-29 20:03     ` Ross Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox