public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH] netlink: Strip nexthop identifiers when duplicating routes
Date: Tue, 18 Jun 2024 08:21:12 +0200	[thread overview]
Message-ID: <20240618062112.1519953-1-sbrivio@redhat.com> (raw)

If routing daemons set up host routes, for example FRR via OSPF as in
the reported issue, they might add nexthop identifiers (not objects)
that are generally not valid in the target namespace. Strip them off
as well, otherwise we'll get EINVAL from the kernel.

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

diff --git a/netlink.c b/netlink.c
index 4dbddb2..58822e9 100644
--- a/netlink.c
+++ b/netlink.c
@@ -608,6 +608,15 @@ int nl_route_dup(int s_src, unsigned int ifi_src,
 				 * route invalid in the namespace.  Strip off
 				 * RTA_PREFSRC attributes to avoid that. */
 				rta->rta_type = RTA_UNSPEC;
+			} else if (rta->rta_type == RTA_NH_ID) {
+				/* Host routes set up via routing protocols
+				 * (e.g. OSPF) might contain a nexthop ID (and
+				 * not nexthop objects, which are taken care of
+				 * in the RTA_MULTIPATH case above) that's not
+				 * valid in the target namespace. Strip those as
+				 * well.
+				 */
+				rta->rta_type = RTA_UNSPEC;
 			}
 		}
 
-- 
@@ -608,6 +608,15 @@ int nl_route_dup(int s_src, unsigned int ifi_src,
 				 * route invalid in the namespace.  Strip off
 				 * RTA_PREFSRC attributes to avoid that. */
 				rta->rta_type = RTA_UNSPEC;
+			} else if (rta->rta_type == RTA_NH_ID) {
+				/* Host routes set up via routing protocols
+				 * (e.g. OSPF) might contain a nexthop ID (and
+				 * not nexthop objects, which are taken care of
+				 * in the RTA_MULTIPATH case above) that's not
+				 * valid in the target namespace. Strip those as
+				 * well.
+				 */
+				rta->rta_type = RTA_UNSPEC;
 			}
 		}
 
-- 
2.43.0


             reply	other threads:[~2024-06-18  6:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18  6:21 Stefano Brivio [this message]
2024-06-19  1:22 ` [PATCH] netlink: Strip nexthop identifiers when duplicating routes David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240618062112.1519953-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).