datapath: backport: net: add dst_cache support
authorPravin B Shelar <pshelar@ovn.org>
Fri, 8 Jul 2016 04:46:19 +0000 (21:46 -0700)
committerPravin B Shelar <pshelar@ovn.org>
Sat, 9 Jul 2016 02:27:49 +0000 (19:27 -0700)
commitd281b6a9a5e79533042e6647114940ef4ef7d838
tree9558578163d179887f42df63f35dbfedf979998f
parent5a109898bdda855cd8e1d846d2e0981db176f3b4
datapath: backport: net: add dst_cache support

This backports dst-cache implementation from upstream implementation.

    commit 911362c70df5b766c243dc297fadeaced786ffd8
    Author: Paolo Abeni <pabeni@redhat.com>

    net: add dst_cache support
    This patch add a generic, lockless dst cache implementation.
    The need for lock is avoided updating the dst cache fields
    only in per cpu scope, and requiring that the cache manipulation
    functions are invoked with the local bh disabled.

    The refresh_ts and reset_ts fields are used to ensure the cache
    consistency in case of cuncurrent cache update (dst_cache_set*) and
    reset operation (dst_cache_reset).

    Consider the following scenario:

    CPU1:                                       CPU2:
      <cache lookup with emtpy cache: it fails>
      <get dst via uncached route lookup>
                                                <related configuration changes>
                                                dst_cache_reset()
      dst_cache_set()

    The dst entry set passed to dst_cache_set() should not be used
    for later dst cache lookup, because it's obtained using old
    configuration values.

    Since the refresh_ts is updated only on dst_cache lookup, the
    cached value in the above scenario will be discarded on the next
    lookup.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Suggested-and-acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
datapath/linux/Modules.mk
datapath/linux/compat/dst_cache.c [new file with mode: 0644]
datapath/linux/compat/include/linux/percpu.h
datapath/linux/compat/include/net/dst_cache.h [new file with mode: 0644]
datapath/linux/compat/include/net/ip6_fib.h [new file with mode: 0644]
datapath/linux/compat/utils.c