Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ceceae1b authored by Yasuyuki Kozakai's avatar Yasuyuki Kozakai Committed by David S. Miller
Browse files

[NETFILTER]: nf_conntrack: use extension infrastructure for helper

parent ecfab2c9
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -294,32 +294,6 @@ static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
	offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
	return (struct nf_conn_nat *) ((void *)ct + offset);
}

static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
{
	unsigned int offset = sizeof(struct nf_conn);

	if (!(ct->features & NF_CT_F_HELP))
		return NULL;
	if (ct->features & NF_CT_F_NAT) {
		offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
		offset += sizeof(struct nf_conn_nat);
	}

	offset = ALIGN(offset, __alignof__(struct nf_conn_help));
	return (struct nf_conn_help *) ((void *)ct + offset);
}
#else /* No NAT */
static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
{
	unsigned int offset = sizeof(struct nf_conn);

	if (!(ct->features & NF_CT_F_HELP))
		return NULL;

	offset = ALIGN(offset, __alignof__(struct nf_conn_help));
	return (struct nf_conn_help *) ((void *)ct + offset);
}
#endif /* CONFIG_NF_NAT_NEEDED */
#endif /* __KERNEL__ */
#endif /* _NF_CONNTRACK_H */
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ extern void nf_conntrack_cleanup(void);
extern int nf_conntrack_proto_init(void);
extern void nf_conntrack_proto_fini(void);

extern int nf_conntrack_helper_init(void);
extern void nf_conntrack_helper_fini(void);

struct nf_conntrack_l3proto;
extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf);
/* Like above, but you already have conntrack read lock. */
+3 −0
Original line number Diff line number Diff line
@@ -5,9 +5,12 @@

enum nf_ct_ext_id
{
	NF_CT_EXT_HELPER,
	NF_CT_EXT_NUM,
};

#define NF_CT_EXT_HELPER_TYPE struct nf_conn_help

/* Extensions: optional stuff which isn't permanently in struct. */
struct nf_ct_ext {
	u8 offset[NF_CT_EXT_NUM];
+5 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#ifndef _NF_CONNTRACK_HELPER_H
#define _NF_CONNTRACK_HELPER_H
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_extend.h>

struct module;

@@ -52,4 +53,8 @@ extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);
extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);

static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
{
	return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
}
#endif /*_NF_CONNTRACK_HELPER_H*/
+0 −10
Original line number Diff line number Diff line
@@ -338,14 +338,6 @@ static int __init nf_nat_standalone_init(void)
		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;
@@ -370,8 +362,6 @@ static int __init nf_nat_standalone_init(void)
	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;
}
Loading