rtc: struct device: replace bus_id with dev_name(), dev_set_name()
[safe/jmp/linux-2.6] / net / ipv4 / netfilter / ip_queue.c
index 7361315..432ce9d 100644 (file)
@@ -156,7 +156,6 @@ 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:
@@ -224,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 "ip_queue: error creating packet message\n");
        return NULL;
@@ -283,8 +280,8 @@ static int
 ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
 {
        int diff;
-       int err;
        struct iphdr *user_iph = (struct iphdr *)v->payload;
+       struct sk_buff *nskb;
 
        if (v->data_len < sizeof(*user_iph))
                return 0;
@@ -296,14 +293,15 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
                if (v->data_len > 0xFFFF)
                        return -EINVAL;
                if (diff > skb_tailroom(e->skb)) {
-                       err = pskb_expand_head(e->skb, 0,
-                                              diff - skb_tailroom(e->skb),
-                                              GFP_ATOMIC);
-                       if (err) {
+                       nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
+                                              diff, GFP_ATOMIC);
+                       if (!nskb) {
                                printk(KERN_WARNING "ip_queue: error "
-                                     "in mangle, dropping packet: %d\n", -err);
-                               return err;
+                                     "in mangle, dropping packet\n");
+                               return -ENOMEM;
                        }
+                       kfree_skb(e->skb);
+                       e->skb = nskb;
                }
                skb_put(e->skb, diff);
        }
@@ -479,7 +477,7 @@ ipq_rcv_dev_event(struct notifier_block *this,
 {
        struct net_device *dev = ptr;
 
-       if (dev->nd_net != &init_net)
+       if (!net_eq(dev_net(dev), &init_net))
                return NOTIFY_DONE;
 
        /* Drop any packets associated with the downed device */
@@ -512,6 +510,7 @@ static struct notifier_block ipq_nl_notifier = {
        .notifier_call  = ipq_rcv_nl_event,
 };
 
+#ifdef CONFIG_SYSCTL
 static struct ctl_table_header *ipq_sysctl_header;
 
 static ctl_table ipq_table[] = {
@@ -525,7 +524,9 @@ static ctl_table ipq_table[] = {
        },
        { .ctl_name = 0 }
 };
+#endif
 
+#ifdef CONFIG_PROC_FS
 static int ip_queue_show(struct seq_file *m, void *v)
 {
        read_lock_bh(&queue_lock);
@@ -562,6 +563,7 @@ static const struct file_operations ip_queue_proc_fops = {
        .release        = single_release,
        .owner          = THIS_MODULE,
 };
+#endif
 
 static const struct nf_queue_handler nfqh = {
        .name   = "ip_queue",
@@ -571,7 +573,7 @@ static const struct nf_queue_handler nfqh = {
 static int __init ip_queue_init(void)
 {
        int status = -ENOMEM;
-       struct proc_dir_entry *proc;
+       struct proc_dir_entry *proc __maybe_unused;
 
        netlink_register_notifier(&ipq_nl_notifier);
        ipqnl = netlink_kernel_create(&init_net, NETLINK_FIREWALL, 0,
@@ -581,18 +583,18 @@ static int __init ip_queue_init(void)
                goto cleanup_netlink_notifier;
        }
 
-       proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
-       if (proc) {
-               proc->owner = THIS_MODULE;
-               proc->proc_fops = &ip_queue_proc_fops;
-       } else {
+#ifdef CONFIG_PROC_FS
+       proc = proc_create(IPQ_PROC_FS_NAME, 0, init_net.proc_net,
+                          &ip_queue_proc_fops);
+       if (!proc) {
                printk(KERN_ERR "ip_queue: failed to create proc entry\n");
                goto cleanup_ipqnl;
        }
-
+#endif
        register_netdevice_notifier(&ipq_dev_notifier);
+#ifdef CONFIG_SYSCTL
        ipq_sysctl_header = register_sysctl_paths(net_ipv4_ctl_path, ipq_table);
-
+#endif
        status = nf_register_queue_handler(PF_INET, &nfqh);
        if (status < 0) {
                printk(KERN_ERR "ip_queue: failed to register queue handler\n");
@@ -601,11 +603,13 @@ static int __init ip_queue_init(void)
        return status;
 
 cleanup_sysctl:
+#ifdef CONFIG_SYSCTL
        unregister_sysctl_table(ipq_sysctl_header);
+#endif
        unregister_netdevice_notifier(&ipq_dev_notifier);
        proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
-cleanup_ipqnl:
-       sock_release(ipqnl->sk_socket);
+cleanup_ipqnl: __maybe_unused
+       netlink_kernel_release(ipqnl);
        mutex_lock(&ipqnl_mutex);
        mutex_unlock(&ipqnl_mutex);
 
@@ -620,11 +624,13 @@ static void __exit ip_queue_fini(void)
        synchronize_net();
        ipq_flush(NULL, 0);
 
+#ifdef CONFIG_SYSCTL
        unregister_sysctl_table(ipq_sysctl_header);
+#endif
        unregister_netdevice_notifier(&ipq_dev_notifier);
        proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
 
-       sock_release(ipqnl->sk_socket);
+       netlink_kernel_release(ipqnl);
        mutex_lock(&ipqnl_mutex);
        mutex_unlock(&ipqnl_mutex);