]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netfilter/nf_conntrack_core.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[linux-2.6-omap-h63xx.git] / net / netfilter / nf_conntrack_core.c
index aa086c83af8000e0114cb46fc76fc6c4df4af717..4d6171bc0829cd1e9283718054b86b5af7195cc2 100644 (file)
@@ -63,7 +63,6 @@ unsigned int nf_ct_log_invalid __read_mostly;
 HLIST_HEAD(unconfirmed);
 static int nf_conntrack_vmalloc __read_mostly;
 static struct kmem_cache *nf_conntrack_cachep __read_mostly;
-static unsigned int nf_conntrack_next_id;
 
 DEFINE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
 EXPORT_PER_CPU_SYMBOL(nf_conntrack_stat);
@@ -79,7 +78,8 @@ static u_int32_t __hash_conntrack(const struct nf_conntrack_tuple *tuple,
        a = jhash2(tuple->src.u3.all, ARRAY_SIZE(tuple->src.u3.all),
                   (tuple->src.l3num << 16) | tuple->dst.protonum);
        b = jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
-                  (tuple->src.u.all << 16) | tuple->dst.u.all);
+                  ((__force __u16)tuple->src.u.all << 16) |
+                   (__force __u16)tuple->dst.u.all);
 
        return jhash_2words(a, b, rnd) % size;
 }
@@ -286,7 +286,6 @@ static void __nf_conntrack_hash_insert(struct nf_conn *ct,
                                       unsigned int hash,
                                       unsigned int repl_hash)
 {
-       ct->id = ++nf_conntrack_next_id;
        hlist_add_head(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnode,
                       &nf_conntrack_hash[hash]);
        hlist_add_head(&ct->tuplehash[IP_CT_DIR_REPLY].hnode,
@@ -308,7 +307,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_hash_insert);
 
 /* Confirm a connection given skb; places it in hash table */
 int
-__nf_conntrack_confirm(struct sk_buff **pskb)
+__nf_conntrack_confirm(struct sk_buff *skb)
 {
        unsigned int hash, repl_hash;
        struct nf_conntrack_tuple_hash *h;
@@ -317,7 +316,7 @@ __nf_conntrack_confirm(struct sk_buff **pskb)
        struct hlist_node *n;
        enum ip_conntrack_info ctinfo;
 
-       ct = nf_ct_get(*pskb, &ctinfo);
+       ct = nf_ct_get(skb, &ctinfo);
 
        /* ipt_REJECT uses nf_conntrack_attach to attach related
           ICMP/TCP RST packets in other direction.  Actual packet
@@ -368,14 +367,14 @@ __nf_conntrack_confirm(struct sk_buff **pskb)
        write_unlock_bh(&nf_conntrack_lock);
        help = nfct_help(ct);
        if (help && help->helper)
-               nf_conntrack_event_cache(IPCT_HELPER, *pskb);
+               nf_conntrack_event_cache(IPCT_HELPER, skb);
 #ifdef CONFIG_NF_NAT_NEEDED
        if (test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status) ||
            test_bit(IPS_DST_NAT_DONE_BIT, &ct->status))
-               nf_conntrack_event_cache(IPCT_NATINFO, *pskb);
+               nf_conntrack_event_cache(IPCT_NATINFO, skb);
 #endif
        nf_conntrack_event_cache(master_ct(ct) ?
-                                IPCT_RELATED : IPCT_NEW, *pskb);
+                                IPCT_RELATED : IPCT_NEW, skb);
        return NF_ACCEPT;
 
 out:
@@ -633,7 +632,7 @@ resolve_normal_ct(struct sk_buff *skb,
 }
 
 unsigned int
-nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
+nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff *skb)
 {
        struct nf_conn *ct;
        enum ip_conntrack_info ctinfo;
@@ -645,14 +644,14 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
        int ret;
 
        /* Previously seen (loopback or untracked)?  Ignore. */
-       if ((*pskb)->nfct) {
+       if (skb->nfct) {
                NF_CT_STAT_INC_ATOMIC(ignore);
                return NF_ACCEPT;
        }
 
        /* rcu_read_lock()ed by nf_hook_slow */
        l3proto = __nf_ct_l3proto_find((u_int16_t)pf);
-       ret = l3proto->get_l4proto(*pskb, skb_network_offset(*pskb),
+       ret = l3proto->get_l4proto(skb, skb_network_offset(skb),
                                   &dataoff, &protonum);
        if (ret <= 0) {
                pr_debug("not prepared to track yet or error occured\n");
@@ -667,13 +666,13 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
         * inverse of the return code tells to the netfilter
         * core what to do with the packet. */
        if (l4proto->error != NULL &&
-           (ret = l4proto->error(*pskb, dataoff, &ctinfo, pf, hooknum)) <= 0) {
+           (ret = l4proto->error(skb, dataoff, &ctinfo, pf, hooknum)) <= 0) {
                NF_CT_STAT_INC_ATOMIC(error);
                NF_CT_STAT_INC_ATOMIC(invalid);
                return -ret;
        }
 
-       ct = resolve_normal_ct(*pskb, dataoff, pf, protonum, l3proto, l4proto,
+       ct = resolve_normal_ct(skb, dataoff, pf, protonum, l3proto, l4proto,
                               &set_reply, &ctinfo);
        if (!ct) {
                /* Not valid part of a connection */
@@ -687,21 +686,21 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
                return NF_DROP;
        }
 
-       NF_CT_ASSERT((*pskb)->nfct);
+       NF_CT_ASSERT(skb->nfct);
 
-       ret = l4proto->packet(ct, *pskb, dataoff, ctinfo, pf, hooknum);
+       ret = l4proto->packet(ct, skb, dataoff, ctinfo, pf, hooknum);
        if (ret < 0) {
                /* Invalid: inverse of the return code tells
                 * the netfilter core what to do */
                pr_debug("nf_conntrack_in: Can't track with proto module\n");
-               nf_conntrack_put((*pskb)->nfct);
-               (*pskb)->nfct = NULL;
+               nf_conntrack_put(skb->nfct);
+               skb->nfct = NULL;
                NF_CT_STAT_INC_ATOMIC(invalid);
                return -ret;
        }
 
        if (set_reply && !test_and_set_bit(IPS_SEEN_REPLY_BIT, &ct->status))
-               nf_conntrack_event_cache(IPCT_STATUS, *pskb);
+               nf_conntrack_event_cache(IPCT_STATUS, skb);
 
        return ret;
 }
@@ -826,44 +825,41 @@ EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
 #include <linux/netfilter/nfnetlink_conntrack.h>
 #include <linux/mutex.h>
 
-
 /* Generic function for tcp/udp/sctp/dccp and alike. This needs to be
  * in ip_conntrack_core, since we don't want the protocols to autoload
  * or depend on ctnetlink */
-int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb,
+int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb,
                               const struct nf_conntrack_tuple *tuple)
 {
-       NFA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(u_int16_t),
+       NLA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(u_int16_t),
                &tuple->src.u.tcp.port);
-       NFA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(u_int16_t),
+       NLA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(u_int16_t),
                &tuple->dst.u.tcp.port);
        return 0;
 
-nfattr_failure:
+nla_put_failure:
        return -1;
 }
-EXPORT_SYMBOL_GPL(nf_ct_port_tuple_to_nfattr);
+EXPORT_SYMBOL_GPL(nf_ct_port_tuple_to_nlattr);
 
-static const size_t cta_min_proto[CTA_PROTO_MAX] = {
-       [CTA_PROTO_SRC_PORT-1]  = sizeof(u_int16_t),
-       [CTA_PROTO_DST_PORT-1]  = sizeof(u_int16_t)
+const struct nla_policy nf_ct_port_nla_policy[CTA_PROTO_MAX+1] = {
+       [CTA_PROTO_SRC_PORT]  = { .type = NLA_U16 },
+       [CTA_PROTO_DST_PORT]  = { .type = NLA_U16 },
 };
+EXPORT_SYMBOL_GPL(nf_ct_port_nla_policy);
 
-int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[],
+int nf_ct_port_nlattr_to_tuple(struct nlattr *tb[],
                               struct nf_conntrack_tuple *t)
 {
-       if (!tb[CTA_PROTO_SRC_PORT-1] || !tb[CTA_PROTO_DST_PORT-1])
-               return -EINVAL;
-
-       if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
+       if (!tb[CTA_PROTO_SRC_PORT] || !tb[CTA_PROTO_DST_PORT])
                return -EINVAL;
 
-       t->src.u.tcp.port = *(__be16 *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]);
-       t->dst.u.tcp.port = *(__be16 *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
+       t->src.u.tcp.port = *(__be16 *)nla_data(tb[CTA_PROTO_SRC_PORT]);
+       t->dst.u.tcp.port = *(__be16 *)nla_data(tb[CTA_PROTO_DST_PORT]);
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(nf_ct_port_nfattr_to_tuple);
+EXPORT_SYMBOL_GPL(nf_ct_port_nlattr_to_tuple);
 #endif
 
 /* Used by ipt_REJECT and ip6t_REJECT. */