[ovs-git] [openvswitch/ovs] 7a5e0e: dpif: Turn dpif_flow_hash function into generic od...

Ilya Maximets noreply at github.com
Wed Jan 8 15:26:06 UTC 2020


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: 7a5e0ee7cc1c8911d3b0085a066facab076647d5
      https://github.com/openvswitch/ovs/commit/7a5e0ee7cc1c8911d3b0085a066facab076647d5
  Author: Ilya Maximets <i.maximets at ovn.org>
  Date:   2020-01-08 (Wed, 08 Jan 2020)

  Changed paths:
    M lib/dpif-netdev.c
    M lib/dpif-netlink.c
    M lib/dpif.c
    M lib/dpif.h
    M lib/odp-util.c
    M lib/odp-util.h
    M ofproto/ofproto-dpif.c

  Log Message:
  -----------
  dpif: Turn dpif_flow_hash function into generic odp_flow_key_hash.

Current implementation of dpif_flow_hash() doesn't depend on datapath
interface and only complicates the callers by forcing them to figure
out what is their current 'dpif'.  If we'll need different hashing
for different 'dpif's we'll implement an API for dpif-providers
and each dpif implementation will be able to use their local function
directly without calling it via dpif API.

This change will allow us to not store 'dpif' pointer in the userspace
datapath implementation which is broken and will be removed in next
commits.

This patch moves dpif_flow_hash() to odp-util module and replaces
unused odp_flow_key_hash() by it, along with removing of unused 'dpif'
argument.

Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>


  Commit: 633486a98e7e2426866b206a65359fb66c0a8363
      https://github.com/openvswitch/ovs/commit/633486a98e7e2426866b206a65359fb66c0a8363
  Author: Ilya Maximets <i.maximets at ovn.org>
  Date:   2020-01-08 (Wed, 08 Jan 2020)

  Changed paths:
    M lib/dpif-netdev.c

  Log Message:
  -----------
  dpif-netdev: Get rid of broken dpif pointer in dp_netdev structure.

This pointer was introduced in July 2014 by commit
6b31e07347ad ("dpif-netdev: Polling threads directly call ofproto upcall functions.")
and it was broken right from this point because dpif_netdev_open()
updates it on each call with the pointer to a newly allocated
'dpif' structure that becomes invalid on the next dpif_netdev_close().
Since dpif_open/close() always happens asynchronously from different
threads and pointer is not protected by rcu or mutex (it's not even
atomic) it's not possible to safely use it.  Thankfully the actual
usage was in repository for less than 3 weeks and was removed by
commit 623540e4617e ("dpif-netdev: Streamline miss handling.").  Until
recently this pointer was used in order to pass it to dpif_flow_hash().
Another luck is that dpif_flow_hash() didn't use the 'dpif' argument.

However, we tried to use it while netdev offloading by commit
30115809da2e ("dpif-netdev: Use netdev-offload API for port lookup while offloading.")
and that unveiled the issue.

Now that all the code that used this pointer was cleaned up we can
just remove it from the structure to avoid possible misuse in the
future.

Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>


Compare: https://github.com/openvswitch/ovs/compare/e988b8abeec9...633486a98e7e


More information about the git mailing list