1. 25 1月, 2017 4 次提交
  2. 24 1月, 2017 10 次提交
    • D
      bpf, lpm: fix kfree of im_node in trie_update_elem · d140199a
      Daniel Borkmann 提交于
      We need to initialize im_node to NULL, otherwise in case of error path
      it gets passed to kfree() as uninitialized pointer.
      
      Fixes: b95a5c4d ("bpf: add a longest prefix match trie map implementation")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d140199a
    • D
      Merge branch 'bpf-lpm' · 2acc76cb
      David S. Miller 提交于
      Daniel Mack says:
      
      ====================
      bpf: add longest prefix match map
      
      This patch set adds a longest prefix match algorithm that can be used
      to match IP addresses to a stored set of ranges. It is exposed as a
      bpf map type.
      
      Internally, data is stored in an unbalanced tree of nodes that has a
      maximum height of n, where n is the prefixlen the trie was created
      with.
      
      Note that this has nothing to do with fib or fib6 and is in no way meant
      to replace or share code with it. It's rather a much simpler
      implementation that is specifically written with bpf maps in mind.
      
      Patch 1/2 adds the implementation, 2/2 an extensive test suite and 3/3
      has benchmarking code for the new trie type.
      
      Feedback is much appreciated.
      
      Changelog:
      
      v3 -> v4:
      	* David added a 3rd patch that augments map_perf_test for
      	  LPM trie benchmarks
      	* Limit allocation of maps of this new type to CAP_SYS_ADMIN
      	  for now, as requested by Alexei
      	* Add a stub .map_delete_elem so the core does not stumble
      	  over a NULL pointer when the syscall is invoked
      	* Tests for non-power-of-2 prefix lengths were added
      	* More comment style fixes
      
      v2 -> v3:
      	* Store both the key match data and the caller provided
      	  value in the same byte array attached to a node. This
      	  avoids double allocations
      	* Bring back node->flags to distinguish between 'real'
      	  and intermediate nodes
      	* Fix comment style and some typos
      
      v1 -> v2:
      	* Turn spin lock into raw spinlock
      	* Lock with irqsave options during trie_update_elem()
      	* Return -ENOMEM properly from trie_alloc()
      	* Force attr->flags == BPF_F_NO_PREALLOC during creation
      	* Set trie->map.pages after creation to account for map memory
      	* Allow arbitrary value sizes
      	* Removed node->flags and denode intermediate nodes through
      	  node->value == NULL instead
      
      rfc -> v1:
      	* Add __rcu pointer annotations to make sparse happy
      	* Fold _lpm_trie_find_target_node() into its only caller
      	* Fix some minor documentation issues
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2acc76cb
    • D
      samples/bpf: add lpm-trie benchmark · b8a943e2
      David Herrmann 提交于
      Extend the map_perf_test_{user,kern}.c infrastructure to stress test
      lpm-trie lookups. We hook into the kprobe on sys_gettid() and measure
      the latency depending on trie size and lookup count.
      
      On my Intel Haswell i7-6400U, a single gettid() syscall with an empty
      bpf program takes roughly 6.5us on my system. Lookups in empty tries
      take ~1.8us on first try, ~0.9us on retries. Lookups in tries with 8192
      entries take ~7.1us (on the first _and_ any subsequent try).
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Mack <daniel@zonque.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b8a943e2
    • D
      bpf: Add tests for the lpm trie map · 4d3381f5
      David Herrmann 提交于
      The first part of this program runs randomized tests against the
      lpm-bpf-map. It implements a "Trivial Longest Prefix Match" (tlpm)
      based on simple, linear, single linked lists. The implementation
      should be pretty straightforward.
      
      Based on tlpm, this inserts randomized data into bpf-lpm-maps and
      verifies the trie-based bpf-map implementation behaves the same way
      as tlpm.
      
      The second part uses 'real world' IPv4 and IPv6 addresses and tests
      the trie with those.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDaniel Mack <daniel@zonque.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4d3381f5
    • D
      bpf: add a longest prefix match trie map implementation · b95a5c4d
      Daniel Mack 提交于
      This trie implements a longest prefix match algorithm that can be used
      to match IP addresses to a stored set of ranges.
      
      Internally, data is stored in an unbalanced trie of nodes that has a
      maximum height of n, where n is the prefixlen the trie was created
      with.
      
      Tries may be created with prefix lengths that are multiples of 8, in
      the range from 8 to 2048. The key used for lookup and update operations
      is a struct bpf_lpm_trie_key, and the value is a uint64_t.
      
      The code carries more information about the internal implementation.
      Signed-off-by: NDaniel Mack <daniel@zonque.org>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b95a5c4d
    • B
      net: xilinx: constify net_device_ops structure · 10eeb5e6
      Bhumika Goyal 提交于
      Declare net_device_ops structure as const as it is only stored in
      the netdev_ops field of a net_device structure. This field is of type
      const, so net_device_ops structures having same properties can be made
      const too.
      Done using Coccinelle:
      
      @r1 disable optional_qualifier@
      identifier i;
      position p;
      @@
      static struct net_device_ops i@p={...};
      
      @ok1@
      identifier r1.i;
      position p;
      struct net_device ndev;
      @@
      ndev.netdev_ops=&i@p
      
      @bad@
      position p!={r1.p,ok1.p};
      identifier r1.i;
      @@
      i@p
      
      @depends on !bad disable optional_qualifier@
      identifier r1.i;
      @@
      +const
      struct net_device_ops i;
      
      File size before:
         text	   data	    bss	    dec	    hex	filename
         6201	    744	      0	   6945	   1b21 ethernet/xilinx/xilinx_emaclite.o
      
      File size after:
         text	   data	    bss	    dec	    hex	filename
         6745	    192	      0	   6937	   1b19 ethernet/xilinx/xilinx_emaclite.o
      Signed-off-by: NBhumika Goyal <bhumirks@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      10eeb5e6
    • B
      net: moxa: constify net_device_ops structures · 30bd2f52
      Bhumika Goyal 提交于
      Declare net_device_ops structure as const as it is only stored in
      the netdev_ops field of a net_device structure. This field is of type
      const, so net_device_ops structures having same properties can be made
      const too.
      Done using Coccinelle:
      
      @r1 disable optional_qualifier@
      identifier i;
      position p;
      @@
      static struct net_device_ops i@p={...};
      
      @ok1@
      identifier r1.i;
      position p;
      struct net_device ndev;
      @@
      ndev.netdev_ops=&i@p
      
      @bad@
      position p!={r1.p,ok1.p};
      identifier r1.i;
      @@
      i@p
      
      @depends on !bad disable optional_qualifier@
      identifier r1.i;
      @@
      +const
      struct net_device_ops i;
      
      File size before:
         text	   data	    bss	    dec	    hex	filename
         4821	    744	      0	   5565	   15bd ethernet/moxa/moxart_ether.o
      
      File size after:
         text	   data	    bss	    dec	    hex	filename
         5373	    192	      0	   5565	   15bd ethernet/moxa/moxart_ether.o
      Signed-off-by: NBhumika Goyal <bhumirks@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      30bd2f52
    • T
      net: qcom/emac: claim the irq only when the device is opened · 4404323c
      Timur Tabi 提交于
      During reset, functions emac_mac_down() and emac_mac_up() are called,
      so we don't want to free and claim the IRQ unnecessarily.  Move those
      operations to open/close.
      Signed-off-by: NTimur Tabi <timur@codeaurora.org>
      Reviewed-by: NLino Sanfilippo <LinoSanfilippo@gmx.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4404323c
    • T
      net: qcom/emac: rename emac_phy to emac_sgmii and move it · 41c1093f
      Timur Tabi 提交于
      The EMAC has an internal PHY that is often called the "SGMII".  This
      SGMII is also connected to an external PHY, which is managed by phylib.
      These dual PHYs often cause confusion.  In this case, the data structure
      for managing the SGMII was mis-named and located in the wrong header file.
      
      Structure emac_phy is renamed to emac_sgmii to clearly indicate it applies
      to the internal PHY only.  It also also moved from emac_phy.h (which
      supports the external PHY) to emac_sgmii.h (where it belongs).
      
      To keep the changes minimal, only the structure name is changed, not
      the names of any variables of that type.
      Signed-off-by: NTimur Tabi <timur@codeaurora.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      41c1093f
    • E
      bnx2x: avoid two atomic ops per page on x86 · b9032741
      Eric Dumazet 提交于
      Commit 4cace675 ("bnx2x: Alloc 4k fragment for each rx ring buffer
      element") added extra put_page() and get_page() calls on arches where
      PAGE_SIZE=4K like x86
      
      Reorder things to avoid this overhead.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Cc: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
      Cc: Yuval Mintz <Yuval.Mintz@cavium.com>
      Cc: Ariel Elior <ariel.elior@cavium.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b9032741
  3. 23 1月, 2017 15 次提交
  4. 21 1月, 2017 11 次提交