2007-07-08 05:23:21 +00:00
|
|
|
#ifndef _NF_CONNTRACK_EXTEND_H
|
|
|
|
#define _NF_CONNTRACK_EXTEND_H
|
|
|
|
|
|
|
|
#include <net/netfilter/nf_conntrack.h>
|
|
|
|
|
|
|
|
enum nf_ct_ext_id
|
|
|
|
{
|
2007-07-08 05:23:42 +00:00
|
|
|
NF_CT_EXT_HELPER,
|
2007-07-08 05:24:28 +00:00
|
|
|
NF_CT_EXT_NAT,
|
netfilter: accounting rework: ct_extend + 64bit counters (v4)
Initially netfilter has had 64bit counters for conntrack-based accounting, but
it was changed in 2.6.14 to save memory. Unfortunately in-kernel 64bit counters are
still required, for example for "connbytes" extension. However, 64bit counters
waste a lot of memory and it was not possible to enable/disable it runtime.
This patch:
- reimplements accounting with respect to the extension infrastructure,
- makes one global version of seq_print_acct() instead of two seq_print_counters(),
- makes it possible to enable it at boot time (for CONFIG_SYSCTL/CONFIG_SYSFS=n),
- makes it possible to enable/disable it at runtime by sysctl or sysfs,
- extends counters from 32bit to 64bit,
- renames ip_conntrack_counter -> nf_conn_counter,
- enables accounting code unconditionally (no longer depends on CONFIG_NF_CT_ACCT),
- set initial accounting enable state based on CONFIG_NF_CT_ACCT
- removes buggy IPCT_COUNTER_FILLING event handling.
If accounting is enabled newly created connections get additional acct extend.
Old connections are not changed as it is not possible to add a ct_extend area
to confirmed conntrack. Accounting is performed for all connections with
acct extend regardless of a current state of "net.netfilter.nf_conntrack_acct".
Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-07-21 17:01:34 +00:00
|
|
|
NF_CT_EXT_ACCT,
|
2009-06-13 10:26:29 +00:00
|
|
|
NF_CT_EXT_ECACHE,
|
2007-07-08 05:23:21 +00:00
|
|
|
NF_CT_EXT_NUM,
|
|
|
|
};
|
|
|
|
|
2007-07-08 05:23:42 +00:00
|
|
|
#define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
|
2007-07-08 05:24:28 +00:00
|
|
|
#define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
|
netfilter: accounting rework: ct_extend + 64bit counters (v4)
Initially netfilter has had 64bit counters for conntrack-based accounting, but
it was changed in 2.6.14 to save memory. Unfortunately in-kernel 64bit counters are
still required, for example for "connbytes" extension. However, 64bit counters
waste a lot of memory and it was not possible to enable/disable it runtime.
This patch:
- reimplements accounting with respect to the extension infrastructure,
- makes one global version of seq_print_acct() instead of two seq_print_counters(),
- makes it possible to enable it at boot time (for CONFIG_SYSCTL/CONFIG_SYSFS=n),
- makes it possible to enable/disable it at runtime by sysctl or sysfs,
- extends counters from 32bit to 64bit,
- renames ip_conntrack_counter -> nf_conn_counter,
- enables accounting code unconditionally (no longer depends on CONFIG_NF_CT_ACCT),
- set initial accounting enable state based on CONFIG_NF_CT_ACCT
- removes buggy IPCT_COUNTER_FILLING event handling.
If accounting is enabled newly created connections get additional acct extend.
Old connections are not changed as it is not possible to add a ct_extend area
to confirmed conntrack. Accounting is performed for all connections with
acct extend regardless of a current state of "net.netfilter.nf_conntrack_acct".
Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-07-21 17:01:34 +00:00
|
|
|
#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
|
2009-06-13 10:26:29 +00:00
|
|
|
#define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache
|
2007-07-08 05:23:42 +00:00
|
|
|
|
2007-07-08 05:23:21 +00:00
|
|
|
/* Extensions: optional stuff which isn't permanently in struct. */
|
|
|
|
struct nf_ct_ext {
|
2008-06-17 22:51:47 +00:00
|
|
|
struct rcu_head rcu;
|
2007-07-08 05:23:21 +00:00
|
|
|
u8 offset[NF_CT_EXT_NUM];
|
|
|
|
u8 len;
|
|
|
|
char data[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int nf_ct_ext_exist(const struct nf_conn *ct, u8 id)
|
|
|
|
{
|
|
|
|
return (ct->ext && ct->ext->offset[id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *__nf_ct_ext_find(const struct nf_conn *ct, u8 id)
|
|
|
|
{
|
|
|
|
if (!nf_ct_ext_exist(ct, id))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (void *)ct->ext + ct->ext->offset[id];
|
|
|
|
}
|
|
|
|
#define nf_ct_ext_find(ext, id) \
|
|
|
|
((id##_TYPE *)__nf_ct_ext_find((ext), (id)))
|
|
|
|
|
|
|
|
/* Destroy all relationships */
|
|
|
|
extern void __nf_ct_ext_destroy(struct nf_conn *ct);
|
|
|
|
static inline void nf_ct_ext_destroy(struct nf_conn *ct)
|
|
|
|
{
|
|
|
|
if (ct->ext)
|
|
|
|
__nf_ct_ext_destroy(ct);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free operation. If you want to free a object referred from private area,
|
|
|
|
* please implement __nf_ct_ext_free() and call it.
|
|
|
|
*/
|
|
|
|
static inline void nf_ct_ext_free(struct nf_conn *ct)
|
|
|
|
{
|
|
|
|
if (ct->ext)
|
|
|
|
kfree(ct->ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add this type, returns pointer to data or NULL. */
|
|
|
|
void *
|
|
|
|
__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp);
|
|
|
|
#define nf_ct_ext_add(ct, id, gfp) \
|
|
|
|
((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp)))
|
|
|
|
|
|
|
|
#define NF_CT_EXT_F_PREALLOC 0x0001
|
|
|
|
|
|
|
|
struct nf_ct_ext_type
|
|
|
|
{
|
|
|
|
/* Destroys relationships (can be NULL). */
|
|
|
|
void (*destroy)(struct nf_conn *ct);
|
|
|
|
/* Called when realloacted (can be NULL).
|
|
|
|
Contents has already been moved. */
|
2008-02-08 01:56:34 +00:00
|
|
|
void (*move)(void *new, void *old);
|
2007-07-08 05:23:21 +00:00
|
|
|
|
|
|
|
enum nf_ct_ext_id id;
|
|
|
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
|
|
|
/* Length and min alignment. */
|
|
|
|
u8 len;
|
|
|
|
u8 align;
|
|
|
|
/* initial size of nf_ct_ext. */
|
|
|
|
u8 alloc_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
int nf_ct_extend_register(struct nf_ct_ext_type *type);
|
|
|
|
void nf_ct_extend_unregister(struct nf_ct_ext_type *type);
|
|
|
|
#endif /* _NF_CONNTRACK_EXTEND_H */
|