From: Stefano Brivio <sbrivio@redhat.com>
To: Paul Holzinger <pholzing@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] netlink: Skip loopback interface while looking for a template
Date: Thu, 23 Jan 2025 12:53:54 +0100 [thread overview]
Message-ID: <20250123125354.0d25b157@elisabeth> (raw)
In-Reply-To: <07aa7b5d-27b9-4494-88db-d675b7489f68@redhat.com>
On Thu, 23 Jan 2025 12:49:06 +0100
Paul Holzinger <pholzing@redhat.com> wrote:
> On 23/01/2025 09:05, Stefano Brivio wrote:
> > There might be reasons to have routes on the loopback interface, for
> > example Any-IP/AnyIP routes as implemented by Linux kernel commit
> > ab79ad14a2d5 ("ipv6: Implement Any-IP support for IPv6.").
> >
> > If we use the loopback interface as a template, though, we'll pick
> > 'lo' (typically) as interface name for our tap interface, but we'll
> > already have an interface called 'lo' in the target namespace, and as
> > we TUNSETIFF on it, we'll fail with EINVAL, because it's not a tap
> > interface.
> >
> > Skip the loopback interface while looking for a template interface or,
> > more accurately, skip the interface with index 1.
> >
> > Strictly speaking, we should fetch interface flags via RTM_GETLINK
> > instead, and check for IFF_LOOPBACK, but interleaving that request
> > while we're iterating over routes is unnecessarily complicated.
>
> I think hard coding 1 is fine but I think there is also the IFF_LOOPBACK
> flag that could be used instead.
>
> From strace:
> ifi_index=if_nametoindex("lo"),
> ifi_flags=IFF_UP|IFF_LOOPBACK|IFF_RUNNING|IFF_LOWER_UP
Yeah but that's in the link flags, right? Am I missing something? Here
we're looking at routes.
Note that 'ip route show' will also fetch link attributes with
RTM_GETLINK, which is the second netlink query I wanted to avoid here.
--
Stefano
next prev parent reply other threads:[~2025-01-23 11:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 8:05 [PATCH] netlink: Skip loopback interface while looking for a template Stefano Brivio
2025-01-23 11:49 ` Paul Holzinger
2025-01-23 11:53 ` Stefano Brivio [this message]
2025-01-23 12:25 ` Paul Holzinger
2025-01-24 1:48 ` 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=20250123125354.0d25b157@elisabeth \
--to=sbrivio@redhat.com \
--cc=passt-dev@passt.top \
--cc=pholzing@redhat.com \
/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).