1. 23 5月, 2018 6 次提交
    • F
      netfilter: nf_nat: add nat type hooks to nat core · 9971a514
      Florian Westphal 提交于
      Currently the packet rewrite and instantiation of nat NULL bindings
      happens from the protocol specific nat backend.
      
      Invocation occurs either via ip(6)table_nat or the nf_tables nat chain type.
      
      Invocation looks like this (simplified):
      NF_HOOK()
         |
         `---iptable_nat
      	 |
      	 `---> nf_nat_l3proto_ipv4 -> nf_nat_packet
      	               |
                new packet? pass skb though iptables nat chain
                             |
      		       `---> iptable_nat: ipt_do_table
      
      In nft case, this looks the same (nft_chain_nat_ipv4 instead of
      iptable_nat).
      
      This is a problem for two reasons:
      1. Can't use iptables nat and nf_tables nat at the same time,
         as the first user adds a nat binding (nf_nat_l3proto_ipv4 adds a
         NULL binding if do_table() did not find a matching nat rule so we
         can detect post-nat tuple collisions).
      2. If you use e.g. nft_masq, snat, redir, etc. uses must also register
         an empty base chain so that the nat core gets called fro NF_HOOK()
         to do the reverse translation, which is neither obvious nor user
         friendly.
      
      After this change, the base hook gets registered not from iptable_nat or
      nftables nat hooks, but from the l3 nat core.
      
      iptables/nft nat base hooks get registered with the nat core instead:
      
      NF_HOOK()
         |
         `---> nf_nat_l3proto_ipv4 -> nf_nat_packet
      		|
               new packet? pass skb through iptables/nftables nat chains
                      |
      		+-> iptables_nat: ipt_do_table
      	        +-> nft nat chain x
      	        `-> nft nat chain y
      
      The nat core deals with null bindings and reverse translation.
      When no mapping exists, it calls the registered nat lookup hooks until
      one creates a new mapping.
      If both iptables and nftables nat hooks exist, the first matching
      one is used (i.e., higher priority wins).
      
      Also, nft users do not need to create empty nat hooks anymore,
      nat core always registers the base hooks that take care of reverse/reply
      translation.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      9971a514
    • F
      netfilter: nf_nat: add nat hook register functions to nf_nat · 1cd472bf
      Florian Westphal 提交于
      This adds the infrastructure to register nat hooks with the nat core
      instead of the netfilter core.
      
      nat hooks are used to configure nat bindings.  Such hooks are registered
      from ip(6)table_nat or by the nftables core when a nat chain is added.
      
      After next patch, nat hooks will be registered with nf_nat instead of
      netfilter core.  This allows to use many nat lookup functions at the
      same time while doing the real packet rewrite (nat transformation) in
      one place.
      
      This change doesn't convert the intended users yet to ease review.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      1cd472bf
    • F
      netfilter: core: export raw versions of add/delete hook functions · 06cad3ac
      Florian Westphal 提交于
      This will allow the nat core to reuse the nf_hook infrastructure
      to maintain nat lookup functions.
      
      The raw versions don't assume a particular hook location, the
      functions get added/deleted from the hook blob that is passed to the
      functions.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      06cad3ac
    • F
      netfilter: nf_tables: allow chain type to override hook register · 4e25ceb8
      Florian Westphal 提交于
      Will be used in followup patch when nat types no longer
      use nf_register_net_hook() but will instead register with the nat core.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      4e25ceb8
    • F
      netfilter: xtables: allow table definitions not backed by hook_ops · ba7d284a
      Florian Westphal 提交于
      The ip(6)tables nat table is currently receiving skbs from the netfilter
      core, after a followup patch skbs will be coming from the netfilter nat
      core instead, so the table is no longer backed by normal hook_ops.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      ba7d284a
    • F
      netfilter: nf_nat: move common nat code to nat core · 1f55236b
      Florian Westphal 提交于
      Copy-pasted, both l3 helpers almost use same code here.
      Split out the common part into an 'inet' helper.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      1f55236b
  2. 17 5月, 2018 4 次提交
  3. 14 5月, 2018 1 次提交
  4. 12 5月, 2018 29 次提交