Ejemplo n.º 1
0
static int __init nf_nat_standalone_init(void)
{
    int ret = 0;

    need_ipv4_conntrack();

#ifdef CONFIG_XFRM
    BUG_ON(ip_nat_decode_session != NULL);
    rcu_assign_pointer_nonull(ip_nat_decode_session, nat_decode_session);
#endif
    ret = nf_nat_rule_init();
    if (ret < 0) {
        pr_err("nf_nat_init: can't setup rules.\n");
        goto cleanup_decode_session;
    }
    ret = nf_register_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops));
    if (ret < 0) {
        pr_err("nf_nat_init: can't register hooks.\n");
        goto cleanup_rule_init;
    }
    return ret;

cleanup_rule_init:
    nf_nat_rule_cleanup();
cleanup_decode_session:
#ifdef CONFIG_XFRM
    rcu_assign_pointer(ip_nat_decode_session, NULL);
    synchronize_net();
#endif
    return ret;
}
Ejemplo n.º 2
0
static void __exit nf_nat_standalone_fini(void)
{
    nf_unregister_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops));
    nf_nat_rule_cleanup();
#ifdef CONFIG_XFRM
    rcu_assign_pointer(ip_nat_decode_session, NULL);
    synchronize_net();
#endif
    /* Conntrack caches are unregistered in nf_conntrack_cleanup */
}
Ejemplo n.º 3
0
static void __exit nf_nat_standalone_fini(void)
{
	nf_unregister_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops));
	nf_nat_rule_cleanup();
	nf_nat_module_is_loaded = 0;
#ifdef CONFIG_XFRM
	ip_nat_decode_session = NULL;
	synchronize_net();
#endif
	/* Conntrack caches are unregistered in nf_conntrack_cleanup */
}
Ejemplo n.º 4
0
static int __init nf_nat_standalone_init(void)
{
	int size, ret = 0;

	need_conntrack();

	size = ALIGN(sizeof(struct nf_conn), __alignof__(struct nf_conn_nat)) +
	       sizeof(struct nf_conn_nat);
	ret = nf_conntrack_register_cache(NF_CT_F_NAT, "nf_nat:base", size);
	if (ret < 0) {
		printk(KERN_ERR "nf_nat_init: Unable to create slab cache\n");
		return ret;
	}

	size = ALIGN(size, __alignof__(struct nf_conn_help)) +
	       sizeof(struct nf_conn_help);
	ret = nf_conntrack_register_cache(NF_CT_F_NAT|NF_CT_F_HELP,
					  "nf_nat:help", size);
	if (ret < 0) {
		printk(KERN_ERR "nf_nat_init: Unable to create slab cache\n");
		goto cleanup_register_cache;
	}
#ifdef CONFIG_XFRM
	BUG_ON(ip_nat_decode_session != NULL);
	ip_nat_decode_session = nat_decode_session;
#endif
	ret = nf_nat_rule_init();
	if (ret < 0) {
		printk("nf_nat_init: can't setup rules.\n");
		goto cleanup_decode_session;
	}
	ret = nf_register_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops));
	if (ret < 0) {
		printk("nf_nat_init: can't register hooks.\n");
		goto cleanup_rule_init;
	}
	nf_nat_module_is_loaded = 1;
	return ret;

 cleanup_rule_init:
	nf_nat_rule_cleanup();
 cleanup_decode_session:
#ifdef CONFIG_XFRM
	ip_nat_decode_session = NULL;
	synchronize_net();
#endif
	nf_conntrack_unregister_cache(NF_CT_F_NAT|NF_CT_F_HELP);
 cleanup_register_cache:
	nf_conntrack_unregister_cache(NF_CT_F_NAT);
	return ret;
}