|
@@ -210,71 +210,63 @@ static unsigned int ipv4_conntrack_local(unsigned int hooknum,
|
|
|
|
|
|
/* Connection tracking may drop packets, but never alters them, so
|
|
|
make it the first hook. */
|
|
|
-static struct nf_hook_ops ipv4_conntrack_defrag_ops = {
|
|
|
- .hook = ipv4_conntrack_defrag,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_PRE_ROUTING,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
|
|
|
-};
|
|
|
-
|
|
|
-static struct nf_hook_ops ipv4_conntrack_in_ops = {
|
|
|
- .hook = ipv4_conntrack_in,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_PRE_ROUTING,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK,
|
|
|
-};
|
|
|
-
|
|
|
-static struct nf_hook_ops ipv4_conntrack_defrag_local_out_ops = {
|
|
|
- .hook = ipv4_conntrack_defrag,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_LOCAL_OUT,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
|
|
|
-};
|
|
|
-
|
|
|
-static struct nf_hook_ops ipv4_conntrack_local_out_ops = {
|
|
|
- .hook = ipv4_conntrack_local,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_LOCAL_OUT,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK,
|
|
|
-};
|
|
|
-
|
|
|
-/* helpers */
|
|
|
-static struct nf_hook_ops ipv4_conntrack_helper_out_ops = {
|
|
|
- .hook = ipv4_conntrack_help,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_POST_ROUTING,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK_HELPER,
|
|
|
-};
|
|
|
-
|
|
|
-static struct nf_hook_ops ipv4_conntrack_helper_in_ops = {
|
|
|
- .hook = ipv4_conntrack_help,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_LOCAL_IN,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK_HELPER,
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-/* Refragmenter; last chance. */
|
|
|
-static struct nf_hook_ops ipv4_conntrack_out_ops = {
|
|
|
- .hook = ipv4_confirm,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_POST_ROUTING,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
|
|
|
-};
|
|
|
-
|
|
|
-static struct nf_hook_ops ipv4_conntrack_local_in_ops = {
|
|
|
- .hook = ipv4_confirm,
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .pf = PF_INET,
|
|
|
- .hooknum = NF_IP_LOCAL_IN,
|
|
|
- .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
|
|
|
+static struct nf_hook_ops ipv4_conntrack_ops[] = {
|
|
|
+ {
|
|
|
+ .hook = ipv4_conntrack_defrag,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_PRE_ROUTING,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_conntrack_in,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_PRE_ROUTING,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_conntrack_defrag,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_LOCAL_OUT,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_conntrack_local,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_LOCAL_OUT,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_conntrack_help,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_POST_ROUTING,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK_HELPER,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_conntrack_help,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_LOCAL_IN,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK_HELPER,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_confirm,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_POST_ROUTING,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .hook = ipv4_confirm,
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .pf = PF_INET,
|
|
|
+ .hooknum = NF_IP_LOCAL_IN,
|
|
|
+ .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
#ifdef CONFIG_SYSCTL
|
|
@@ -476,59 +468,18 @@ static int init_or_cleanup(int init)
|
|
|
goto cleanup_icmp;
|
|
|
}
|
|
|
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_defrag_ops);
|
|
|
+ ret = nf_register_hooks(ipv4_conntrack_ops,
|
|
|
+ ARRAY_SIZE(ipv4_conntrack_ops));
|
|
|
if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register pre-routing defrag hook.\n");
|
|
|
+ printk("nf_conntrack_ipv4: can't register hooks.\n");
|
|
|
goto cleanup_ipv4;
|
|
|
}
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_defrag_local_out_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register local_out defrag hook.\n");
|
|
|
- goto cleanup_defragops;
|
|
|
- }
|
|
|
-
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_in_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register pre-routing hook.\n");
|
|
|
- goto cleanup_defraglocalops;
|
|
|
- }
|
|
|
-
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_local_out_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register local out hook.\n");
|
|
|
- goto cleanup_inops;
|
|
|
- }
|
|
|
-
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_helper_in_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register local helper hook.\n");
|
|
|
- goto cleanup_inandlocalops;
|
|
|
- }
|
|
|
-
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_helper_out_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register postrouting helper hook.\n");
|
|
|
- goto cleanup_helperinops;
|
|
|
- }
|
|
|
-
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_out_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register post-routing hook.\n");
|
|
|
- goto cleanup_helperoutops;
|
|
|
- }
|
|
|
-
|
|
|
- ret = nf_register_hook(&ipv4_conntrack_local_in_ops);
|
|
|
- if (ret < 0) {
|
|
|
- printk("nf_conntrack_ipv4: can't register local in hook.\n");
|
|
|
- goto cleanup_inoutandlocalops;
|
|
|
- }
|
|
|
-
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
nf_ct_ipv4_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
|
|
|
if (nf_ct_ipv4_sysctl_header == NULL) {
|
|
|
printk("nf_conntrack: can't register to sysctl.\n");
|
|
|
ret = -ENOMEM;
|
|
|
- goto cleanup_localinops;
|
|
|
+ goto cleanup_hooks;
|
|
|
}
|
|
|
#endif
|
|
|
return ret;
|
|
@@ -537,23 +488,9 @@ static int init_or_cleanup(int init)
|
|
|
synchronize_net();
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
unregister_sysctl_table(nf_ct_ipv4_sysctl_header);
|
|
|
- cleanup_localinops:
|
|
|
+ cleanup_hooks:
|
|
|
#endif
|
|
|
- nf_unregister_hook(&ipv4_conntrack_local_in_ops);
|
|
|
- cleanup_inoutandlocalops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_out_ops);
|
|
|
- cleanup_helperoutops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_helper_out_ops);
|
|
|
- cleanup_helperinops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_helper_in_ops);
|
|
|
- cleanup_inandlocalops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_local_out_ops);
|
|
|
- cleanup_inops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_in_ops);
|
|
|
- cleanup_defraglocalops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_defrag_local_out_ops);
|
|
|
- cleanup_defragops:
|
|
|
- nf_unregister_hook(&ipv4_conntrack_defrag_ops);
|
|
|
+ nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
|
|
|
cleanup_ipv4:
|
|
|
nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
|
|
|
cleanup_icmp:
|