linux-stable/net/openvswitch
Eelco Chaudron 4f592e712e openvswitch: Fix flow lookup to use unmasked key
[ Upstream commit 68bb10101e ]

The commit mentioned below causes the ovs_flow_tbl_lookup() function
to be called with the masked key. However, it's supposed to be called
with the unmasked key. This due to the fact that the datapath supports
installing wider flows, and OVS relies on this behavior. For example
if ipv4(src=1.1.1.1/192.0.0.0, dst=1.1.1.2/192.0.0.0) exists, a wider
flow (smaller mask) of ipv4(src=192.1.1.1/128.0.0.0,dst=192.1.1.2/
128.0.0.0) is allowed to be added.

However, if we try to add a wildcard rule, the installation fails:

$ ovs-appctl dpctl/add-flow system@myDP "in_port(1),eth_type(0x0800), \
  ipv4(src=1.1.1.1/192.0.0.0,dst=1.1.1.2/192.0.0.0,frag=no)" 2
$ ovs-appctl dpctl/add-flow system@myDP "in_port(1),eth_type(0x0800), \
  ipv4(src=192.1.1.1/0.0.0.0,dst=49.1.1.2/0.0.0.0,frag=no)" 2
ovs-vswitchd: updating flow table (File exists)

The reason is that the key used to determine if the flow is already
present in the system uses the original key ANDed with the mask.
This results in the IP address not being part of the (miniflow) key,
i.e., being substituted with an all-zero value. When doing the actual
lookup, this results in the key wrongfully matching the first flow,
and therefore the flow does not get installed.

This change reverses the commit below, but rather than having the key
on the stack, it's allocated.

Fixes: 190aa3e778 ("openvswitch: Fix Frame-size larger than 1024 bytes warning.")

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-07 12:07:29 +01:00
..
Kconfig openvswitch: call only into reachable nf-nat code 2016-03-28 17:58:59 +02:00
Makefile
actions.c openvswitch: Fix setting ipv6 fields causing hw csum failure 2022-03-02 11:32:02 +01:00
conntrack.c openvswitch: handle DNAT tuple collision 2020-10-14 09:48:16 +02:00
conntrack.h
datapath.c openvswitch: Fix flow lookup to use unmasked key 2023-01-07 12:07:29 +01:00
datapath.h openvswitch: fix skb_panic due to the incorrect actions attrlen 2017-08-30 10:21:40 +02:00
dp_notify.c
flow.c openvswitch: vlan: remove wrong likely statement 2016-10-13 10:03:23 -04:00
flow.h openvswitch: use percpu flow stats 2016-09-18 22:14:01 -04:00
flow_netlink.c openvswitch: fix OOB access in reserve_sfa_size() 2022-04-27 13:14:11 +02:00
flow_netlink.h openvswitch: avoid resetting flow key while installing new flow. 2016-09-20 22:54:35 -04:00
flow_table.c openvswitch: use percpu flow stats 2016-09-18 22:14:01 -04:00
flow_table.h
vport-geneve.c openvswitch: do not ignore netdev errors when creating tunnel vports 2016-08-10 23:13:23 -07:00
vport-gre.c openvswitch: do not ignore netdev errors when creating tunnel vports 2016-08-10 23:13:23 -07:00
vport-internal_dev.c net: ovs: fix return type of ndo_start_xmit function 2019-11-25 09:53:15 +01:00
vport-internal_dev.h
vport-netdev.c
vport-netdev.h
vport-vxlan.c openvswitch: do not ignore netdev errors when creating tunnel vports 2016-08-10 23:13:23 -07:00
vport.c openvswitch: fix vlan subtraction from packet length 2016-10-13 10:03:23 -04:00
vport.h