[NETFILTER]: nf_queue: remove unused data pointer
[powerpc.git] / net / ipv4 / netfilter / nf_nat_core.c
index e848d8d..746c2ef 100644 (file)
@@ -77,7 +77,8 @@ static inline unsigned int
 hash_by_src(const struct nf_conntrack_tuple *tuple)
 {
        /* Original src, to ensure we map it consistently if poss. */
-       return jhash_3words((__force u32)tuple->src.u3.ip, tuple->src.u.all,
+       return jhash_3words((__force u32)tuple->src.u3.ip,
+                           (__force u32)tuple->src.u.all,
                            tuple->dst.protonum, 0) % nf_nat_htable_size;
 }
 
@@ -212,9 +213,9 @@ find_best_ips_proto(struct nf_conntrack_tuple *tuple,
        *var_ipp = htonl(minip + j % (maxip - minip + 1));
 }
 
-/* Manipulate the tuple into the range given.  For NF_IP_POST_ROUTING,
- * we change the source to map into the range.  For NF_IP_PRE_ROUTING
- * and NF_IP_LOCAL_OUT, we change the destination to map into the
+/* Manipulate the tuple into the range given.  For NF_INET_POST_ROUTING,
+ * we change the source to map into the range.  For NF_INET_PRE_ROUTING
+ * and NF_INET_LOCAL_OUT, we change the destination to map into the
  * range.  It might not be possible to get a unique tuple, but we try.
  * At worst (or if we race), we will end up with a final duplicate in
  * __ip_conntrack_confirm and drop the packet. */
@@ -292,10 +293,10 @@ nf_nat_setup_info(struct nf_conn *ct,
                }
        }
 
-       NF_CT_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
-                    hooknum == NF_IP_POST_ROUTING ||
-                    hooknum == NF_IP_LOCAL_IN ||
-                    hooknum == NF_IP_LOCAL_OUT);
+       NF_CT_ASSERT(hooknum == NF_INET_PRE_ROUTING ||
+                    hooknum == NF_INET_POST_ROUTING ||
+                    hooknum == NF_INET_LOCAL_IN ||
+                    hooknum == NF_INET_LOCAL_OUT);
        BUG_ON(nf_nat_initialized(ct, maniptype));
 
        /* What we've got will look like inverse of reply. Normally
@@ -348,7 +349,7 @@ EXPORT_SYMBOL(nf_nat_setup_info);
 /* Returns true if succeeded. */
 static int
 manip_pkt(u_int16_t proto,
-         struct sk_buff **pskb,
+         struct sk_buff *skb,
          unsigned int iphdroff,
          const struct nf_conntrack_tuple *target,
          enum nf_nat_manip_type maniptype)
@@ -356,25 +357,25 @@ manip_pkt(u_int16_t proto,
        struct iphdr *iph;
        struct nf_nat_protocol *p;
 
-       if (!skb_make_writable(pskb, iphdroff + sizeof(*iph)))
+       if (!skb_make_writable(skb, iphdroff + sizeof(*iph)))
                return 0;
 
-       iph = (void *)(*pskb)->data + iphdroff;
+       iph = (void *)skb->data + iphdroff;
 
        /* Manipulate protcol part. */
 
        /* rcu_read_lock()ed by nf_hook_slow */
        p = __nf_nat_proto_find(proto);
-       if (!p->manip_pkt(pskb, iphdroff, target, maniptype))
+       if (!p->manip_pkt(skb, iphdroff, target, maniptype))
                return 0;
 
-       iph = (void *)(*pskb)->data + iphdroff;
+       iph = (void *)skb->data + iphdroff;
 
        if (maniptype == IP_NAT_MANIP_SRC) {
-               nf_csum_replace4(&iph->check, iph->saddr, target->src.u3.ip);
+               csum_replace4(&iph->check, iph->saddr, target->src.u3.ip);
                iph->saddr = target->src.u3.ip;
        } else {
-               nf_csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip);
+               csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip);
                iph->daddr = target->dst.u3.ip;
        }
        return 1;
@@ -384,7 +385,7 @@ manip_pkt(u_int16_t proto,
 unsigned int nf_nat_packet(struct nf_conn *ct,
                           enum ip_conntrack_info ctinfo,
                           unsigned int hooknum,
-                          struct sk_buff **pskb)
+                          struct sk_buff *skb)
 {
        enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
        unsigned long statusbit;
@@ -406,7 +407,7 @@ unsigned int nf_nat_packet(struct nf_conn *ct,
                /* We are aiming to look like inverse of other direction. */
                nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
 
-               if (!manip_pkt(target.dst.protonum, pskb, 0, &target, mtype))
+               if (!manip_pkt(target.dst.protonum, skb, 0, &target, mtype))
                        return NF_DROP;
        }
        return NF_ACCEPT;
@@ -417,7 +418,7 @@ EXPORT_SYMBOL_GPL(nf_nat_packet);
 int nf_nat_icmp_reply_translation(struct nf_conn *ct,
                                  enum ip_conntrack_info ctinfo,
                                  unsigned int hooknum,
-                                 struct sk_buff **pskb)
+                                 struct sk_buff *skb)
 {
        struct {
                struct icmphdr icmp;
@@ -425,24 +426,24 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct,
        } *inside;
        struct nf_conntrack_l4proto *l4proto;
        struct nf_conntrack_tuple inner, target;
-       int hdrlen = ip_hdrlen(*pskb);
+       int hdrlen = ip_hdrlen(skb);
        enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
        unsigned long statusbit;
        enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
 
-       if (!skb_make_writable(pskb, hdrlen + sizeof(*inside)))
+       if (!skb_make_writable(skb, hdrlen + sizeof(*inside)))
                return 0;
 
-       inside = (void *)(*pskb)->data + ip_hdrlen(*pskb);
+       inside = (void *)skb->data + ip_hdrlen(skb);
 
        /* We're actually going to mangle it beyond trivial checksum
           adjustment, so make sure the current checksum is correct. */
-       if (nf_ip_checksum(*pskb, hooknum, hdrlen, 0))
+       if (nf_ip_checksum(skb, hooknum, hdrlen, 0))
                return 0;
 
        /* Must be RELATED */
-       NF_CT_ASSERT((*pskb)->nfctinfo == IP_CT_RELATED ||
-                    (*pskb)->nfctinfo == IP_CT_RELATED+IP_CT_IS_REPLY);
+       NF_CT_ASSERT(skb->nfctinfo == IP_CT_RELATED ||
+                    skb->nfctinfo == IP_CT_RELATED+IP_CT_IS_REPLY);
 
        /* Redirects on non-null nats must be dropped, else they'll
           start talking to each other without our translation, and be
@@ -457,15 +458,15 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct,
        }
 
        pr_debug("icmp_reply_translation: translating error %p manip %u "
-                "dir %s\n", *pskb, manip,
+                "dir %s\n", skb, manip,
                 dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY");
 
        /* rcu_read_lock()ed by nf_hook_slow */
        l4proto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
 
-       if (!nf_ct_get_tuple(*pskb,
-                            ip_hdrlen(*pskb) + sizeof(struct icmphdr),
-                            (ip_hdrlen(*pskb) +
+       if (!nf_ct_get_tuple(skb,
+                            ip_hdrlen(skb) + sizeof(struct icmphdr),
+                            (ip_hdrlen(skb) +
                              sizeof(struct icmphdr) + inside->ip.ihl * 4),
                             (u_int16_t)AF_INET,
                             inside->ip.protocol,
@@ -477,19 +478,19 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct,
           pass all hooks (locally-generated ICMP).  Consider incoming
           packet: PREROUTING (DST manip), routing produces ICMP, goes
           through POSTROUTING (which must correct the DST manip). */
-       if (!manip_pkt(inside->ip.protocol, pskb,
-                      ip_hdrlen(*pskb) + sizeof(inside->icmp),
+       if (!manip_pkt(inside->ip.protocol, skb,
+                      ip_hdrlen(skb) + sizeof(inside->icmp),
                       &ct->tuplehash[!dir].tuple,
                       !manip))
                return 0;
 
-       if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
+       if (skb->ip_summed != CHECKSUM_PARTIAL) {
                /* Reloading "inside" here since manip_pkt inner. */
-               inside = (void *)(*pskb)->data + ip_hdrlen(*pskb);
+               inside = (void *)skb->data + ip_hdrlen(skb);
                inside->icmp.checksum = 0;
                inside->icmp.checksum =
-                       csum_fold(skb_checksum(*pskb, hdrlen,
-                                              (*pskb)->len - hdrlen, 0));
+                       csum_fold(skb_checksum(skb, hdrlen,
+                                              skb->len - hdrlen, 0));
        }
 
        /* Change outer to look the reply to an incoming packet
@@ -505,7 +506,7 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct,
 
        if (ct->status & statusbit) {
                nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
-               if (!manip_pkt(0, pskb, 0, &target, manip))
+               if (!manip_pkt(0, skb, 0, &target, manip))
                        return 0;
        }
 
@@ -543,46 +544,46 @@ EXPORT_SYMBOL(nf_nat_protocol_unregister);
 
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
 int
-nf_nat_port_range_to_nfattr(struct sk_buff *skb,
+nf_nat_port_range_to_nlattr(struct sk_buff *skb,
                            const struct nf_nat_range *range)
 {
-       NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
+       NLA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
                &range->min.tcp.port);
-       NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16),
+       NLA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16),
                &range->max.tcp.port);
 
        return 0;
 
-nfattr_failure:
+nla_put_failure:
        return -1;
 }
-EXPORT_SYMBOL_GPL(nf_nat_port_nfattr_to_range);
+EXPORT_SYMBOL_GPL(nf_nat_port_nlattr_to_range);
 
 int
-nf_nat_port_nfattr_to_range(struct nfattr *tb[], struct nf_nat_range *range)
+nf_nat_port_nlattr_to_range(struct nlattr *tb[], struct nf_nat_range *range)
 {
        int ret = 0;
 
        /* we have to return whether we actually parsed something or not */
 
-       if (tb[CTA_PROTONAT_PORT_MIN-1]) {
+       if (tb[CTA_PROTONAT_PORT_MIN]) {
                ret = 1;
                range->min.tcp.port =
-                       *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]);
+                       *(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MIN]);
        }
 
-       if (!tb[CTA_PROTONAT_PORT_MAX-1]) {
+       if (!tb[CTA_PROTONAT_PORT_MAX]) {
                if (ret)
                        range->max.tcp.port = range->min.tcp.port;
        } else {
                ret = 1;
                range->max.tcp.port =
-                       *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]);
+                       *(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MAX]);
        }
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nfattr);
+EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nlattr);
 #endif
 
 /* Noone using conntrack by the time this called. */
@@ -606,13 +607,10 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
        struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT);
        struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old;
        struct nf_conn *ct = old_nat->ct;
-       unsigned int srchash;
 
-       if (!(ct->status & IPS_NAT_DONE_MASK))
+       if (!ct || !(ct->status & IPS_NAT_DONE_MASK))
                return;
 
-       srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
-
        write_lock_bh(&nf_nat_lock);
        hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource);
        new_nat->ct = ct;
@@ -680,7 +678,7 @@ static int clean_nat(struct nf_conn *i, void *data)
 
        if (!nat)
                return 0;
-       memset(nat, 0, sizeof(nat));
+       memset(nat, 0, sizeof(*nat));
        i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST);
        return 0;
 }