1. 28 2月, 2017 1 次提交
  2. 24 11月, 2016 1 次提交
    • D
      netfilter: Update ip_route_me_harder to consider L3 domain · 6d8b49c3
      David Ahern 提交于
      ip_route_me_harder is not considering the L3 domain and sending lookups
      to the wrong table. For example consider the following output rule:
      
      iptables -I OUTPUT -p tcp --dport 12345 -j REJECT --reject-with tcp-reset
      
      using perf to analyze lookups via the fib_table_lookup tracepoint shows:
      
      vrf-test  1187 [001] 46887.295927: fib:fib_table_lookup: table 255 oif 0 iif 0 src 0.0.0.0 dst 10.100.1.254 tos 0 scope 0 flags 0
              ffffffff8143922c perf_trace_fib_table_lookup ([kernel.kallsyms])
              ffffffff81493aac fib_table_lookup ([kernel.kallsyms])
              ffffffff8148dda3 __inet_dev_addr_type ([kernel.kallsyms])
              ffffffff8148ddf6 inet_addr_type ([kernel.kallsyms])
              ffffffff8149e344 ip_route_me_harder ([kernel.kallsyms])
      
      and
      
      vrf-test  1187 [001] 46887.295933: fib:fib_table_lookup: table 255 oif 0 iif 1 src 10.100.1.254 dst 10.100.1.2 tos 0 scope 0 flags
              ffffffff8143922c perf_trace_fib_table_lookup ([kernel.kallsyms])
              ffffffff81493aac fib_table_lookup ([kernel.kallsyms])
              ffffffff814998ff fib4_rule_action ([kernel.kallsyms])
              ffffffff81437f35 fib_rules_lookup ([kernel.kallsyms])
              ffffffff81499758 __fib_lookup ([kernel.kallsyms])
              ffffffff8144f010 fib_lookup.constprop.34 ([kernel.kallsyms])
              ffffffff8144f759 __ip_route_output_key_hash ([kernel.kallsyms])
              ffffffff8144fc6a ip_route_output_flow ([kernel.kallsyms])
              ffffffff8149e39b ip_route_me_harder ([kernel.kallsyms])
      
      In both cases the lookups are directed to table 255 rather than the
      table associated with the device via the L3 domain. Update both
      lookups to pull the L3 domain from the dst currently attached to the
      skb.
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      6d8b49c3
  3. 30 9月, 2015 2 次提交
  4. 17 6月, 2015 1 次提交
    • P
      netfilter: don't use module_init/exit in core IPV4 code · 55331060
      Paul Gortmaker 提交于
      The file net/ipv4/netfilter.o is created based on whether
      CONFIG_NETFILTER is set.  However that is defined as a bool, and
      hence this file with the core netfilter hooks will never be
      modular.  So using module_init as an alias for __initcall can be
      somewhat misleading.
      
      Fix this up now, so that we can relocate module_init from
      init.h into module.h in the future.  If we don't do this, we'd
      have to add module.h to obviously non-modular code, and that
      would be a worse thing.  Also add an inclusion of init.h, as
      that was previously implicit here in the netfilter.c file.
      
      Note that direct use of __initcall is discouraged, vs. one
      of the priority categorized subgroups.  As __initcall gets
      mapped onto device_initcall, our use of subsys_initcall (which
      seems to make sense for netfilter code) will thus change this
      registration from level 6-device to level 4-subsys (i.e. slightly
      earlier).  However no observable impact of that small difference
      has been observed during testing, or is expected. (i.e. the
      location of the netfilter messages in dmesg remains unchanged
      with respect to all the other surrounding messages.)
      
      As for the module_exit, rather than replace it with __exitcall,
      we simply remove it, since it appears only UML does anything
      with those, and even for UML, there is no relevant cleanup
      to be done here.
      
      Cc: Pablo Neira Ayuso <pablo@netfilter.org>
      Acked-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Cc: Patrick McHardy <kaber@trash.net>
      Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: netfilter-devel@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      55331060
  5. 05 4月, 2015 1 次提交
  6. 19 2月, 2014 1 次提交
  7. 19 4月, 2013 1 次提交
    • P
      netfilter: add my copyright statements · f229f6ce
      Patrick McHardy 提交于
      Add copyright statements to all netfilter files which have had significant
      changes done by myself in the past.
      
      Some notes:
      
      - nf_conntrack_ecache.c was incorrectly attributed to Rusty and Netfilter
        Core Team when it got split out of nf_conntrack_core.c. The copyrights
        even state a date which lies six years before it was written. It was
        written in 2005 by Harald and myself.
      
      - net/ipv{4,6}/netfilter.c, net/netfitler/nf_queue.c were missing copyright
        statements. I've added the copyright statement from net/netfilter/core.c,
        where this code originated
      
      - for nf_conntrack_proto_tcp.c I've also added Jozsef, since I didn't want
        it to give the wrong impression
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      f229f6ce
  8. 08 4月, 2013 1 次提交
    • P
      netfilter: ipv4: propagate routing errors from ip_route_me_harder() · c9e1673a
      Patrick McHardy 提交于
      Propagate routing errors from ip_route_me_harder() when dropping a packet
      using NF_DROP_ERR(). This makes userspace get the proper error instead of
      EPERM for everything.
      
      Example:
      
      # ip r a unreachable default table 100
      # ip ru add fwmark 0x1 lookup 100
      # iptables -t mangle -A OUTPUT -d 8.8.8.8 -j MARK --set-mark 0x1
      
      Current behaviour:
      
      PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
      ping: sendmsg: Operation not permitted
      ping: sendmsg: Operation not permitted
      ping: sendmsg: Operation not permitted
      
      New behaviour:
      
      PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
      ping: sendmsg: Network is unreachable
      ping: sendmsg: Network is unreachable
      ping: sendmsg: Network is unreachable
      ping: sendmsg: Network is unreachable
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      c9e1673a
  9. 03 9月, 2012 1 次提交
  10. 30 8月, 2012 1 次提交
  11. 21 4月, 2012 1 次提交
  12. 16 4月, 2012 1 次提交
  13. 22 11月, 2011 1 次提交
    • P
      netfilter: possible unaligned packet header in ip_route_me_harder · 5e2afba4
      Paul Guo 提交于
      This patch tries to fix the following issue in netfilter:
      In ip_route_me_harder(), we invoke pskb_expand_head() that
      rellocates new header with additional head room which can break
      the alignment of the original packet header.
      
      In one of my NAT test case, the NIC port for internal hosts is
      configured with vlan and the port for external hosts is with
      general configuration. If we ping an external "unknown" hosts from an
      internal host, an icmp packet will be sent. We find that in
      icmp_send()->...->ip_route_me_harder()->pskb_expand_head(), hh_len=18
      and current headroom (skb_headroom(skb)) of the packet is 16. After
      calling pskb_expand_head() the packet header becomes to be unaligned
      and then our system (arch/tile) panics immediately.
      Signed-off-by: NPaul Guo <ggang@tilera.com>
      Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      5e2afba4
  14. 01 11月, 2011 1 次提交
  15. 08 8月, 2011 1 次提交
    • J
      netfilter: TCP and raw fix for ip_route_me_harder · 797fd391
      Julian Anastasov 提交于
      TCP in some cases uses different global (raw) socket
      to send RST and ACK. The transparent flag is not set there.
      Currently, it is a problem for rerouting after the previous
      change.
      
      	Fix it by simplifying the checks in ip_route_me_harder
      and use FLOWI_FLAG_ANYSRC even for sockets. It looks safe
      because the initial routing allowed this source address to
      be used and now we just have to make sure the packet is rerouted.
      
      	As a side effect this also allows rerouting for normal
      raw sockets that use spoofed source addresses which was not possible
      even before we eliminated the ip_route_input call.
      Signed-off-by: NJulian Anastasov <ja@ssi.bg>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      797fd391
  16. 29 6月, 2011 1 次提交
    • J
      netfilter: Fix ip_route_me_harder triggering ip_rt_bug · ed6e4ef8
      Julian Anastasov 提交于
      	Avoid creating input routes with ip_route_me_harder.
      It does not work for locally generated packets. Instead,
      restrict sockets to provide valid saddr for output route (or
      unicast saddr for transparent proxy). For other traffic
      allow saddr to be unicast or local but if callers forget
      to check saddr type use 0 for the output route.
      
      	The resulting handling should be:
      
      - REJECT TCP:
      	- in INPUT we can provide addr_type = RTN_LOCAL but
      	better allow rejecting traffic delivered with
      	local route (no IP address => use RTN_UNSPEC to
      	allow also RTN_UNICAST).
      	- FORWARD: RTN_UNSPEC => allow RTN_LOCAL/RTN_UNICAST
      	saddr, add fix to ignore RTN_BROADCAST and RTN_MULTICAST
      	- OUTPUT: RTN_UNSPEC
      
      - NAT, mangle, ip_queue, nf_ip_reroute: RTN_UNSPEC in LOCAL_OUT
      
      - IPVS:
      	- use RTN_LOCAL in LOCAL_OUT and FORWARD after SNAT
      	to restrict saddr to be local
      Signed-off-by: NJulian Anastasov <ja@ssi.bg>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ed6e4ef8
  17. 04 4月, 2011 2 次提交
  18. 13 3月, 2011 2 次提交
  19. 03 3月, 2011 2 次提交
  20. 18 11月, 2010 1 次提交
  21. 14 6月, 2010 1 次提交
  22. 11 6月, 2010 1 次提交
  23. 18 5月, 2010 1 次提交
    • E
      net: add a noref bit on skb dst · 7fee226a
      Eric Dumazet 提交于
      Use low order bit of skb->_skb_dst to tell dst is not refcounted.
      
      Change _skb_dst to _skb_refdst to make sure all uses are catched.
      
      skb_dst() returns the dst, regardless of noref bit set or not, but
      with a lockdep check to make sure a noref dst is not given if current
      user is not rcu protected.
      
      New skb_dst_set_noref() helper to set an notrefcounted dst on a skb.
      (with lockdep check)
      
      skb_dst_drop() drops a reference only if skb dst was refcounted.
      
      skb_dst_force() helper is used to force a refcount on dst, when skb
      is queued and not anymore RCU protected.
      
      Use skb_dst_force() in __sk_add_backlog(), __dev_xmit_skb() if
      !IFF_XMIT_DST_RELEASE or skb enqueued on qdisc queue, in
      sock_queue_rcv_skb(), in __nf_queue().
      
      Use skb_dst_force() in dev_requeue_skb().
      
      Note: dst_use_noref() still dirties dst, we might transform it
      later to do one dirtying per jiffies.
      Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7fee226a
  24. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  25. 30 11月, 2009 1 次提交
  26. 12 11月, 2009 1 次提交
    • E
      sysctl net: Remove unused binary sysctl code · f8572d8f
      Eric W. Biederman 提交于
      Now that sys_sysctl is a compatiblity wrapper around /proc/sys
      all sysctl strategy routines, and all ctl_name and strategy
      entries in the sysctl tables are unused, and can be
      revmoed.
      
      In addition neigh_sysctl_register has been modified to no longer
      take a strategy argument and it's callers have been modified not
      to pass one.
      
      Cc: "David Miller" <davem@davemloft.net>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Cc: netdev@vger.kernel.org
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      f8572d8f
  27. 03 6月, 2009 1 次提交
  28. 26 11月, 2008 1 次提交
  29. 25 11月, 2008 1 次提交
  30. 08 10月, 2008 1 次提交
  31. 01 10月, 2008 1 次提交
  32. 14 4月, 2008 1 次提交
  33. 29 1月, 2008 4 次提交