1. 16 4月, 2020 1 次提交
    • W
      netfilter: Avoid assigning 'const' pointer to non-const pointer · 514cc55b
      Will Deacon 提交于
      nf_remove_net_hook() uses WRITE_ONCE() to assign a 'const' pointer to a
      'non-const' pointer. Cleanups to the implementation of WRITE_ONCE() mean
      that this will give rise to a compiler warning, just like a plain old
      assignment would do:
      
        | In file included from ./include/linux/export.h:43,
        |                  from ./include/linux/linkage.h:7,
        |                  from ./include/linux/kernel.h:8,
        |                  from net/netfilter/core.c:9:
        | net/netfilter/core.c: In function ‘nf_remove_net_hook’:
        | ./include/linux/compiler.h:216:30: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
        |   *(volatile typeof(x) *)&(x) = (val);  \
        |                               ^
        | net/netfilter/core.c:379:3: note: in expansion of macro ‘WRITE_ONCE’
        |    WRITE_ONCE(orig_ops[i], &dummy_ops);
        |    ^~~~~~~~~~
      
      Follow the pattern used elsewhere in this file and add a cast to 'void *'
      to squash the warning.
      
      Cc: Pablo Neira Ayuso <pablo@netfilter.org>
      Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
      Cc: Florian Westphal <fw@strlen.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      514cc55b
  2. 19 3月, 2020 1 次提交
  3. 18 3月, 2020 1 次提交
    • L
      netfilter: Introduce egress hook · 8537f786
      Lukas Wunner 提交于
      Commit e687ad60 ("netfilter: add netfilter ingress hook after
      handle_ing() under unique static key") introduced the ability to
      classify packets on ingress.
      
      Allow the same on egress.  Position the hook immediately before a packet
      is handed to tc and then sent out on an interface, thereby mirroring the
      ingress order.  This order allows marking packets in the netfilter
      egress hook and subsequently using the mark in tc.  Another benefit of
      this order is consistency with a lot of existing documentation which
      says that egress tc is performed after netfilter hooks.
      
      Egress hooks already exist for the most common protocols, such as
      NF_INET_LOCAL_OUT or NF_ARP_OUT, and those are to be preferred because
      they are executed earlier during packet processing.  However for more
      exotic protocols, there is currently no provision to apply netfilter on
      egress.  A common workaround is to enslave the interface to a bridge and
      use ebtables, or to resort to tc.  But when the ingress hook was
      introduced, consensus was that users should be given the choice to use
      netfilter or tc, whichever tool suits their needs best:
      https://lore.kernel.org/netdev/20150430153317.GA3230@salvia/
      This hook is also useful for NAT46/NAT64, tunneling and filtering of
      locally generated af_packet traffic such as dhclient.
      
      There have also been occasional user requests for a netfilter egress
      hook in the past, e.g.:
      https://www.spinics.net/lists/netfilter/msg50038.html
      
      Performance measurements with pktgen surprisingly show a speedup rather
      than a slowdown with this commit:
      
      * Without this commit:
        Result: OK: 34240933(c34238375+d2558) usec, 100000000 (60byte,0frags)
        2920481pps 1401Mb/sec (1401830880bps) errors: 0
      
      * With this commit:
        Result: OK: 33997299(c33994193+d3106) usec, 100000000 (60byte,0frags)
        2941410pps 1411Mb/sec (1411876800bps) errors: 0
      
      * Without this commit + tc egress:
        Result: OK: 39022386(c39019547+d2839) usec, 100000000 (60byte,0frags)
        2562631pps 1230Mb/sec (1230062880bps) errors: 0
      
      * With this commit + tc egress:
        Result: OK: 37604447(c37601877+d2570) usec, 100000000 (60byte,0frags)
        2659259pps 1276Mb/sec (1276444320bps) errors: 0
      
      * With this commit + nft egress:
        Result: OK: 41436689(c41434088+d2600) usec, 100000000 (60byte,0frags)
        2413320pps 1158Mb/sec (1158393600bps) errors: 0
      
      Tested on a bare-metal Core i7-3615QM, each measurement was performed
      three times to verify that the numbers are stable.
      
      Commands to perform a measurement:
      modprobe pktgen
      echo "add_device lo@3" > /proc/net/pktgen/kpktgend_3
      samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh -i 'lo@3' -n 100000000
      
      Commands for testing tc egress:
      tc qdisc add dev lo clsact
      tc filter add dev lo egress protocol ip prio 1 u32 match ip dst 4.3.2.1/32
      
      Commands for testing nft egress:
      nft add table netdev t
      nft add chain netdev t co \{ type filter hook egress device lo priority 0 \; \}
      nft add rule netdev t co ip daddr 4.3.2.1/32 drop
      
      All testing was performed on the loopback interface to avoid distorting
      measurements by the packet handling in the low-level Ethernet driver.
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      8537f786
  4. 17 10月, 2019 1 次提交
  5. 04 7月, 2019 1 次提交
  6. 01 6月, 2019 1 次提交
  7. 15 5月, 2019 1 次提交
  8. 12 4月, 2019 1 次提交
    • F
      bridge: netfilter: unroll NF_HOOK helper in bridge input path · 971502d7
      Florian Westphal 提交于
      Replace NF_HOOK() based invocation of the netfilter hooks with a private
      copy of nf_hook_slow().
      
      This copy has one difference: it can return the rx handler value expected
      by the stack, i.e. RX_HANDLER_CONSUMED or RX_HANDLER_PASS.
      
      This is needed by the next patch to invoke the ebtables
      "broute" table via the standard netfilter hooks rather than the custom
      "br_should_route_hook" indirection that is used now.
      
      When the skb is to be "brouted", we must return RX_HANDLER_PASS from the
      bridge rx input handler, but there is no way to indicate this via
      NF_HOOK(), unless perhaps by some hack such as exposing bridge_cb in the
      netfilter core or a percpu flag.
      
        text    data     bss     dec   filename
        3369      56       0    3425   net/bridge/br_input.o.before
        3458      40       0    3498   net/bridge/br_input.o.after
      
      This allows removal of the "br_should_route_hook" in the next patch.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Acked-by: NNikolay Aleksandrov <nikolay@cumulusnetworks.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      971502d7
  9. 06 1月, 2019 1 次提交
    • M
      jump_label: move 'asm goto' support test to Kconfig · e9666d10
      Masahiro Yamada 提交于
      Currently, CONFIG_JUMP_LABEL just means "I _want_ to use jump label".
      
      The jump label is controlled by HAVE_JUMP_LABEL, which is defined
      like this:
      
        #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
        # define HAVE_JUMP_LABEL
        #endif
      
      We can improve this by testing 'asm goto' support in Kconfig, then
      make JUMP_LABEL depend on CC_HAS_ASM_GOTO.
      
      Ugly #ifdef HAVE_JUMP_LABEL will go away, and CONFIG_JUMP_LABEL will
      match to the real kernel capability.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Tested-by: NSedat Dilek <sedat.dilek@gmail.com>
      e9666d10
  10. 11 7月, 2018 1 次提交
    • T
      netfilter: Add nf_ct_get_tuple_skb global lookup function · b60a6040
      Toke Høiland-Jørgensen 提交于
      This adds a global netfilter function to extract a conntrack tuple from an
      skb. The function uses a new function added to nf_ct_hook, which will try
      to get the tuple from skb->_nfct, and do a full lookup if that fails. This
      makes it possible to use the lookup function before the skb has passed
      through the conntrack init hooks (e.g., in an ingress qdisc). The tuple is
      copied to the caller to avoid issues with reference counting.
      
      The function returns false if conntrack is not loaded, allowing it to be
      used without incurring a module dependency on conntrack. This is used by
      the NAT mode in sch_cake.
      
      Cc: netfilter-devel@vger.kernel.org
      Signed-off-by: NToke Høiland-Jørgensen <toke@toke.dk>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b60a6040
  11. 23 5月, 2018 4 次提交
  12. 08 5月, 2018 1 次提交
  13. 28 3月, 2018 1 次提交
  14. 13 2月, 2018 1 次提交
  15. 10 1月, 2018 2 次提交
  16. 09 1月, 2018 13 次提交
  17. 09 9月, 2017 1 次提交
  18. 28 8月, 2017 3 次提交
  19. 19 7月, 2017 1 次提交
  20. 17 7月, 2017 1 次提交
  21. 01 5月, 2017 2 次提交