Skip to contentSkip to conversation

systemd: backport networkd route readiness fix from upstream

PATCH Superseded Akash Hadke 2 participants 2 messages Sep 23 – Oct 1

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd: backport networkd route readiness fix from upstream

From: Akash Hadke <[email protected]>

Backport upstream systemd PR #41000 to v255.22 to fix route handling in systemd-networkd when routes are configured on links that are not yet up.

In 255.21, networkd only checks link readiness when configuring explicit nexthops. Routes using an implicit nexthop can therefore be processed while the bound link is still down, which breaks setups using ConfigureWithoutCarrier= and BindCarrier=. One visible symptom is that static multicast routes are not installed until much later, or are missed entirely, even though the address configuration succeeds.

The upstream fix makes the readiness checks consistent by introducing a common link_is_up() helper, limiting gateway readiness checks to nexthops that are actually bound to a link, and moving the "link must be up" check into the shared gateway readiness path so both explicit and implicit nexthops follow the same logic. Upstream also adds a regression test for issue #40106.

This backport is needed to keep route configuration reliable on carrier-dependent interfaces in our 255.22-based systemd.

Ref: https://github.com/systemd/systemd/pull/41000
https://github.com/systemd/systemd/issues/40106

Tested:
- Built core-image-minimal with INIT_MANAGER = "systemd" on qemux86-64.
- Verified functional test case in QEMU:
* Setup dummy parent (carrier off) and VLAN child with BindCarrier=.
* Verified multicast route remains deferred while carrier is down.
* Verified multicast route installs immediately upon carrier up.
* Verified clean route recovery across carrier toggles.

---
 ...introduce-link_is_up-helper-function.patch | 166 ++++++++++++++++++
 ...ly-when-the-nexthop-is-bound-to-link.patch |  72 ++++++++
 ...nd-to-a-link-requires-the-link-is-up.patch |  57 ++++++
 ...etwork-add-test-case-for-issue-40106.patch | 117 ++++++++++++
 meta/recipes-core/systemd/systemd_255.22.bb   |   4 +
 5 files changed, 416 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0024-network-check-if-gateway-is-ready-only-when-the-nexthop-is-bound-to-link.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0025-network-route-bound-to-a-link-requires-the-link-is-up.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0026-test-network-add-test-case-for-issue-40106.patch
meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch new file +166 -0
new file mode 100644
index 0000000000..04f7963a8a
@@ -0,0 +1,166 @@
+From ec4f646759d6625bbafcd4ce67224fb63b99a96c Mon Sep 17 00:00:00 2001
+From: Yu Watanabe <[email protected]>
+Date: Mon, 9 Mar 2026 10:57:06 +0900
+Subject: [PATCH] network: introduce link_is_up() helper function
+
+Upstream-Status: Backport [https://github.com/systemd/systemd/pull/41000/commits/ec4f646759d6625bbafcd4ce67224fb63b99a96c]
+Comment: Patch is refreshed based on the 255.22 codebase
+Did not pick changes from the below files as it is not matches to our code base.
+src/network/netdev/bond.c
+src/network/networkd-route.c
+
+Signed-off-by: Akash Hadke <[email protected]>
+---
+ src/network/networkd-link.c    | 21 +++++++++++----------
+ src/network/networkd-link.h    |  1 +
+ src/network/networkd-nexthop.c |  4 ++--
+ src/network/networkd-route.c   |  2 +-
+ src/network/networkd-setlink.c | 11 +++++------
+ 6 files changed, 21 insertions(+), 20 deletions(-)
+
+diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
+index e49d5946aa67d..c77b02b8e0192 100644
+--- a/src/network/networkd-link.c
++++ b/src/network/networkd-link.c
+@@ -726,7 +726,6 @@ int link_ipv6ll_gained(Link *link) {
+
+ int link_handle_bound_to_list(Link *link) {
+         bool required_up = false;
+-        bool link_is_up = false;
+         Link *l;
+
+         assert(link);
+@@ -737,18 +736,15 @@ int link_handle_bound_to_list(Link *link) {
+         if (hashmap_isempty(link->bound_to_links))
+                 return 0;
+
+-        if (link->flags & IFF_UP)
+-                link_is_up = true;
+-
+         HASHMAP_FOREACH(l, link->bound_to_links)
+                 if (link_has_carrier(l)) {
+                         required_up = true;
+                         break;
+                 }
+
+-        if (!required_up && link_is_up)
++        if (!required_up && link_is_up(link))
+                 return link_request_to_bring_up_or_down(link, /* up = */ false);
+-        if (required_up && !link_is_up)
++        if (required_up && !link_is_up(link))
+                 return link_request_to_bring_up_or_down(link, /* up = */ true);
+
+         return 0;
+@@ -1736,7 +1732,7 @@ void link_update_operstate(Link *link, bool also_update_master) {
+                         carrier_state = LINK_CARRIER_STATE_ENSLAVED;
+                 else
+                         carrier_state = LINK_CARRIER_STATE_CARRIER;
+-        } else if (link->flags & IFF_UP)
++        } else if (link_is_up(link))
+                 carrier_state = LINK_CARRIER_STATE_NO_CARRIER;
+         else
+                 carrier_state = LINK_CARRIER_STATE_OFF;
+@@ -1867,6 +1863,11 @@ void link_update_operstate(Link *link, bool also_update_master) {
+          ? ((old & flag) ? (" -" string) : (" +" string))        \
+          : "")
+
++bool link_is_up(Link *link) {
++        assert(link);
++        return FLAGS_SET(link->flags, IFF_UP);
++}
++
+ static int link_update_flags(Link *link, sd_netlink_message *message) {
+         bool link_was_admin_up, had_carrier;
+         uint8_t operstate;
+@@ -1930,21 +1931,21 @@ static int link_update_flags(Link *link, sd_netlink_message *message) {
+                         log_link_debug(link, "Unknown link flags lost, ignoring: %#.5x", unknown_flags_removed);
+         }
+
+-        link_was_admin_up = link->flags & IFF_UP;
++        link_was_admin_up = link_is_up(link);
+         had_carrier = link_has_carrier(link);
+
+         link->flags = flags;
+         link->kernel_operstate = operstate;
+
+         link_update_operstate(link, true);
+-
+-        if (!link_was_admin_up && (link->flags & IFF_UP)) {
++	
++        if (!link_was_admin_up && link_is_up(link)) {
+                 log_link_info(link, "Link UP");
+
+                 r = link_admin_state_up(link);
+                 if (r < 0)
+                         return r;
+-        } else if (link_was_admin_up && !(link->flags & IFF_UP)) {
++        } else if (link_was_admin_up && !link_is_up(link)) {
+                 log_link_info(link, "Link DOWN");
+
+                 r = link_admin_state_down(link);
+diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
+index c5b9421bc0b2b..9c641fad39bdb 100644
+--- a/src/network/networkd-link.h
++++ b/src/network/networkd-link.h
+@@ -233,6 +233,7 @@ static inline bool link_has_carrier(Link *link) {
+         assert(link);
+         return netif_has_carrier(link->kernel_operstate, link->flags);
+ }
++bool link_is_up(Link *link);
+
+ bool link_ipv6_enabled(Link *link);
+ int link_ipv6ll_gained(Link *link);
+diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c
+index 5e5f0d0e6858b..23941527cfdcf 100644
+--- a/src/network/networkd-nexthop.c
++++ b/src/network/networkd-nexthop.c
+@@ -526,7 +526,7 @@ static bool nexthop_is_ready_to_configur
+                  * kernel. */
+                 if (link->set_flags_messages > 0)
+                         return false;
+-                if (!FLAGS_SET(link->flags, IFF_UP))
++                if (!link_is_up(link))
+                         return false;
+         }
+ 
+diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c
+index 7069b101f9f55..f5a43788ef792 100644
+--- a/src/network/networkd-setlink.c
++++ b/src/network/networkd-setlink.c
+@@ -486,7 +486,7 @@ static int link_is_ready_to_set_link(Lin
+         case REQUEST_TYPE_SET_LINK_CAN:
+                 /* Do not check link->set_flags_messages here, as it is ok even if link->flags
+                  * is outdated, and checking the counter causes a deadlock. */
+-                if (FLAGS_SET(link->flags, IFF_UP)) {
++                if (link_is_up(link)) {
+                         /* The CAN interface must be down to configure bitrate, etc... */
+                         r = link_down_now(link);
+                         if (r < 0)
+@@ -550,7 +550,7 @@ static int link_is_ready_to_set_link(Lin
+ 
+                 /* Do not check link->set_flags_messages here, as it is ok even if link->flags is outdated,
+                  * and checking the counter causes a deadlock. */
+-                if (link->network->bond && FLAGS_SET(link->flags, IFF_UP)) {
++                if (link->network->bond && link_is_up(link)) {
+                         /* link must be down when joining to bond master. */
+                         r = link_down_now(link);
+                         if (r < 0)
+@@ -649,8 +649,7 @@ int link_request_to_set_addrgen_mode(Lin
+          * link goes down. Hence, we need to reset the interface. However, setting the mode by sysctl
+          * does not need that. Let's use the sysctl interface when the link is already up.
+          * See also issue #22424. */
+-        if (mode != IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE &&
+-            FLAGS_SET(link->flags, IFF_UP)) {
++        if (mode != IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE && link_is_up(link)) {
+                 r = link_set_ipv6ll_addrgen_mode(link, mode);
+                 if (r < 0)
+                         log_link_warning_errno(link, r, "Cannot set IPv6 address generation mode, ignoring: %m");
+@@ -1142,7 +1141,7 @@ static bool link_is_ready_to_bring_up_or
+                 if (link_get_by_index(link->manager, link->dsa_master_ifindex, &master) < 0)
+                         return false;
+ 
+-                if (!FLAGS_SET(master->flags, IFF_UP))
++                if (!link_is_up(master)) 
+                         return false;
+         }
+ 
meta/recipes-core/systemd/systemd/0024-network-check-if-gateway-is-ready-only-when-the-nexthop-is-bound-to-link.patch new file +72 -0

72 lines not on this page · raw message

meta/recipes-core/systemd/systemd/0025-network-route-bound-to-a-link-requires-the-link-is-up.patch new file +57 -0

57 lines not on this page · raw message

meta/recipes-core/systemd/systemd/0026-test-network-add-test-case-for-issue-40106.patch new file +117 -0

117 lines not on this page · raw message

meta/recipes-core/systemd/systemd_255.22.bb +4 -0
index e5a0fd9170..f5e0618def 100644
@@ -37,6 +37,10 @@ SRC_URI += " \
            file://CVE-2026-29111-02.patch \
            file://CVE-2026-29111-03.patch \
            file://CVE-2026-29111-04.patch \
+           file://0023-network-introduce-link_is_up-helper-function.patch \
+           file://0024-network-check-if-gateway-is-ready-only-when-the-nexthop-is-bound-to-link.patch \
+           file://0025-network-route-bound-to-a-link-requires-the-link-is-up.patch \
+           file://0026-test-network-add-test-case-for-issue-40106.patch \
            "
 
 # patches needed by musl
Signature · 1 line
2.43.0
#1 lore raw

Hello,

Quoted 54 lines · Akash Hadke via lists.openembedded.org

From: Akash Hadke <[email protected]>

Backport upstream systemd PR #41000 to v255.22 to fix route handling in systemd-networkd when routes are configured on links that are not yet up.

In 255.21, networkd only checks link readiness when configuring explicit nexthops. Routes using an implicit nexthop can therefore be processed while the bound link is still down, which breaks setups using ConfigureWithoutCarrier= and BindCarrier=. One visible symptom is that static multicast routes are not installed until much later, or are missed entirely, even though the address configuration succeeds.

The upstream fix makes the readiness checks consistent by introducing a common link_is_up() helper, limiting gateway readiness checks to nexthops that are actually bound to a link, and moving the "link must be up" check into the shared gateway readiness path so both explicit and implicit nexthops follow the same logic. Upstream also adds a regression test for issue #40106.

This backport is needed to keep route configuration reliable on carrier-dependent interfaces in our 255.22-based systemd.

Ref: https://github.com/systemd/systemd/pull/41000
https://github.com/systemd/systemd/issues/40106

Tested:
- Built core-image-minimal with INIT_MANAGER = "systemd" on qemux86-64.
- Verified functional test case in QEMU:
* Setup dummy parent (carrier off) and VLAN child with BindCarrier=.
* Verified multicast route remains deferred while carrier is down.
* Verified multicast route installs immediately upon carrier up.
* Verified clean route recovery across carrier toggles.

---
 ...introduce-link_is_up-helper-function.patch | 166 ++++++++++++++++++
 ...ly-when-the-nexthop-is-bound-to-link.patch |  72 ++++++++
 ...nd-to-a-link-requires-the-link-is-up.patch |  57 ++++++
 ...etwork-add-test-case-for-issue-40106.patch | 117 ++++++++++++
 meta/recipes-core/systemd/systemd_255.22.bb   |   4 +
 5 files changed, 416 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0024-network-check-if-gateway-is-ready-only-when-the-nexthop-is-bound-to-link.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0025-network-route-bound-to-a-link-requires-the-link-is-up.patch
 create mode 100644 meta/recipes-core/systemd/systemd/0026-test-network-add-test-case-for-issue-40106.patch
meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch new file +0 -0
new file mode 100644
index 0000000000..04f7963a8a

meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch line 6

Quoted 6 lines
meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch new file +6 -0
@@ -0,0 +1,166 @@
+From ec4f646759d6625bbafcd4ce67224fb63b99a96c Mon Sep 17 00:00:00 2001
+From: Yu Watanabe <[email protected]>
+Date: Mon, 9 Mar 2026 10:57:06 +0900
+Subject: [PATCH] network: introduce link_is_up() helper function
+
+Upstream-Status: Backport [https://github.com/systemd/systemd/pull/41000/commits/ec4f646759d6625bbafcd4ce67224fb63b99a96c]

Can you check if this patch is needed for wrynose as well? If that is the case, then, you will have to send it for wrynose.

meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch line 12

Quoted 6 lines
meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch new file +6 -0
+Comment: Patch is refreshed based on the 255.22 codebase
+Did not pick changes from the below files as it is not matches to our code base.
+src/network/netdev/bond.c
+src/network/networkd-route.c
+
+Signed-off-by: Akash Hadke <[email protected]>

This patch has formating issues (see below):

Quoted 4 lines
meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch new file +4 -0
+---
+ src/network/networkd-link.c    | 21 +++++++++++----------
+ src/network/networkd-link.h    |  1 +
+ src/network/networkd-nexthop.c |  4 ++--

meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch line 26

Quoted 10 lines
meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch new file +10 -0
+ src/network/networkd-route.c   |  2 +-
+ src/network/networkd-setlink.c | 11 +++++------
+ 6 files changed, 21 insertions(+), 20 deletions(-)
+
+diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
+index e49d5946aa67d..c77b02b8e0192 100644
+--- a/src/network/networkd-link.c
++++ b/src/network/networkd-link.c
+@@ -726,7 +726,6 @@ int link_ipv6ll_gained(Link *link) {
+

^ missing a space marking an emtpy context line here

Every other issues:

Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:26 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:31 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:36 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:45 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:52 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:66 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:78 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:82 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:85 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:92 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:99 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.
Error: Malformed patch line at meta/recipes-core/systemd/systemd/0023-network-introduce-link_is_up-helper-function.patch:110 Line content: '\n'
Context lines must start with exactly one space. This line is missing its prefix.

Regards,

Signature · 2 lines
Yoann Congal
Smile ECS