public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] netlink: Drop nexthop state flags from routes we duplicate
@ 2025-09-18 16:33 Stefano Brivio
  2025-09-19  0:33 ` David Gibson
  2025-09-19  9:54 ` Paul Holzinger
  0 siblings, 2 replies; 3+ messages in thread
From: Stefano Brivio @ 2025-09-18 16:33 UTC (permalink / raw)
  To: passt-dev; +Cc: Paul Holzinger

The kernel doesn't like those (EINVAL) on RTM_NEWROUTE, as they are
flags representing states, not configuration.

Link: https://github.com/containers/podman/discussions/27104
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 netlink.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/netlink.c b/netlink.c
index 8f82e73..c436780 100644
--- a/netlink.c
+++ b/netlink.c
@@ -565,6 +565,11 @@ int nl_route_dup(int s_src, unsigned int ifi_src,
 		if (nh->nlmsg_type != RTM_NEWROUTE)
 			continue;
 
+		/* nexthop state flags don't apply to freshly created routes,
+		 * and the kernel will refuse our route if they are set.
+		 */
+		rtm->rtm_flags &= ~RTNH_COMPARE_MASK;
+
 		for (rta = RTM_RTA(rtm), na = RTM_PAYLOAD(nh); RTA_OK(rta, na);
 		     rta = RTA_NEXT(rta, na)) {
 			/* RTA_OIF and RTA_MULTIPATH attributes carry the
-- 
2.43.0


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

* Re: [PATCH] netlink: Drop nexthop state flags from routes we duplicate
  2025-09-18 16:33 [PATCH] netlink: Drop nexthop state flags from routes we duplicate Stefano Brivio
@ 2025-09-19  0:33 ` David Gibson
  2025-09-19  9:54 ` Paul Holzinger
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2025-09-19  0:33 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev, Paul Holzinger

[-- Attachment #1: Type: text/plain, Size: 1281 bytes --]

On Thu, Sep 18, 2025 at 06:33:50PM +0200, Stefano Brivio wrote:
> The kernel doesn't like those (EINVAL) on RTM_NEWROUTE, as they are
> flags representing states, not configuration.
> 
> Link: https://github.com/containers/podman/discussions/27104
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Aha!, nice catch.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  netlink.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/netlink.c b/netlink.c
> index 8f82e73..c436780 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -565,6 +565,11 @@ int nl_route_dup(int s_src, unsigned int ifi_src,
>  		if (nh->nlmsg_type != RTM_NEWROUTE)
>  			continue;
>  
> +		/* nexthop state flags don't apply to freshly created routes,
> +		 * and the kernel will refuse our route if they are set.
> +		 */
> +		rtm->rtm_flags &= ~RTNH_COMPARE_MASK;
> +
>  		for (rta = RTM_RTA(rtm), na = RTM_PAYLOAD(nh); RTA_OK(rta, na);
>  		     rta = RTA_NEXT(rta, na)) {
>  			/* RTA_OIF and RTA_MULTIPATH attributes carry the
> -- 
> 2.43.0
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] netlink: Drop nexthop state flags from routes we duplicate
  2025-09-18 16:33 [PATCH] netlink: Drop nexthop state flags from routes we duplicate Stefano Brivio
  2025-09-19  0:33 ` David Gibson
@ 2025-09-19  9:54 ` Paul Holzinger
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Holzinger @ 2025-09-19  9:54 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev


On 18/09/2025 18:33, Stefano Brivio wrote:
> The kernel doesn't like those (EINVAL) on RTM_NEWROUTE, as they are
> flags representing states, not configuration.
>
> Link: https://github.com/containers/podman/discussions/27104
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Paul Holzinger <pholzing@redhat.com>
> ---
>   netlink.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/netlink.c b/netlink.c
> index 8f82e73..c436780 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -565,6 +565,11 @@ int nl_route_dup(int s_src, unsigned int ifi_src,
>   		if (nh->nlmsg_type != RTM_NEWROUTE)
>   			continue;
>   
> +		/* nexthop state flags don't apply to freshly created routes,
> +		 * and the kernel will refuse our route if they are set.
> +		 */
> +		rtm->rtm_flags &= ~RTNH_COMPARE_MASK;
> +
>   		for (rta = RTM_RTA(rtm), na = RTM_PAYLOAD(nh); RTA_OK(rta, na);
>   		     rta = RTA_NEXT(rta, na)) {
>   			/* RTA_OIF and RTA_MULTIPATH attributes carry the

-- 
Paul Holzinger


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

end of thread, other threads:[~2025-09-19  9:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 16:33 [PATCH] netlink: Drop nexthop state flags from routes we duplicate Stefano Brivio
2025-09-19  0:33 ` David Gibson
2025-09-19  9:54 ` Paul Holzinger

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).