1. 01 3月, 2019 3 次提交
  2. 27 2月, 2019 2 次提交
    • F
      netfilter: nat: merge nf_nat_ipv4,6 into nat core · 3bf195ae
      Florian Westphal 提交于
      before:
         text    data     bss     dec     hex filename
        16566    1576    4136   22278    5706 nf_nat.ko
         3598	    844	      0	   4442	   115a	nf_nat_ipv6.ko
         3187	    844	      0	   4031	    fbf	nf_nat_ipv4.ko
      
      after:
         text    data     bss     dec     hex filename
        22948    1612    4136   28696    7018 nf_nat.ko
      
      ... with ipv4/v6 nat now provided directly via nf_nat.ko.
      
      Also changes:
             ret = nf_nat_ipv4_fn(priv, skb, state);
             if (ret != NF_DROP && ret != NF_STOLEN &&
      into
      	if (ret != NF_ACCEPT)
      		return ret;
      
      everywhere.
      
      The nat hooks never should return anything other than
      ACCEPT or DROP (and the latter only in rare error cases).
      
      The original code uses multi-line ANDing including assignment-in-if:
              if (ret != NF_DROP && ret != NF_STOLEN &&
                 !(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) &&
                  (ct = nf_ct_get(skb, &ctinfo)) != NULL) {
      
      I removed this while moving, breaking those in separate conditionals
      and moving the assignments into extra lines.
      
      checkpatch still generates some warnings:
       1. Overly long lines (of moved code).
          Breaking them is even more ugly. so I kept this as-is.
       2. use of extern function declarations in a .c file.
          This is necessary evil, we must call
          nf_nat_l3proto_register() from the nat core now.
          All l3proto related functions are removed later in this series,
          those prototypes are then removed as well.
      
      v2: keep empty nf_nat_ipv6_csum_update stub for CONFIG_IPV6=n case.
      v3: remove IS_ENABLED(NF_NAT_IPV4/6) tests, NF_NAT_IPVx toggles
          are removed here.
      v4: also get rid of the assignments in conditionals.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      3bf195ae
    • F
      netfilter: nat: merge ipv4 and ipv6 masquerade functionality · d1aca8ab
      Florian Westphal 提交于
      Before:
         text	   data	    bss	    dec	    hex	filename
        13916	   1412	   4128	  19456	   4c00	nf_nat.ko
         4510	    968	      4	   5482	   156a	nf_nat_ipv4.ko
         5146	    944	      8	   6098	   17d2	nf_nat_ipv6.ko
      
      After:
         text	   data	    bss	    dec	    hex	filename
        16566	   1576	   4136	  22278	   5706	nf_nat.ko
         3187	    844	      0	   4031	    fbf	nf_nat_ipv4.ko
         3598	    844	      0	   4442	   115a	nf_nat_ipv6.ko
      
      ... so no drastic changes in combined size.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      d1aca8ab
  3. 18 1月, 2019 1 次提交
    • F
      netfilter: conntrack: gre: switch module to be built-in · 22fc4c4c
      Florian Westphal 提交于
      This makes the last of the modular l4 trackers 'bool'.
      
      After this, all infrastructure to handle dynamic l4 protocol registration
      becomes obsolete and can be removed in followup patches.
      
      Old:
      302824 net/netfilter/nf_conntrack.ko
       21504 net/netfilter/nf_conntrack_proto_gre.ko
      
      New:
      313728 net/netfilter/nf_conntrack.ko
      
      Old:
         text	   data	    bss	    dec	    hex	filename
         6281	   1732	      4	   8017	   1f51	nf_conntrack_proto_gre.ko
       108356	  20613	    236	 129205	  1f8b5	nf_conntrack.ko
      New:
       112095	  21381	    240	 133716	  20a54	nf_conntrack.ko
      
      The size increase is only temporary.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      22fc4c4c
  4. 18 12月, 2018 1 次提交
    • F
      netfilter: nat: remove l4proto->manip_pkt · faec18db
      Florian Westphal 提交于
      This removes the last l4proto indirection, the two callers, the l3proto
      packet mangling helpers for ipv4 and ipv6, now call the
      nf_nat_l4proto_manip_pkt() helper.
      
      nf_nat_proto_{dccp,tcp,sctp,gre,icmp,icmpv6} are left behind, even though
      they contain no functionality anymore to not clutter this patch.
      
      Next patch will remove the empty files and the nf_nat_l4proto
      struct.
      
      nf_nat_proto_udp.c is renamed to nf_nat_proto.c, as it now contains the
      other nat manip functionality as well, not just udp and udplite.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      faec18db
  5. 17 9月, 2018 1 次提交
  6. 24 8月, 2018 1 次提交
  7. 04 8月, 2018 3 次提交
  8. 30 7月, 2018 3 次提交
  9. 17 7月, 2018 2 次提交
    • M
      netfilter: Kconfig: Change select IPv6 dependencies · 5d400a49
      Máté Eckl 提交于
      ... from IPV6 to NF_TABLES_IPV6 and IP6_NF_IPTABLES.
      
      In some cases module selects depend on IPV6, but this means that they
      select another module even if eg. NF_TABLES_IPV6 is not set in which
      case the selected module is useless due to the lack of IPv6 nf_tables
      functionality.
      
      The same applies for IP6_NF_IPTABLES and iptables.
      
      Joint work with: Arnd Bermann <arnd@arndb.de>
      Signed-off-by: NMáté Eckl <ecklm94@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      5d400a49
    • F
      netfilter: conntrack: remove l3proto abstraction · a0ae2562
      Florian Westphal 提交于
      This unifies ipv4 and ipv6 protocol trackers and removes the l3proto
      abstraction.
      
      This gets rid of all l3proto indirect calls and the need to do
      a lookup on the function to call for l3 demux.
      
      It increases module size by only a small amount (12kbyte), so this reduces
      size because nf_conntrack.ko is useless without either nf_conntrack_ipv4
      or nf_conntrack_ipv6 module.
      
      before:
         text    data     bss     dec     hex filename
         7357    1088       0    8445    20fd nf_conntrack_ipv4.ko
         7405    1084       4    8493    212d nf_conntrack_ipv6.ko
        72614   13689     236   86539   1520b nf_conntrack.ko
       19K nf_conntrack_ipv4.ko
       19K nf_conntrack_ipv6.ko
      179K nf_conntrack.ko
      
      after:
         text    data     bss     dec     hex filename
        79277   13937     236   93450   16d0a nf_conntrack.ko
        191K nf_conntrack.ko
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      a0ae2562
  10. 16 7月, 2018 1 次提交
  11. 07 7月, 2018 1 次提交
  12. 03 6月, 2018 2 次提交
    • P
      netfilter: nf_tables: add connlimit support · 290180e2
      Pablo Neira Ayuso 提交于
      This features which allows you to limit the maximum number of
      connections per arbitrary key. The connlimit expression is stateful,
      therefore it can be used from meters to dynamically populate a set, this
      provides a mapping to the iptables' connlimit match. This patch also
      comes that allows you define static connlimit policies.
      
      This extension depends on the nf_conncount infrastructure.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      290180e2
    • M
      netfilter: Libify xt_TPROXY · 45ca4e0c
      Máté Eckl 提交于
      The extracted functions will likely be usefull to implement tproxy
      support in nf_tables.
      
      Extrancted functions:
      	- nf_tproxy_sk_is_transparent
      	- nf_tproxy_laddr4
      	- nf_tproxy_handle_time_wait4
      	- nf_tproxy_get_sock_v4
      	- nf_tproxy_laddr6
      	- nf_tproxy_handle_time_wait6
      	- nf_tproxy_get_sock_v6
      
      (nf_)tproxy_handle_time_wait6 also needed some refactor as its current
      implementation was xtables-specific.
      Signed-off-by: NMáté Eckl <ecklm94@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      45ca4e0c
  13. 01 6月, 2018 1 次提交
  14. 29 5月, 2018 1 次提交
  15. 23 5月, 2018 1 次提交
  16. 07 5月, 2018 1 次提交
  17. 27 4月, 2018 3 次提交
  18. 24 4月, 2018 1 次提交
  19. 16 4月, 2018 1 次提交
    • A
      netfilter: fix CONFIG_NF_REJECT_IPV6=m link error · a6615743
      Arnd Bergmann 提交于
      We get a new link error with CONFIG_NFT_REJECT_INET=y and CONFIG_NF_REJECT_IPV6=m
      after larger parts of the nftables modules are linked together:
      
      net/netfilter/nft_reject_inet.o: In function `nft_reject_inet_eval':
      nft_reject_inet.c:(.text+0x17c): undefined reference to `nf_send_unreach6'
      nft_reject_inet.c:(.text+0x190): undefined reference to `nf_send_reset6'
      
      The problem is that with NF_TABLES_INET set, we implicitly try to use
      the ipv6 version as well for NFT_REJECT, but when CONFIG_IPV6 is set to
      a loadable module, it's impossible to reach that.
      
      The best workaround I found is to express the above as a Kconfig
      dependency, forcing NFT_REJECT itself to be 'm' in that particular
      configuration.
      
      Fixes: 02c7b25e ("netfilter: nf_tables: build-in filter chain type")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      a6615743
  20. 30 3月, 2018 1 次提交
  21. 02 2月, 2018 1 次提交
    • P
      netfilter: flowtable infrastructure depends on NETFILTER_INGRESS · 6be3bcd7
      Pablo Neira Ayuso 提交于
      config NF_FLOW_TABLE depends on NETFILTER_INGRESS. If users forget to
      enable this toggle, flowtable registration fails with EOPNOTSUPP.
      
      Moreover, turn 'select NF_FLOW_TABLE' in every flowtable family flavour
      into dependency instead, otherwise this new dependency on
      NETFILTER_INGRESS causes a warning. This also allows us to remove the
      explicit dependency between family flowtables <-> NF_TABLES and
      NF_CONNTRACK, given they depend on the NF_FLOW_TABLE core that already
      expresses the general dependencies for this new infrastructure.
      
      Moreover, NF_FLOW_TABLE_INET depends on NF_FLOW_TABLE_IPV4 and
      NF_FLOWTABLE_IPV6, which already depends on NF_FLOW_TABLE. So we can get
      rid of direct dependency with NF_FLOW_TABLE.
      
      In general, let's avoid 'select', it just makes things more complicated.
      Reported-by: NJohn Crispin <john@phrozen.org>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      6be3bcd7
  22. 16 1月, 2018 1 次提交
    • A
      netfilter: nf_tables: flow_offload depends on flow_table · 9be9d04b
      Arnd Bergmann 提交于
      Without CONFIG_NF_FLOW_TABLE, the new nft_flow_offload module produces
      a link error:
      
      net/netfilter/nft_flow_offload.o: In function `nft_flow_offload_iterate_cleanup':
      nft_flow_offload.c:(.text+0xb0): undefined reference to `nf_flow_table_iterate'
      net/netfilter/nft_flow_offload.o: In function `flow_offload_iterate_cleanup':
      nft_flow_offload.c:(.text+0x160): undefined reference to `flow_offload_dead'
      net/netfilter/nft_flow_offload.o: In function `nft_flow_offload_eval':
      nft_flow_offload.c:(.text+0xc4c): undefined reference to `flow_offload_alloc'
      nft_flow_offload.c:(.text+0xc64): undefined reference to `flow_offload_add'
      nft_flow_offload.c:(.text+0xc94): undefined reference to `flow_offload_free'
      
      This adds a Kconfig dependency for it.
      
      Fixes: a3c90f7a ("netfilter: nf_tables: flow offload expression")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      9be9d04b
  23. 11 1月, 2018 1 次提交
    • A
      netfilter: improve flow table Kconfig dependencies · a0a97f2a
      Arnd Bergmann 提交于
      The newly added NF_FLOW_TABLE options cause some build failures in
      randconfig kernels:
      
      - when CONFIG_NF_CONNTRACK is disabled, or is a loadable module but
        NF_FLOW_TABLE is built-in:
      
        In file included from net/netfilter/nf_flow_table.c:8:0:
        include/net/netfilter/nf_conntrack.h:59:22: error: field 'ct_general' has incomplete type
          struct nf_conntrack ct_general;
        include/net/netfilter/nf_conntrack.h: In function 'nf_ct_get':
        include/net/netfilter/nf_conntrack.h:148:15: error: 'const struct sk_buff' has no member named '_nfct'
        include/net/netfilter/nf_conntrack.h: In function 'nf_ct_put':
        include/net/netfilter/nf_conntrack.h:157:2: error: implicit declaration of function 'nf_conntrack_put'; did you mean 'nf_ct_put'? [-Werror=implicit-function-declaration]
      
        net/netfilter/nf_flow_table.o: In function `nf_flow_offload_work_gc':
        (.text+0x1540): undefined reference to `nf_ct_delete'
      
      - when CONFIG_NF_TABLES is disabled:
      
        In file included from net/ipv6/netfilter/nf_flow_table_ipv6.c:13:0:
        include/net/netfilter/nf_tables.h: In function 'nft_gencursor_next':
        include/net/netfilter/nf_tables.h:1189:14: error: 'const struct net' has no member named 'nft'; did you mean 'nf'?
      
       - when CONFIG_NF_FLOW_TABLE_INET is enabled, but NF_FLOW_TABLE_IPV4
        or NF_FLOW_TABLE_IPV6 are not, or are loadable modules
      
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_offload_inet_hook':
        nf_flow_table_inet.c:(.text+0x94): undefined reference to `nf_flow_offload_ipv6_hook'
        nf_flow_table_inet.c:(.text+0x40): undefined reference to `nf_flow_offload_ip_hook'
      
      - when CONFIG_NF_FLOW_TABLES is disabled, but the other options are
        enabled:
      
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_offload_inet_hook':
        nf_flow_table_inet.c:(.text+0x6c): undefined reference to `nf_flow_offload_ipv6_hook'
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_inet_module_exit':
        nf_flow_table_inet.c:(.exit.text+0x8): undefined reference to `nft_unregister_flowtable_type'
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_inet_module_init':
        nf_flow_table_inet.c:(.init.text+0x8): undefined reference to `nft_register_flowtable_type'
        net/ipv4/netfilter/nf_flow_table_ipv4.o: In function `nf_flow_ipv4_module_exit':
        nf_flow_table_ipv4.c:(.exit.text+0x8): undefined reference to `nft_unregister_flowtable_type'
        net/ipv4/netfilter/nf_flow_table_ipv4.o: In function `nf_flow_ipv4_module_init':
        nf_flow_table_ipv4.c:(.init.text+0x8): undefined reference to `nft_register_flowtable_type'
      
      This adds additional Kconfig dependencies to ensure that NF_CONNTRACK and NF_TABLES
      are always visible from NF_FLOW_TABLE, and that the internal dependencies between
      the four new modules are met.
      
      Fixes: 7c23b629 ("netfilter: flow table support for the mixed IPv4/IPv6 family")
      Fixes: 09952107 ("netfilter: flow table support for IPv6")
      Fixes: 97add9f0 ("netfilter: flow table support for IPv4")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      a0a97f2a
  24. 09 1月, 2018 5 次提交
  25. 01 8月, 2017 1 次提交