]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
netfilter: nat: avoid use of nf_conn_nat extension
authorFlorian Westphal <fw@strlen.de>
Tue, 28 Mar 2017 08:31:03 +0000 (10:31 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 6 Apr 2017 20:01:42 +0000 (22:01 +0200)
successful insert into the bysource hash sets IPS_SRC_NAT_DONE status bit
so we can check that instead of presence of nat extension which requires
extra deref.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_nat_core.c

index 3d621b8d7b8a7ba6318ac1359e1efa795c63a479..bcf1d2a6539e8dbe34526b64052be8f842dd3586 100644 (file)
@@ -706,7 +706,7 @@ static int nf_ct_resolve_clash(struct net *net, struct sk_buff *skb,
 
        l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
        if (l4proto->allow_clash &&
-           !nfct_nat(ct) &&
+           ((ct->status & IPS_NAT_DONE_MASK) == 0) &&
            !nf_ct_is_dying(ct) &&
            atomic_inc_not_zero(&ct->ct_general.use)) {
                enum ip_conntrack_info oldinfo;
index 82802e4a6640817e64eb3f3a6ffcb875ad14a747..376c1b36f22276d3e01b20f9d395d98bc468bb96 100644 (file)
@@ -549,10 +549,6 @@ struct nf_nat_proto_clean {
 static int nf_nat_proto_remove(struct nf_conn *i, void *data)
 {
        const struct nf_nat_proto_clean *clean = data;
-       struct nf_conn_nat *nat = nfct_nat(i);
-
-       if (!nat)
-               return 0;
 
        if ((clean->l3proto && nf_ct_l3num(i) != clean->l3proto) ||
            (clean->l4proto && nf_ct_protonum(i) != clean->l4proto))
@@ -563,12 +559,10 @@ static int nf_nat_proto_remove(struct nf_conn *i, void *data)
 
 static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
 {
-       struct nf_conn_nat *nat = nfct_nat(ct);
-
        if (nf_nat_proto_remove(ct, data))
                return 1;
 
-       if (!nat)
+       if ((ct->status & IPS_SRC_NAT_DONE) == 0)
                return 0;
 
        /* This netns is being destroyed, and conntrack has nat null binding.
@@ -716,13 +710,9 @@ EXPORT_SYMBOL_GPL(nf_nat_l3proto_unregister);
 /* No one using conntrack by the time this called. */
 static void nf_nat_cleanup_conntrack(struct nf_conn *ct)
 {
-       struct nf_conn_nat *nat = nf_ct_ext_find(ct, NF_CT_EXT_NAT);
-
-       if (!nat)
-               return;
-
-       rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource,
-                       nf_nat_bysource_params);
+       if (ct->status & IPS_SRC_NAT_DONE)
+               rhltable_remove(&nf_nat_bysource_table, &ct->nat_bysource,
+                               nf_nat_bysource_params);
 }
 
 static struct nf_ct_ext_type nat_extend __read_mostly = {