netfilter: only do skb_checksum_help on CHECKSUM_PARTIAL in ip6_queue
[safe/jmp/linux-2.6] / net / ipv6 / netfilter / ip6_queue.c
index a6d3062..39856a2 100644 (file)
@@ -36,7 +36,6 @@
 
 #define IPQ_QMAX_DEFAULT 1024
 #define IPQ_PROC_FS_NAME "ip6_queue"
-#define NET_IPQ_QMAX 2088
 #define NET_IPQ_QMAX_NAME "ip6_queue_maxlen"
 
 typedef int (*ipq_cmpfn)(struct nf_queue_entry *, unsigned long);
@@ -159,12 +158,10 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)
        case IPQ_COPY_META:
        case IPQ_COPY_NONE:
                size = NLMSG_SPACE(sizeof(*pmsg));
-               data_len = 0;
                break;
 
        case IPQ_COPY_PACKET:
-               if ((entry->skb->ip_summed == CHECKSUM_PARTIAL ||
-                    entry->skb->ip_summed == CHECKSUM_COMPLETE) &&
+               if (entry->skb->ip_summed == CHECKSUM_PARTIAL &&
                    (*errp = skb_checksum_help(entry->skb))) {
                        read_unlock_bh(&queue_lock);
                        return NULL;
@@ -226,8 +223,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)
        return skb;
 
 nlmsg_failure:
-       if (skb)
-               kfree_skb(skb);
        *errp = -EINVAL;
        printk(KERN_ERR "ip6_queue: error creating packet message\n");
        return NULL;
@@ -298,9 +293,8 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
                if (v->data_len > 0xFFFF)
                        return -EINVAL;
                if (diff > skb_tailroom(e->skb)) {
-                       nskb = skb_copy_expand(e->skb, 0,
-                                              diff - skb_tailroom(e->skb),
-                                              GFP_ATOMIC);
+                       nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
+                                              diff, GFP_ATOMIC);
                        if (!nskb) {
                                printk(KERN_WARNING "ip6_queue: OOM "
                                      "in mangle, dropping packet\n");
@@ -484,7 +478,7 @@ ipq_rcv_dev_event(struct notifier_block *this,
 {
        struct net_device *dev = ptr;
 
-       if (dev_net(dev) != &init_net)
+       if (!net_eq(dev_net(dev), &init_net))
                return NOTIFY_DONE;
 
        /* Drop any packets associated with the downed device */
@@ -503,10 +497,9 @@ ipq_rcv_nl_event(struct notifier_block *this,
 {
        struct netlink_notify *n = ptr;
 
-       if (event == NETLINK_URELEASE &&
-           n->protocol == NETLINK_IP6_FW && n->pid) {
+       if (event == NETLINK_URELEASE && n->protocol == NETLINK_IP6_FW) {
                write_lock_bh(&queue_lock);
-               if ((n->net == &init_net) && (n->pid == peer_pid))
+               if ((net_eq(n->net, &init_net)) && (n->pid == peer_pid))
                        __ipq_reset();
                write_unlock_bh(&queue_lock);
        }
@@ -522,14 +515,13 @@ static struct ctl_table_header *ipq_sysctl_header;
 
 static ctl_table ipq_table[] = {
        {
-               .ctl_name       = NET_IPQ_QMAX,
                .procname       = NET_IPQ_QMAX_NAME,
                .data           = &queue_maxlen,
                .maxlen         = sizeof(queue_maxlen),
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
-       { .ctl_name = 0 }
+       { }
 };
 #endif
 
@@ -591,11 +583,9 @@ static int __init ip6_queue_init(void)
        }
 
 #ifdef CONFIG_PROC_FS
-       proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
-       if (proc) {
-               proc->owner = THIS_MODULE;
-               proc->proc_fops = &ip6_queue_proc_fops;
-       } else {
+       proc = proc_create(IPQ_PROC_FS_NAME, 0, init_net.proc_net,
+                          &ip6_queue_proc_fops);
+       if (!proc) {
                printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
                goto cleanup_ipqnl;
        }
@@ -604,7 +594,7 @@ static int __init ip6_queue_init(void)
 #ifdef CONFIG_SYSCTL
        ipq_sysctl_header = register_sysctl_paths(net_ipv6_ctl_path, ipq_table);
 #endif
-       status = nf_register_queue_handler(PF_INET6, &nfqh);
+       status = nf_register_queue_handler(NFPROTO_IPV6, &nfqh);
        if (status < 0) {
                printk(KERN_ERR "ip6_queue: failed to register queue handler\n");
                goto cleanup_sysctl;
@@ -631,7 +621,7 @@ cleanup_netlink_notifier:
 static void __exit ip6_queue_fini(void)
 {
        nf_unregister_queue_handlers(&nfqh);
-       synchronize_net();
+
        ipq_flush(NULL, 0);
 
 #ifdef CONFIG_SYSCTL
@@ -649,6 +639,7 @@ static void __exit ip6_queue_fini(void)
 
 MODULE_DESCRIPTION("IPv6 packet queue handler");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_IP6_FW);
 
 module_init(ip6_queue_init);
 module_exit(ip6_queue_fini);