netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@redhat.com>
To: netdev@vger.kernel.org
Cc: dev@openvswitch.org,  Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org,
	 Stefano Brivio <sbrivio@redhat.com>,
	 Eric Dumazet <edumazet@google.com>,
	 linux-kselftest@vger.kernel.org,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,  Shuah Khan <shuah@kernel.org>,
	 "David S. Miller" <davem@davemloft.net>
Subject: Re: [ovs-dev] [PATCH net-next 5/7] selftests: openvswitch: Support implicit ipv6 arguments.
Date: Tue, 18 Jun 2024 12:04:36 -0400	[thread overview]
Message-ID: <f7tr0cujkyz.fsf@redhat.com> (raw)
In-Reply-To: <20240617180218.1154326-6-aconole@redhat.com> (Aaron Conole's message of "Mon, 17 Jun 2024 14:02:16 -0400")

Aaron Conole <aconole@redhat.com> writes:

> The current iteration of IPv6 support requires explicit fields to be set
> in addition to not properly support the actual IPv6 addresses properly.
> With this change, make it so that the ipv6() bare option is usable to
> create wildcarded flows to match broad swaths of ipv6 traffic.
>
> Reviewed-by: Simon Horman <horms@kernel.org>
> Tested-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  .../selftests/net/openvswitch/ovs-dpctl.py    | 42 ++++++++++++-------
>  1 file changed, 27 insertions(+), 15 deletions(-)
>
> diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py
> index 2f16df2fb16b..2062e7e6e99e 100644
> --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py
> +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py
> @@ -200,6 +200,18 @@ def convert_ipv4(data):
>  
>      return int(ipaddress.IPv4Address(ip)), int(ipaddress.IPv4Address(mask))
>  
> +def convert_ipv6(data):
> +    ip, _, mask = data.partition('/')
> +
> +    if not ip:
> +        ip = mask = 0
> +    elif not mask:
> +        mask = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
> +    elif mask.isdigit():
> +        mask = ipaddress.IPv6Network("::/" + mask).hostmask
> +
> +    return ipaddress.IPv6Address(ip).packed, ipaddress.IPv6Address(mask).packed
> +
>  def convert_int(size):
>      def convert_int_sized(data):
>          value, _, mask = data.partition('/')
> @@ -941,21 +953,21 @@ class ovskey(nla):
>                  "src",
>                  "src",
>                  lambda x: str(ipaddress.IPv6Address(x)),
> -                lambda x: int.from_bytes(x, "big"),
> -                lambda x: ipaddress.IPv6Address(x),
> +                lambda x: ipaddress.IPv6Address(x).packed if x else 0,
> +                convert_ipv6,
>              ),
>              (
>                  "dst",
>                  "dst",
>                  lambda x: str(ipaddress.IPv6Address(x)),
> -                lambda x: int.from_bytes(x, "big"),
> -                lambda x: ipaddress.IPv6Address(x),
> +                lambda x: ipaddress.IPv6Address(x).packed if x else 0,
> +                convert_ipv6,
>              ),
> -            ("label", "label", "%d", int),
> -            ("proto", "proto", "%d", int),
> -            ("tclass", "tclass", "%d", int),
> -            ("hlimit", "hlimit", "%d", int),
> -            ("frag", "frag", "%d", int),
> +            ("label", "label", "%d", lambda x: int(x) if x else 0),
> +            ("proto", "proto", "%d", lambda x: int(x) if x else 0),
> +            ("tclass", "tclass", "%d", lambda x: int(x) if x else 0),
> +            ("hlimit", "hlimit", "%d", lambda x: int(x) if x else 0),
> +            ("frag", "frag", "%d", lambda x: int(x) if x else 0),
>          )
>  
>          def __init__(
> @@ -1152,8 +1164,8 @@ class ovskey(nla):
>              (
>                  "target",
>                  "target",
> -                lambda x: str(ipaddress.IPv6Address(x)),
> -                lambda x: int.from_bytes(x, "big"),
> +                lambda x: ipaddress.IPv6Address(x).packed,

This (and the following str() calls) shouldn't have been changed.  I'll
send a v2.  Sorry about the noise.  It isn't visible in this test, but
when doing some additional ipv6 test development for a future series, I
caught it.

> +                convert_ipv6,
>              ),
>              ("sll", "sll", macstr, lambda x: int.from_bytes(x, "big")),
>              ("tll", "tll", macstr, lambda x: int.from_bytes(x, "big")),
> @@ -1237,14 +1249,14 @@ class ovskey(nla):
>              (
>                  "src",
>                  "src",
> -                lambda x: str(ipaddress.IPv6Address(x)),
> -                lambda x: int.from_bytes(x, "big", convertmac),
> +                lambda x: ipaddress.IPv6Address(x).packed,
> +                convert_ipv6,
>              ),
>              (
>                  "dst",
>                  "dst",
> -                lambda x: str(ipaddress.IPv6Address(x)),
> -                lambda x: int.from_bytes(x, "big"),
> +                lambda x: ipaddress.IPv6Address(x).packed,
> +                convert_ipv6,
>              ),
>              ("tp_src", "tp_src", "%d", int),
>              ("tp_dst", "tp_dst", "%d", int),


  reply	other threads:[~2024-06-18 16:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 18:02 [PATCH net-next 0/7] selftests: net: Switch pmtu.sh to use the internal ovs script Aaron Conole
2024-06-17 18:02 ` [PATCH net-next 1/7] selftests: openvswitch: Support explicit tunnel port creation Aaron Conole
2024-06-17 18:02 ` [PATCH net-next 2/7] selftests: openvswitch: Refactor actions parsing Aaron Conole
2024-06-17 18:02 ` [PATCH net-next 3/7] selftests: openvswitch: Add set() and set_masked() support Aaron Conole
2024-06-17 18:02 ` [PATCH net-next 4/7] selftests: openvswitch: Add support for tunnel() key Aaron Conole
2024-06-17 18:02 ` [PATCH net-next 5/7] selftests: openvswitch: Support implicit ipv6 arguments Aaron Conole
2024-06-18 16:04   ` Aaron Conole [this message]
2024-06-17 18:02 ` [PATCH net-next 6/7] selftests: net: Use the provided dpctl rather than the vswitchd for tests Aaron Conole
2024-06-17 18:48   ` Stefano Brivio
2024-06-18 16:02   ` [ovs-dev] " Aaron Conole
2024-06-17 18:02 ` [PATCH net-next 7/7] selftests: net: add config for openvswitch Aaron Conole

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=f7tr0cujkyz.fsf@redhat.com \
    --to=aconole@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbrivio@redhat.com \
    --cc=shuah@kernel.org \
    /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 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 NNTP newsgroup(s).