]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
systemd: stop enabling non-standard MAC policy when using the 'pni-names' DISTRO_FEATURE
authorKoen Kooi <koen.kooi@oss.qualcomm.com>
Tue, 2 Sep 2025 09:09:25 +0000 (11:09 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 8 Sep 2025 10:40:07 +0000 (11:40 +0100)
This recipe enabled an additional, non-standard policy for predictable
network names: the MAC policy. This is a deviation from upstream
policies and in cases where no MAC address is available, it makes it
actively worse by changing the name(s) every boot.

Change the logic to disable predictable naming when the DISTRO_FEATURE
isn't enabled and only use upstream logic with it *is* enabled.

For DISTROs that wish to use non-standard policies, a DISTRO layer is the correct place.
E.g. in DISTRO_LAYER/recipes-core/systemd/systemd_%.bbappend:

do_install:append:DISTRO() {
       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
}

Signed-off-by: Koen Kooi <koen.kooi@oss.qualcomm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/systemd/systemd_257.8.bb

index 174372be03c4de678c58a64fad6c16e051805bfd..6399c576409d5910581e1d4d567fb16d89f6b4cf 100644 (file)
@@ -400,15 +400,8 @@ do_install() {
                        ${D}/${sysconfdir}/systemd/system.conf
        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
-       else
-               # Actively disable Predictable Network Interface Names
+       # Actively disable Predictable Network Interface Names
+       if ${@ 'true' if not bb.utils.contains('PACKAGECONFIG', 'pni-names', 'true', 'false', d) else 'false'}; then
                sed -i 's/^NamePolicy=.*/NamePolicy=/;s/^AlternativeNamesPolicy=.*/AlternativeNamesPolicy=/' ${D}${nonarch_libdir}/systemd/network/99-default.link
        fi
 }