All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<edumazet@google.com>, <pabeni@redhat.com>,
	<andrew+netdev@lunn.ch>, <horms@kernel.org>, <willemb@google.com>,
	<shuah@kernel.org>, <petrm@nvidia.com>
Subject: Re: [PATCH net-next 1/3] selftests: drv-net: resolve remote interface name
Date: Thu, 13 Feb 2025 15:31:57 +0100	[thread overview]
Message-ID: <87o6z5di4m.fsf@nvidia.com> (raw)
In-Reply-To: <20250213003454.1333711-2-kuba@kernel.org>


Jakub Kicinski <kuba@kernel.org> writes:

> Find out and record in env the name of the interface which remote host
> will use for the IP address provided via config.
>
> Interface name is useful for mausezahn and for setting up tunnels.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  tools/testing/selftests/drivers/net/lib/py/env.py | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py
> index 886b4904613c..fc649797230b 100644
> --- a/tools/testing/selftests/drivers/net/lib/py/env.py
> +++ b/tools/testing/selftests/drivers/net/lib/py/env.py
> @@ -154,6 +154,9 @@ from .remote import Remote
>          self.ifname = self.dev['ifname']
>          self.ifindex = self.dev['ifindex']
>  
> +        # resolve remote interface name
> +        self.remote_ifname = self.resolve_remote_ifc()
> +
>          self._required_cmd = {}
>  
>      def create_local(self):
> @@ -200,6 +203,16 @@ from .remote import Remote
>              raise Exception("Invalid environment, missing configuration:", missing,
>                              "Please see tools/testing/selftests/drivers/net/README.rst")
>  
> +    def resolve_remote_ifc(self):
> +        v4 = v6 = None
> +        if self.remote_v4:
> +            v4 = ip("addr show to " + self.remote_v4, json=True, host=self.remote)
> +        if self.remote_v6:
> +            v6 = ip("addr show to " + self.remote_v6, json=True, host=self.remote)
> +        if v4 and v6 and v4[0]["ifname"] != v6[0]["ifname"]:
> +            raise Exception("Can't resolve remote interface name, v4 and v6 don't match")
> +        return v6[0]["ifname"] if v6 else v4[0]["ifname"]

Is existence of more than one interface with the same IP address a
concern? I guess such configuration is broken and wouldn't come up in a
selftest, but consider throwing in an "len(v4) == len(v6) == 1" for
robustness sake. I guess it could in fact replace the "v4 and v6" bit.

> +
>      def __enter__(self):
>          return self


  reply	other threads:[~2025-02-13 14:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13  0:34 [PATCH net-next 0/3] selftests: drv-net: add a simple TSO test Jakub Kicinski
2025-02-13  0:34 ` [PATCH net-next 1/3] selftests: drv-net: resolve remote interface name Jakub Kicinski
2025-02-13 14:31   ` Petr Machata [this message]
2025-02-13 15:55     ` Jakub Kicinski
2025-02-13 16:23       ` Petr Machata
2025-02-13  0:34 ` [PATCH net-next 2/3] selftests: drv-net: get detailed interface info Jakub Kicinski
2025-02-13 14:39   ` Petr Machata
2025-02-13  0:34 ` [PATCH net-next 3/3] selftests: drv-net: add a simple TSO test Jakub Kicinski
2025-02-13  2:49   ` Stanislav Fomichev
2025-02-13  4:18     ` Jakub Kicinski
2025-02-13 16:02     ` Willem de Bruijn
2025-02-13 17:01       ` Jakub Kicinski
2025-02-13 16:01   ` Willem de Bruijn
2025-02-13 17:07     ` Jakub Kicinski

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=87o6z5di4m.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=willemb@google.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.