diff options
author | Patrick McHardy <kaber@trash.net> | 2010-10-04 17:24:21 -0400 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-10-04 17:24:21 -0400 |
commit | eecc545856c8a0f27783a440d25f4ceaa1f95ce8 (patch) | |
tree | 7dcfcb0c91c098c6233fb360e0d23cccdef20dc9 /include | |
parent | f68c53015c5b9aa98ffd87a34009f89bdbbd7160 (diff) |
netfilter: add missing xt_log.h file
Forgot to add xt_log.h in commit a8defca0 (netfilter: ipt_LOG:
add bufferisation to call printk() once)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/netfilter/xt_log.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h new file mode 100644 index 000000000000..0dfb34a5b53c --- /dev/null +++ b/include/net/netfilter/xt_log.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #define S_SIZE (1024 - (sizeof(unsigned int) + 1)) | ||
2 | |||
3 | struct sbuff { | ||
4 | unsigned int count; | ||
5 | char buf[S_SIZE + 1]; | ||
6 | }; | ||
7 | static struct sbuff emergency, *emergency_ptr = &emergency; | ||
8 | |||
9 | static int sb_add(struct sbuff *m, const char *f, ...) | ||
10 | { | ||
11 | va_list args; | ||
12 | int len; | ||
13 | |||
14 | if (likely(m->count < S_SIZE)) { | ||
15 | va_start(args, f); | ||
16 | len = vsnprintf(m->buf + m->count, S_SIZE - m->count, f, args); | ||
17 | va_end(args); | ||
18 | if (likely(m->count + len < S_SIZE)) { | ||
19 | m->count += len; | ||
20 | return 0; | ||
21 | } | ||
22 | } | ||
23 | m->count = S_SIZE; | ||
24 | printk_once(KERN_ERR KBUILD_MODNAME " please increase S_SIZE\n"); | ||
25 | return -1; | ||
26 | } | ||
27 | |||
28 | static struct sbuff *sb_open(void) | ||
29 | { | ||
30 | struct sbuff *m = kmalloc(sizeof(*m), GFP_ATOMIC); | ||
31 | |||
32 | if (unlikely(!m)) { | ||
33 | local_bh_disable(); | ||
34 | do { | ||
35 | m = xchg(&emergency_ptr, NULL); | ||
36 | } while (!m); | ||
37 | } | ||
38 | m->count = 0; | ||
39 | return m; | ||
40 | } | ||
41 | |||
42 | static void sb_close(struct sbuff *m) | ||
43 | { | ||
44 | m->buf[m->count] = 0; | ||
45 | printk("%s\n", m->buf); | ||
46 | |||
47 | if (likely(m != &emergency)) | ||
48 | kfree(m); | ||
49 | else { | ||
50 | xchg(&emergency_ptr, m); | ||
51 | local_bh_enable(); | ||
52 | } | ||
53 | } | ||
54 | |||