2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

openvswitch.h: Align uAPI definition with the kernel.

Upstream commit:
    commit 1926407a4ab0e59d5a27bed7b82029b356d80fa0
    Author: Ilya Maximets <i.maximets@ovn.org>
    Date:   Wed Mar 9 23:20:33 2022 +0100

    net: openvswitch: fix uAPI incompatibility with existing user space

    Few years ago OVS user space made a strange choice in the commit [1]
    to define types only valid for the user space inside the copy of a
    kernel uAPI header.  '#ifndef __KERNEL__' and another attribute was
    added later.

    This leads to the inevitable clash between user space and kernel types
    when the kernel uAPI is extended.  The issue was unveiled with the
    addition of a new type for IPv6 extension header in kernel uAPI.

    When kernel provides the OVS_KEY_ATTR_IPV6_EXTHDRS attribute to the
    older user space application, application tries to parse it as
    OVS_KEY_ATTR_PACKET_TYPE and discards the whole netlink message as
    malformed.  Since OVS_KEY_ATTR_IPV6_EXTHDRS is supplied along with
    every IPv6 packet that goes to the user space, IPv6 support is fully
    broken.

    Fixing that by bringing these user space attributes to the kernel
    uAPI to avoid the clash.  Strictly speaking this is not the problem
    of the kernel uAPI, but changing it is the only way to avoid breakage
    of the older user space applications at this point.

    These 2 types are explicitly rejected now since they should not be
    passed to the kernel.  Additionally, OVS_KEY_ATTR_TUNNEL_INFO moved
    out from the '#ifdef __KERNEL__' as there is no good reason to hide
    it from the userspace.  And it's also explicitly rejected now, because
    it's for in-kernel use only.

    Comments with warnings were added to avoid the problem coming back.

    (1 << type) converted to (1ULL << type) to avoid integer overflow on
    OVS_KEY_ATTR_IPV6_EXTHDRS, since it equals 32 now.

     [1] beb75a40fd ("userspace: Switching of L3 packets in L2 pipeline")

    Fixes: 28a3f0601727 ("net: openvswitch: IPv6: Add IPv6 extension header support")
    Link: https://lore.kernel.org/netdev/3adf00c7-fe65-3ef4-b6d7-6d8a0cad8a5f@nvidia.com
    Link: beb75a40fd
    Reported-by: Roi Dayan <roid@nvidia.com>
    Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
    Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Acked-by: Aaron Conole <aconole@redhat.com>
    Link: https://lore.kernel.org/r/20220309222033.3018976-1-i.maximets@ovn.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Not adding OVS_KEY_ATTR_IPV6_EXTHDRS in this commit as this is not
necessary.  Will be added along with the actual userspace
implementation.

This change should help avoiding incompatibility issues in the future.

Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Ilya Maximets
2022-03-25 14:48:23 +01:00
parent 9d86459516
commit d96d14b147
5 changed files with 26 additions and 10 deletions

View File

@@ -553,6 +553,7 @@ odp_execute_set_action(struct dp_packet *packet, const struct nlattr *a)
case OVS_KEY_ATTR_CT_ZONE:
case OVS_KEY_ATTR_CT_MARK:
case OVS_KEY_ATTR_CT_LABELS:
case OVS_KEY_ATTR_TUNNEL_INFO:
case __OVS_KEY_ATTR_MAX:
default:
OVS_NOT_REACHED();
@@ -665,6 +666,7 @@ odp_execute_masked_set_action(struct dp_packet *packet,
case OVS_KEY_ATTR_ICMP:
case OVS_KEY_ATTR_ICMPV6:
case OVS_KEY_ATTR_TCP_FLAGS:
case OVS_KEY_ATTR_TUNNEL_INFO:
case __OVS_KEY_ATTR_MAX:
default:
OVS_NOT_REACHED();