1. 23 10月, 2012 1 次提交
  2. 09 10月, 2012 1 次提交
  3. 05 10月, 2012 1 次提交
    • E
      ipv4: add a fib_type to fib_info · f4ef85bb
      Eric Dumazet 提交于
      commit d2d68ba9 (ipv4: Cache input routes in fib_info nexthops.)
      introduced a regression for forwarding.
      
      This was hard to reproduce but the symptom was that packets were
      delivered to local host instead of being forwarded.
      
      David suggested to add fib_type to fib_info so that we dont
      inadvertently share same fib_info for different purposes.
      
      With help from Julian Anastasov who provided very helpful
      hints, reproduced here :
      
      <quote>
              Can it be a problem related to fib_info reuse
      from different routes. For example, when local IP address
      is created for subnet we have:
      
      broadcast 192.168.0.255 dev DEV  proto kernel  scope link  src
      192.168.0.1
      192.168.0.0/24 dev DEV  proto kernel  scope link  src 192.168.0.1
      local 192.168.0.1 dev DEV  proto kernel  scope host  src 192.168.0.1
      
              The "dev DEV  proto kernel  scope link  src 192.168.0.1" is
      a reused fib_info structure where we put cached routes.
      The result can be same fib_info for 192.168.0.255 and
      192.168.0.0/24. RTN_BROADCAST is cached only for input
      routes. Incoming broadcast to 192.168.0.255 can be cached
      and can cause problems for traffic forwarded to 192.168.0.0/24.
      So, this patch should solve the problem because it
      separates the broadcast from unicast traffic.
      
              And the ip_route_input_slow caching will work for
      local and broadcast input routes (above routes 1 and 3) just
      because they differ in scope and use different fib_info.
      
      </quote>
      
      Many thanks to Chris Clayton for his patience and help.
      Reported-by: NChris Clayton <chris2553@googlemail.com>
      Bisected-by: NChris Clayton <chris2553@googlemail.com>
      Reported-by: NDave Jones <davej@redhat.com>
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Cc: Julian Anastasov <ja@ssi.bg>
      Tested-by: NChris Clayton <chris2553@googlemail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f4ef85bb
  4. 11 9月, 2012 1 次提交
  5. 01 8月, 2012 3 次提交
    • D
      c5038a83
    • E
      ipv4: percpu nh_rth_output cache · d26b3a7c
      Eric Dumazet 提交于
      Input path is mostly run under RCU and doesnt touch dst refcnt
      
      But output path on forwarding or UDP workloads hits
      badly dst refcount, and we have lot of false sharing, for example
      in ipv4_mtu() when reading rt->rt_pmtu
      
      Using a percpu cache for nh_rth_output gives a nice performance
      increase at a small cost.
      
      24 udpflood test on my 24 cpu machine (dummy0 output device)
      (each process sends 1.000.000 udp frames, 24 processes are started)
      
      before : 5.24 s
      after : 2.06 s
      For reference, time on linux-3.5 : 6.60 s
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Tested-by: NAlexander Duyck <alexander.h.duyck@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d26b3a7c
    • E
      ipv4: Restore old dst_free() behavior. · 54764bb6
      Eric Dumazet 提交于
      commit 404e0a8b (net: ipv4: fix RCU races on dst refcounts) tried
      to solve a race but added a problem at device/fib dismantle time :
      
      We really want to call dst_free() as soon as possible, even if sockets
      still have dst in their cache.
      dst_release() calls in free_fib_info_rcu() are not welcomed.
      
      Root of the problem was that now we also cache output routes (in
      nh_rth_output), we must use call_rcu() instead of call_rcu_bh() in
      rt_free(), because output route lookups are done in process context.
      
      Based on feedback and initial patch from David Miller (adding another
      call_rcu_bh() call in fib, but it appears it was not the right fix)
      
      I left the inet_sk_rx_dst_set() helper and added __rcu attributes
      to nh_rth_output and nh_rth_input to better document what is going on in
      this code.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      54764bb6
  6. 31 7月, 2012 1 次提交
    • E
      net: ipv4: fix RCU races on dst refcounts · 404e0a8b
      Eric Dumazet 提交于
      commit c6cffba4 (ipv4: Fix input route performance regression.)
      added various fatal races with dst refcounts.
      
      crashes happen on tcp workloads if routes are added/deleted at the same
      time.
      
      The dst_free() calls from free_fib_info_rcu() are clearly racy.
      
      We need instead regular dst refcounting (dst_release()) and make
      sure dst_release() is aware of RCU grace periods :
      
      Add DST_RCU_FREE flag so that dst_release() respects an RCU grace period
      before dst destruction for cached dst
      
      Introduce a new inet_sk_rx_dst_set() helper, using atomic_inc_not_zero()
      to make sure we dont increase a zero refcount (On a dst currently
      waiting an rcu grace period before destruction)
      
      rt_cache_route() must take a reference on the new cached route, and
      release it if was not able to install it.
      
      With this patch, my machines survive various benchmarks.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      404e0a8b
  7. 27 7月, 2012 1 次提交
  8. 21 7月, 2012 2 次提交
    • D
      ipv4: Cache input routes in fib_info nexthops. · d2d68ba9
      David S. Miller 提交于
      Caching input routes is slightly simpler than output routes, since we
      don't need to be concerned with nexthop exceptions.  (locally
      destined, and routed packets, never trigger PMTU events or redirects
      that will be processed by us).
      
      However, we have to elide caching for the DIRECTSRC and non-zero itag
      cases.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d2d68ba9
    • D
      ipv4: Cache output routes in fib_info nexthops. · f2bb4bed
      David S. Miller 提交于
      If we have an output route that lacks nexthop exceptions, we can cache
      it in the FIB info nexthop.
      
      Such routes will have DST_HOST cleared because such routes refer to a
      family of destinations, rather than just one.
      
      The sequence of the handling of exceptions during route lookup is
      adjusted to make the logic work properly.
      
      Before we allocate the route, we lookup the exception.
      
      Then we know if we will cache this route or not, and therefore whether
      DST_HOST should be set on the allocated route.
      
      Then we use DST_HOST to key off whether we should store the resulting
      route, during rt_set_nexthop(), in the FIB nexthop cache.
      
      With help from Eric Dumazet.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f2bb4bed
  9. 18 7月, 2012 1 次提交
  10. 17 7月, 2012 1 次提交
    • D
      ipv4: Add FIB nexthop exceptions. · 4895c771
      David S. Miller 提交于
      In a regime where we have subnetted route entries, we need a way to
      store persistent storage about destination specific learned values
      such as redirects and PMTU values.
      
      This is implemented here via nexthop exceptions.
      
      The initial implementation is a 2048 entry hash table with relaiming
      starting at chain length 5.  A more sophisticated scheme can be
      devised if that proves necessary.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4895c771
  11. 11 7月, 2012 1 次提交
  12. 06 7月, 2012 1 次提交
  13. 29 6月, 2012 1 次提交
    • D
      ipv4: Elide fib_validate_source() completely when possible. · 7a9bc9b8
      David S. Miller 提交于
      If rpfilter is off (or the SKB has an IPSEC path) and there are not
      tclassid users, we don't have to do anything at all when
      fib_validate_source() is invoked besides setting the itag to zero.
      
      We monitor tclassid uses with a counter (modified only under RTNL and
      marked __read_mostly) and we protect the fib_validate_source() real
      work with a test against this counter and whether rpfilter is to be
      done.
      
      Having a way to know whether we need no tclassid processing or not
      also opens the door for future optimized rpfilter algorithms that do
      not perform full FIB lookups.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7a9bc9b8
  14. 18 6月, 2012 1 次提交
  15. 24 5月, 2012 1 次提交
    • Y
      ipv4: fix the rcu race between free_fib_info and ip_route_output_slow · e49cc0da
      Yanmin Zhang 提交于
      We hit a kernel OOPS.
      
      <3>[23898.789643] BUG: sleeping function called from invalid context at
      /data/buildbot/workdir/ics/hardware/intel/linux-2.6/arch/x86/mm/fault.c:1103
      <3>[23898.862215] in_atomic(): 0, irqs_disabled(): 0, pid: 10526, name:
      Thread-6683
      <4>[23898.967805] HSU serial 0000:00:05.1: 0000:00:05.2:HSU serial prevented me
      to suspend...
      <4>[23899.258526] Pid: 10526, comm: Thread-6683 Tainted: G        W
      3.0.8-137685-ge7742f9 #1
      <4>[23899.357404] HSU serial 0000:00:05.1: 0000:00:05.2:HSU serial prevented me
      to suspend...
      <4>[23899.904225] Call Trace:
      <4>[23899.989209]  [<c1227f50>] ? pgtable_bad+0x130/0x130
      <4>[23900.000416]  [<c1238c2a>] __might_sleep+0x10a/0x110
      <4>[23900.007357]  [<c1228021>] do_page_fault+0xd1/0x3c0
      <4>[23900.013764]  [<c18e9ba9>] ? restore_all+0xf/0xf
      <4>[23900.024024]  [<c17c007b>] ? napi_complete+0x8b/0x690
      <4>[23900.029297]  [<c1227f50>] ? pgtable_bad+0x130/0x130
      <4>[23900.123739]  [<c1227f50>] ? pgtable_bad+0x130/0x130
      <4>[23900.128955]  [<c18ea0c3>] error_code+0x5f/0x64
      <4>[23900.133466]  [<c1227f50>] ? pgtable_bad+0x130/0x130
      <4>[23900.138450]  [<c17f6298>] ? __ip_route_output_key+0x698/0x7c0
      <4>[23900.144312]  [<c17f5f8d>] ? __ip_route_output_key+0x38d/0x7c0
      <4>[23900.150730]  [<c17f63df>] ip_route_output_flow+0x1f/0x60
      <4>[23900.156261]  [<c181de58>] ip4_datagram_connect+0x188/0x2b0
      <4>[23900.161960]  [<c18e981f>] ? _raw_spin_unlock_bh+0x1f/0x30
      <4>[23900.167834]  [<c18298d6>] inet_dgram_connect+0x36/0x80
      <4>[23900.173224]  [<c14f9e88>] ? _copy_from_user+0x48/0x140
      <4>[23900.178817]  [<c17ab9da>] sys_connect+0x9a/0xd0
      <4>[23900.183538]  [<c132e93c>] ? alloc_file+0xdc/0x240
      <4>[23900.189111]  [<c123925d>] ? sub_preempt_count+0x3d/0x50
      
      Function free_fib_info resets nexthop_nh->nh_dev to NULL before releasing
      fi. Other cpu might be accessing fi. Fixing it by delaying the releasing.
      
      With the patch, we ran MTBF testing on Android mobile for 12 hours
      and didn't trigger the issue.
      
      Thank Eric for very detailed review/checking the issue.
      Signed-off-by: NYanmin Zhang <yanmin_zhang@linux.intel.com>
      Signed-off-by: NKun Jiang <kunx.jiang@intel.com>
      Acked-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e49cc0da
  16. 02 4月, 2012 1 次提交
  17. 29 3月, 2012 1 次提交
  18. 12 3月, 2012 1 次提交
    • J
      net: Convert printks to pr_<level> · 058bd4d2
      Joe Perches 提交于
      Use a more current kernel messaging style.
      
      Convert a printk block to print_hex_dump.
      Coalesce formats, align arguments.
      Use %s, __func__ instead of embedding function names.
      
      Some messages that were prefixed with <foo>_close are
      now prefixed with <foo>_fini.  Some ah4 and esp messages
      are now not prefixed with "ip ".
      
      The intent of this patch is to later add something like
        #define pr_fmt(fmt) "IPv4: " fmt.
      to standardize the output messages.
      
      Text size is trivially reduced. (x86-32 allyesconfig)
      
      $ size net/ipv4/built-in.o*
         text	   data	    bss	    dec	    hex	filename
       887888	  31558	 249696	1169142	 11d6f6	net/ipv4/built-in.o.new
       887934	  31558	 249800	1169292	 11d78c	net/ipv4/built-in.o.old
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      058bd4d2
  19. 17 9月, 2011 1 次提交
  20. 08 5月, 2011 1 次提交
  21. 25 3月, 2011 3 次提交
  22. 13 3月, 2011 3 次提交
  23. 11 3月, 2011 1 次提交
  24. 09 3月, 2011 1 次提交
  25. 08 3月, 2011 3 次提交
  26. 15 2月, 2011 1 次提交
  27. 02 2月, 2011 1 次提交
  28. 01 2月, 2011 2 次提交
    • D
      ipv4: Consolidate all default route selection implementations. · 0c838ff1
      David S. Miller 提交于
      Both fib_trie and fib_hash have a local implementation of
      fib_table_select_default().  This is completely unnecessary
      code duplication.
      
      Since we now remember the fib_table and the head of the fib
      alias list of the default route, we can implement one single
      generic version of this routine.
      
      Looking at the fib_hash implementation you may get the impression
      that it's possible for there to be multiple top-level routes in
      the table for the default route.  The truth is, it isn't, the
      insert code will only allow one entry to exist in the zero
      prefix hash table, because all keys evaluate to zero and all
      keys in a hash table must be unique.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0c838ff1
    • D
      ipv4: Remember FIB alias list head and table in lookup results. · 5b470441
      David S. Miller 提交于
      This will be used later to implement fib_select_default() in a
      completely generic manner, instead of the current situation where the
      default route is re-looked up in the TRIE/HASH table and then the
      available aliases are analyzed.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5b470441
  29. 29 1月, 2011 2 次提交