All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@redhat.com>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org,  dev@openvswitch.org,
	linux-kernel@vger.kernel.org,  Ilya Maximets <i.maximets@ovn.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] [RFC net-next 4/7] selftests: openvswitch: Add support for tunnel() key.
Date: Mon, 17 Jun 2024 13:56:46 -0400	[thread overview]
Message-ID: <f7t7cenmp0h.fsf@redhat.com> (raw)
In-Reply-To: <20240616162743.GJ8447@kernel.org> (Simon Horman's message of "Sun, 16 Jun 2024 17:27:43 +0100")

Simon Horman <horms@kernel.org> writes:

> On Thu, Jun 13, 2024 at 02:13:30PM -0400, Aaron Conole wrote:
>> This will be used when setting details about the tunnel to use as
>> transport.  There is a difference between the ODP format between tunnel():
>> the 'key' flag is not actually a flag field, so we don't support it in the
>> same way that the vswitchd userspace supports displaying it.
>> 
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>
> ...
>
>> @@ -1265,6 +1265,165 @@ class ovskey(nla):
>>                  init=init,
>>              )
>>  
>> +    class ovs_key_tunnel(nla):
>> +        nla_flags = NLA_F_NESTED
>> +
>> +        nla_map = (
>> +            ("OVS_TUNNEL_KEY_ATTR_ID", "be64"),
>> +            ("OVS_TUNNEL_KEY_ATTR_IPV4_SRC", "ipaddr"),
>> +            ("OVS_TUNNEL_KEY_ATTR_IPV4_DST", "ipaddr"),
>> +            ("OVS_TUNNEL_KEY_ATTR_TOS", "uint8"),
>> +            ("OVS_TUNNEL_KEY_ATTR_TTL", "uint8"),
>> +            ("OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT", "flag"),
>> +            ("OVS_TUNNEL_KEY_ATTR_CSUM", "flag"),
>> +            ("OVS_TUNNEL_KEY_ATTR_OAM", "flag"),
>> +            ("OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS", "array(uint32)"),
>> +            ("OVS_TUNNEL_KEY_ATTR_TP_SRC", "be16"),
>> +            ("OVS_TUNNEL_KEY_ATTR_TP_DST", "be16"),
>> +            ("OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS", "none"),
>> +            ("OVS_TUNNEL_KEY_ATTR_IPV6_SRC", "ipaddr"),
>> +            ("OVS_TUNNEL_KEY_ATTR_IPV6_DST", "ipaddr"),
>> +            ("OVS_TUNNEL_KEY_ATTR_PAD", "none"),
>> +            ("OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS", "none"),
>> +            ("OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE", "flag"),
>> +        )
>> +
>> +        def parse(self, flowstr, mask=None):
>> +            if not flowstr.startswith("tunnel("):
>> +                return None, None
>> +
>> +            k = ovskey.ovs_key_tunnel()
>> +            if mask is not None:
>> +                mask = ovskey.ovs_key_tunnel()
>> +
>> +            flowstr = flowstr[len("tunnel("):]
>> +
>> +            v6_address = None
>> +
>> +            fields = [
>> +                ("tun_id=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_ID",
>> +                 0xffffffffffffffff, None, None),
>> +
>> +                ("src=", r"([0-9a-fA-F\.]+)", str,
>> +                 "OVS_TUNNEL_KEY_ATTR_IPV4_SRC", "255.255.255.255", "0.0.0.0",
>> +                 False),
>> +                ("dst=", r"([0-9a-fA-F\.]+)", str,
>> +                 "OVS_TUNNEL_KEY_ATTR_IPV4_DST", "255.255.255.255", "0.0.0.0",
>> +                 False),
>> +
>> +                ("ipv6_src=", r"([0-9a-fA-F:]+)", str,
>> +                 "OVS_TUNNEL_KEY_ATTR_IPV6_SRC",
>> +                 "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "::", True),
>> +                ("ipv6_dst=", r"([0-9a-fA-F:]+)", str,
>> +                 "OVS_TUNNEL_KEY_ATTR_IPV6_DST",
>> +                 "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "::", True),
>> +
>> +                ("tos=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_TOS", 255, 0,
>> +                 None),
>> +                ("ttl=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_TTL", 255, 0,
>> +                 None),
>> +
>> +                ("tp_src=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_TP_SRC",
>> +                 65535, 0, None),
>> +                ("tp_dst=", r"(\d+)", int, "OVS_TUNNEL_KEY_ATTR_TP_DST",
>> +                 65535, 0, None),
>> +            ]
>> +
>> +            forced_include = ["OVS_TUNNEL_KEY_ATTR_TTL"]
>> +
>> +            for prefix, regex, typ, attr_name, mask_val, default_val, v46_flag in fields:
>> +                flowstr, value = parse_extract_field(flowstr, prefix, regex, typ, False)
>> +                if not attr_name:
>> +                    raise Exception("Bad list value in tunnel fields")
>> +
>> +                if value is None and attr_name in forced_include:
>> +                    value = default_val
>> +                    mask_val = default_val
>> +
>> +                if value is not None:
>> +                    if v6_address is None and v46_flag is not None:
>> +                        v6_address = v46_flag
>
> By my reading, at this point v6_address will only be None if v46_flag is
> not None.  IF so, the condition below seems excessive.

Agreed - thanks for the suggestions.

>> +                    if v6_address is not None and v46_flag is not None \
>> +                       and v46_flag != v6_address:
>> +                        raise ValueError("Cannot mix v6 and v4 addresses")
>
> I wonder if we can instead express this as (completely untested!):
>
>                     if v46_flag is not None:
>                         if v6_address is None:
>                             v6_address = v46_flag
>                         if v46_flag != v6_address:
>                             raise ValueError("Cannot mix v6 and v4 addresses")
>
>> +                    k["attrs"].append([attr_name, value])
>> +                    if mask is not None:
>> +                        mask["attrs"].append([attr_name, mask_val])
>> +                else:
>> +                    if v6_address is not None and v46_flag is not None \
>> +                       and v46_flag != v6_address:
>> +                        continue
>> +                    if v6_address is None and v46_flag is not None:
>> +                        continue
>
> And I wonder if this is a bit easier on the eyes (also completely untested):
>
>                     if v46_flag is not None:
>                         if v6_address is None or v46_flag != v6_address:
>                             continue

I folded both of these in and did some quick testing.  Thanks Simon!

>> +                    if mask is not None:
>> +                        mask["attrs"].append([attr_name, default_val])
>> +
>> +            if k["attrs"][0][0] != "OVS_TUNNEL_KEY_ATTR_ID":
>> +                raise ValueError("Needs a tunid set")
>
> ...
>
>> @@ -1745,7 +1905,7 @@ class OvsVport(GenericNetlinkSocket):
>>          )
>>  
>>          TUNNEL_DEFAULTS = [("geneve", 6081),
>> -                           ("vxlan", 4798)]
>> +                           ("vxlan", 4789)]
>>  
>>          for tnl in TUNNEL_DEFAULTS:
>>              if ptype == tnl[0]:
>
> As noted in my response to PATCH 1/7, I think that the
> change in the hunk above belongs there rather than here.


  reply	other threads:[~2024-06-17 17:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 18:13 [RFC net-next 0/7] selftests: net: Switch pmtu.sh to use the internal ovs script Aaron Conole
2024-06-13 18:13 ` [RFC net-next 1/7] selftests: openvswitch: Support explicit tunnel port creation Aaron Conole
2024-06-16 16:25   ` [ovs-dev] " Simon Horman
2024-06-17 17:03     ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 2/7] selftests: openvswitch: Refactor actions parsing Aaron Conole
2024-06-16 16:29   ` [ovs-dev] " Simon Horman
2024-06-13 18:13 ` [RFC net-next 3/7] selftests: openvswitch: Add set() and set_masked() support Aaron Conole
2024-06-16 16:29   ` [ovs-dev] " Simon Horman
2024-06-17 12:18   ` Adrián Moreno
2024-06-17 17:07     ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 4/7] selftests: openvswitch: Add support for tunnel() key Aaron Conole
2024-06-16 16:27   ` [ovs-dev] " Simon Horman
2024-06-17 17:56     ` Aaron Conole [this message]
2024-06-13 18:13 ` [RFC net-next 5/7] selftests: openvswitch: Support implicit ipv6 arguments Aaron Conole
2024-06-16 16:28   ` [ovs-dev] " Simon Horman
2024-06-17 17:03     ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 6/7] selftests: net: Use the provided dpctl rather than the vswitchd for tests Aaron Conole
2024-06-13 20:37   ` Stefano Brivio
2024-06-14 15:53     ` Aaron Conole
2024-06-13 18:13 ` [RFC net-next 7/7] selftests: net: add config for openvswitch Aaron Conole
2024-06-16 16:30   ` [ovs-dev] " Simon Horman

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=f7t7cenmp0h.fsf@redhat.com \
    --to=aconole@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.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 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.