1. 03 6月, 2018 10 次提交
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next · 4cb160d0
      David S. Miller 提交于
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter updates for net-next
      
      The following patchset contains Netfilter updates for your net-next tree:
      
      1) Get rid of nf_sk_is_transparent(), use inet_sk_transparent() instead.
         From Máté Eckl.
      
      2) Move shared tproxy infrastructure to nf_tproxy_ipv4 and nf_tproxy_ipv6.
         Also from Máté.
      
      3) Add hashtable to speed up chain lookups by name, from Florian Westphal.
      
      4) Patch series to add connlimit support reusing part of the
         nf_conncount infrastructure. This includes preparation changes such
         passing context to the object and expression destroy interface;
         garbage collection for expressions embedded into set elements, and
         the introduction of the clone_destroy interface for expressions.
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4cb160d0
    • F
      netfilter: nf_tables: handle chain name lookups via rhltable · 1b2470e5
      Florian Westphal 提交于
      If there is a significant amount of chains list search is too slow, so
      add an rhlist table for this.
      
      This speeds up ruleset loading: for every new rule we have to check if
      the name already exists in current generation.
      
      We need to be able to cope with duplicate chain names in case a transaction
      drops the nfnl mutex (for request_module) and the abort of this old
      transaction is still pending.
      
      The list is kept -- we need a way to iterate chains even if hash resize is
      in progress without missing an entry.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      1b2470e5
    • 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
    • P
      netfilter: nf_tables: add destroy_clone expression · 371ebcbb
      Pablo Neira Ayuso 提交于
      Before this patch, cloned expressions are released via ->destroy. This
      is a problem for the new connlimit expression since the ->destroy path
      drop a reference on the conntrack modules and it unregisters hooks. The
      new ->destroy_clone provides context that this expression is being
      released from the packet path, so it is mirroring ->clone(), where
      neither module reference is dropped nor hooks need to be unregistered -
      because this done from the control plane path from the ->init() path.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      371ebcbb
    • P
      netfilter: nf_tables: garbage collection for stateful expressions · 79b174ad
      Pablo Neira Ayuso 提交于
      Use garbage collector to schedule removal of elements based of feedback
      from expression that this element comes with. Therefore, the garbage
      collector is not guided by timeout expirations in this new mode.
      
      The new connlimit expression sets on the NFT_EXPR_GC flag to enable this
      behaviour, the dynset expression needs to explicitly enable the garbage
      collector via set->ops->gc_init call.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      79b174ad
    • P
      netfilter: nf_tables: pass ctx to nf_tables_expr_destroy() · 3453c927
      Pablo Neira Ayuso 提交于
      nft_set_elem_destroy() can be called from call_rcu context. Annotate
      netns and table in set object so we can populate the context object.
      Moreover, pass context object to nf_tables_set_elem_destroy() from the
      commit phase, since it is already available from there.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      3453c927
    • P
      netfilter: nf_conncount: expose connection list interface · 5e5cbc7b
      Pablo Neira Ayuso 提交于
      This patch provides an interface to maintain the list of connections and
      the lookup function to obtain the number of connections in the list.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      5e5cbc7b
    • P
      netfilter: nf_tables: pass context to object destroy indirection · 00bfb320
      Pablo Neira Ayuso 提交于
      The new connlimit object needs this to properly deal with conntrack
      dependencies.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      00bfb320
    • 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
    • M
      netfilter: Decrease code duplication regarding transparent socket option · 8d6e5557
      Máté Eckl 提交于
      There is a function in include/net/netfilter/nf_socket.h to decide if a
      socket has IP(V6)_TRANSPARENT socket option set or not. However this
      does the same as inet_sk_transparent() in include/net/tcp.h
      
      include/net/tcp.h:1733
      /* This helper checks if socket has IP_TRANSPARENT set */
      static inline bool inet_sk_transparent(const struct sock *sk)
      {
      	switch (sk->sk_state) {
      	case TCP_TIME_WAIT:
      		return inet_twsk(sk)->tw_transparent;
      	case TCP_NEW_SYN_RECV:
      		return inet_rsk(inet_reqsk(sk))->no_srccheck;
      	}
      	return inet_sk(sk)->transparent;
      }
      
      tproxy_sk_is_transparent has also been refactored to use this function
      instead of reimplementing it.
      Signed-off-by: NMáté Eckl <ecklm94@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      8d6e5557
  2. 02 6月, 2018 30 次提交