]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
skbuff: add and use skb_nfct helper
authorFlorian Westphal <fw@strlen.de>
Mon, 23 Jan 2017 17:21:56 +0000 (18:21 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 2 Feb 2017 13:31:53 +0000 (14:31 +0100)
Followup patch renames skb->nfct and changes its type so add a helper to
avoid intrusive rename change later.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
15 files changed:
include/linux/skbuff.h
include/net/netfilter/nf_conntrack_core.h
net/core/skbuff.c
net/ipv4/netfilter/ipt_SYNPROXY.c
net/ipv4/netfilter/nf_conntrack_proto_icmp.c
net/ipv4/netfilter/nf_defrag_ipv4.c
net/ipv4/netfilter/nf_dup_ipv4.c
net/ipv6/netfilter/ip6t_SYNPROXY.c
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_nat_helper.c
net/netfilter/xt_CT.c
net/openvswitch/conntrack.c
net/sched/cls_flow.c

index b53c0cfd417e3bec1c5cfab76787901bafa5884c..276431e047af0d7746afae0853b232ecf68385b1 100644 (file)
@@ -3553,6 +3553,15 @@ static inline void skb_remcsum_process(struct sk_buff *skb, void *ptr,
        skb->csum = csum_add(skb->csum, delta);
 }
 
+static inline struct nf_conntrack *skb_nfct(const struct sk_buff *skb)
+{
+#if IS_ENABLED(CONFIG_NF_CONNTRACK)
+       return skb->nfct;
+#else
+       return NULL;
+#endif
+}
+
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 void nf_conntrack_destroy(struct nf_conntrack *nfct);
 static inline void nf_conntrack_put(struct nf_conntrack *nfct)
@@ -3652,9 +3661,7 @@ static inline bool skb_irq_freeable(const struct sk_buff *skb)
 #if IS_ENABLED(CONFIG_XFRM)
                !skb->sp &&
 #endif
-#if IS_ENABLED(CONFIG_NF_CONNTRACK)
-               !skb->nfct &&
-#endif
+               !skb_nfct(skb) &&
                !skb->_skb_refdst &&
                !skb_has_frag_list(skb);
 }
index 62e17d1319ff7423dbcf176815f04cecfcdf3371..84ec7ca5f195db411b7e07c6dce641a286b5ea0a 100644 (file)
@@ -62,7 +62,7 @@ int __nf_conntrack_confirm(struct sk_buff *skb);
 /* Confirm a connection: returns NF_DROP if packet must be dropped. */
 static inline int nf_conntrack_confirm(struct sk_buff *skb)
 {
-       struct nf_conn *ct = (struct nf_conn *)skb->nfct;
+       struct nf_conn *ct = (struct nf_conn *)skb_nfct(skb);
        int ret = NF_ACCEPT;
 
        if (ct && !nf_ct_is_untracked(ct)) {
index 5a03730fbc1a84376985d4d68d8b80d8f38b0985..cac3ebfb4b4556dd9c218ee654afce29c8fbf551 100644 (file)
@@ -655,7 +655,7 @@ static void skb_release_head_state(struct sk_buff *skb)
                skb->destructor(skb);
        }
 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
-       nf_conntrack_put(skb->nfct);
+       nf_conntrack_put(skb_nfct(skb));
 #endif
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
        nf_bridge_put(skb->nf_bridge);
index 30c0de53e2541b45c494830bf0fc2fc36b0b9d43..a12d4f0aa67493c8e08b9649f6dd2807e0768410 100644 (file)
@@ -107,8 +107,8 @@ synproxy_send_client_synack(struct net *net,
 
        synproxy_build_options(nth, opts);
 
-       synproxy_send_tcp(net, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
-                         niph, nth, tcp_hdr_size);
+       synproxy_send_tcp(net, skb, nskb, skb_nfct(skb),
+                         IP_CT_ESTABLISHED_REPLY, niph, nth, tcp_hdr_size);
 }
 
 static void
@@ -230,8 +230,8 @@ synproxy_send_client_ack(struct net *net,
 
        synproxy_build_options(nth, opts);
 
-       synproxy_send_tcp(net, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
-                         niph, nth, tcp_hdr_size);
+       synproxy_send_tcp(net, skb, nskb, skb_nfct(skb),
+                         IP_CT_ESTABLISHED_REPLY, niph, nth, tcp_hdr_size);
 }
 
 static bool
index 566afac98a889f369660b5f101f3547d01c78e6a..478a025909fc06367401fcbf6f6a0c96d88a9728 100644 (file)
@@ -137,7 +137,7 @@ icmp_error_message(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
        enum ip_conntrack_info ctinfo;
        struct nf_conntrack_zone tmp;
 
-       NF_CT_ASSERT(skb->nfct == NULL);
+       NF_CT_ASSERT(!skb_nfct(skb));
        zone = nf_ct_zone_tmpl(tmpl, skb, &tmp);
 
        /* Are they talking about one of our connections? */
index 49bd6a54404f17559d31722b90bb4687b6c4abc8..346bf7ccac0881bc86c7d019987281d9dc8db62e 100644 (file)
@@ -45,7 +45,7 @@ static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum,
 {
        u16 zone_id = NF_CT_DEFAULT_ZONE_ID;
 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
-       if (skb->nfct) {
+       if (skb_nfct(skb)) {
                enum ip_conntrack_info ctinfo;
                const struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
 
@@ -75,7 +75,7 @@ static unsigned int ipv4_conntrack_defrag(void *priv,
 #if !IS_ENABLED(CONFIG_NF_NAT)
        /* Previously seen (loopback)?  Ignore.  Do this before
           fragment check. */
-       if (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct))
+       if (skb_nfct(skb) && !nf_ct_is_template((struct nf_conn *)skb_nfct(skb)))
                return NF_ACCEPT;
 #endif
 #endif
index a981ef7151caadc150896eafcca129f2a1ca532e..1a5e1f53ceaa91bed85f04935b7bcd6429b65ea5 100644 (file)
@@ -71,7 +71,7 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,
        nf_reset(skb);
        skb->nfct     = &nf_ct_untracked_get()->ct_general;
        skb->nfctinfo = IP_CT_NEW;
-       nf_conntrack_get(skb->nfct);
+       nf_conntrack_get(skb_nfct(skb));
 #endif
        /*
         * If we are in PREROUTING/INPUT, decrease the TTL to mitigate potential
index 98c8dd38575a35c0c3d243378cd516f23ca8d62d..2dc01d2c6ec02a6da732e039ebba751577c1a16e 100644 (file)
@@ -121,8 +121,8 @@ synproxy_send_client_synack(struct net *net,
 
        synproxy_build_options(nth, opts);
 
-       synproxy_send_tcp(net, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
-                         niph, nth, tcp_hdr_size);
+       synproxy_send_tcp(net, skb, nskb, skb_nfct(skb),
+                         IP_CT_ESTABLISHED_REPLY, niph, nth, tcp_hdr_size);
 }
 
 static void
@@ -244,8 +244,8 @@ synproxy_send_client_ack(struct net *net,
 
        synproxy_build_options(nth, opts);
 
-       synproxy_send_tcp(net, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
-                         niph, nth, tcp_hdr_size);
+       synproxy_send_tcp(net, skb, nskb, skb_nfct(skb),
+                         IP_CT_ESTABLISHED_REPLY, niph, nth, tcp_hdr_size);
 }
 
 static bool
index 44b9af3f813e18a90a30dfa9dc597ee3e1709178..09f1661a4e885c3aaa8b88ba59070109e5a578ca 100644 (file)
@@ -153,7 +153,7 @@ icmpv6_error_message(struct net *net, struct nf_conn *tmpl,
        enum ip_conntrack_info ctinfo;
        struct nf_conntrack_zone tmp;
 
-       NF_CT_ASSERT(skb->nfct == NULL);
+       NF_CT_ASSERT(!skb_nfct(skb));
 
        /* Are they talking about one of our connections? */
        if (!nf_ct_get_tuplepr(skb,
@@ -224,7 +224,7 @@ icmpv6_error(struct net *net, struct nf_conn *tmpl,
            noct_valid_new[type]) {
                skb->nfct = &nf_ct_untracked_get()->ct_general;
                skb->nfctinfo = IP_CT_NEW;
-               nf_conntrack_get(skb->nfct);
+               nf_conntrack_get(skb_nfct(skb));
                return NF_ACCEPT;
        }
 
index 8e0bdd0587871f03aa949b0eabc4d6ec9740b0cc..ada60d1a991b7c2e421884f0a8c4361d6f81f10a 100644 (file)
@@ -37,7 +37,7 @@ static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
 {
        u16 zone_id = NF_CT_DEFAULT_ZONE_ID;
 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
-       if (skb->nfct) {
+       if (skb_nfct(skb)) {
                enum ip_conntrack_info ctinfo;
                const struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
 
@@ -61,7 +61,7 @@ static unsigned int ipv6_defrag(void *priv,
 
 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
        /* Previously seen (loopback)?  */
-       if (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct))
+       if (skb_nfct(skb) && !nf_ct_is_template((struct nf_conn *)skb_nfct(skb)))
                return NF_ACCEPT;
 #endif
 
index adb7af3a4c4ce46fe9cc010bd220ed39b2b413a4..78aebf0ee6e37c84e41426030a45ff82047857e7 100644 (file)
@@ -1357,7 +1357,7 @@ repeat:
                goto out;
        }
 
-       NF_CT_ASSERT(skb->nfct);
+       NF_CT_ASSERT(skb_nfct(skb));
 
        /* Decide what timeout policy we want to apply to this flow. */
        timeouts = nf_ct_timeout_lookup(net, ct, l4proto);
@@ -1528,7 +1528,7 @@ static void nf_conntrack_attach(struct sk_buff *nskb, const struct sk_buff *skb)
        /* Attach to new skbuff, and increment count */
        nskb->nfct = &ct->ct_general;
        nskb->nfctinfo = ctinfo;
-       nf_conntrack_get(nskb->nfct);
+       nf_conntrack_get(skb_nfct(nskb));
 }
 
 /* Bring out ya dead! */
index 2840abb5bb99a7590b228f13e5769a62902f3cf3..211661cb2c90a5d25a57d5ce41c9c5f9898c5302 100644 (file)
@@ -60,7 +60,7 @@ static void mangle_contents(struct sk_buff *skb,
                __skb_trim(skb, skb->len + rep_len - match_len);
        }
 
-       if (nf_ct_l3num((struct nf_conn *)skb->nfct) == NFPROTO_IPV4) {
+       if (nf_ct_l3num((struct nf_conn *)skb_nfct(skb)) == NFPROTO_IPV4) {
                /* fix IP hdr checksum information */
                ip_hdr(skb)->tot_len = htons(skb->len);
                ip_send_check(ip_hdr(skb));
index 26b0bccfa0c5de8585c9d82d10b718d9bd75ce79..cd7e29910ae1b06f6af41218822406490483e9b2 100644 (file)
@@ -415,7 +415,7 @@ notrack_tg(struct sk_buff *skb, const struct xt_action_param *par)
 
        skb->nfct = &nf_ct_untracked_get()->ct_general;
        skb->nfctinfo = IP_CT_NEW;
-       nf_conntrack_get(skb->nfct);
+       nf_conntrack_get(skb_nfct(skb));
 
        return XT_CONTINUE;
 }
index 6b78bab27755b2758f3c8ecd5b9c6d61615af4b6..4525579461475af7a434da9855991d80716b53a8 100644 (file)
@@ -721,8 +721,8 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 
                /* Associate skb with specified zone. */
                if (tmpl) {
-                       if (skb->nfct)
-                               nf_conntrack_put(skb->nfct);
+                       if (skb_nfct(skb))
+                               nf_conntrack_put(skb_nfct(skb));
                        nf_conntrack_get(&tmpl->ct_general);
                        skb->nfct = &tmpl->ct_general;
                        skb->nfctinfo = IP_CT_NEW;
@@ -819,7 +819,7 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
                if (err)
                        return err;
 
-               ct = (struct nf_conn *)skb->nfct;
+               ct = (struct nf_conn *)skb_nfct(skb);
                if (ct)
                        nf_ct_deliver_cached_events(ct);
        }
index 6575aba87630a24052a6374ddfceef1ce597144d..3d6b9286c203f298b14b5254e5c12cb4781eb4b1 100644 (file)
@@ -129,7 +129,7 @@ static u32 flow_get_mark(const struct sk_buff *skb)
 static u32 flow_get_nfct(const struct sk_buff *skb)
 {
 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
-       return addr_fold(skb->nfct);
+       return addr_fold(skb_nfct(skb));
 #else
        return 0;
 #endif