1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/module.h>
16#include <linux/spinlock.h>
17#include <linux/netfilter/x_tables.h>
18#include <linux/netfilter_bridge/ebtables.h>
19#include <linux/netfilter_bridge/ebt_nflog.h>
20#include <net/netfilter/nf_log.h>
21
22static unsigned int
23ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
24{
25 const struct ebt_nflog_info *info = par->targinfo;
26 struct net *net = xt_net(par);
27 struct nf_loginfo li;
28
29 li.type = NF_LOG_TYPE_ULOG;
30 li.u.ulog.copy_len = info->len;
31 li.u.ulog.group = info->group;
32 li.u.ulog.qthreshold = info->threshold;
33 li.u.ulog.flags = 0;
34
35 nf_log_packet(net, PF_BRIDGE, xt_hooknum(par), skb, xt_in(par),
36 xt_out(par), &li, "%s", info->prefix);
37 return EBT_CONTINUE;
38}
39
40static int ebt_nflog_tg_check(const struct xt_tgchk_param *par)
41{
42 struct ebt_nflog_info *info = par->targinfo;
43
44 if (info->flags & ~EBT_NFLOG_MASK)
45 return -EINVAL;
46 info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
47 return 0;
48}
49
50static struct xt_target ebt_nflog_tg_reg __read_mostly = {
51 .name = "nflog",
52 .revision = 0,
53 .family = NFPROTO_BRIDGE,
54 .target = ebt_nflog_tg,
55 .checkentry = ebt_nflog_tg_check,
56 .targetsize = sizeof(struct ebt_nflog_info),
57 .me = THIS_MODULE,
58};
59
60static int __init ebt_nflog_init(void)
61{
62 return xt_register_target(&ebt_nflog_tg_reg);
63}
64
65static void __exit ebt_nflog_fini(void)
66{
67 xt_unregister_target(&ebt_nflog_tg_reg);
68}
69
70module_init(ebt_nflog_init);
71module_exit(ebt_nflog_fini);
72MODULE_LICENSE("GPL");
73MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
74MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");
75