treewide: Add SPDX license identifier for more missed files
[linux-2.6-block.git] / net / bridge / netfilter / ebt_nflog.c
CommitLineData
09c434b8 1// SPDX-License-Identifier: GPL-2.0-only
e7bfd0a1
PW
2/*
3 * ebt_nflog
4 *
5 * Author:
6 * Peter Warasin <peter@endian.com>
7 *
8 * February, 2008
9 *
10 * Based on:
11 * xt_NFLOG.c, (C) 2006 by Patrick McHardy <kaber@trash.net>
12 * ebt_ulog.c, (C) 2004 by Bart De Schuymer <bdschuym@pandora.be>
13 *
14 */
15
16#include <linux/module.h>
17#include <linux/spinlock.h>
18219d3f 18#include <linux/netfilter/x_tables.h>
e7bfd0a1
PW
19#include <linux/netfilter_bridge/ebtables.h>
20#include <linux/netfilter_bridge/ebt_nflog.h>
21#include <net/netfilter/nf_log.h>
22
2d06d4a5 23static unsigned int
4b560b44 24ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
e7bfd0a1 25{
7eb35586 26 const struct ebt_nflog_info *info = par->targinfo;
613dbd95 27 struct net *net = xt_net(par);
e7bfd0a1
PW
28 struct nf_loginfo li;
29
30 li.type = NF_LOG_TYPE_ULOG;
31 li.u.ulog.copy_len = info->len;
32 li.u.ulog.group = info->group;
33 li.u.ulog.qthreshold = info->threshold;
91af6ba7 34 li.u.ulog.flags = 0;
e7bfd0a1 35
613dbd95
PNA
36 nf_log_packet(net, PF_BRIDGE, xt_hooknum(par), skb, xt_in(par),
37 xt_out(par), &li, "%s", info->prefix);
0ac6ab1f 38 return EBT_CONTINUE;
e7bfd0a1
PW
39}
40
135367b8 41static int ebt_nflog_tg_check(const struct xt_tgchk_param *par)
e7bfd0a1 42{
af5d6dc2 43 struct ebt_nflog_info *info = par->targinfo;
e7bfd0a1 44
e7bfd0a1 45 if (info->flags & ~EBT_NFLOG_MASK)
d6b00a53 46 return -EINVAL;
e7bfd0a1 47 info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
d6b00a53 48 return 0;
e7bfd0a1
PW
49}
50
043ef46c
JE
51static struct xt_target ebt_nflog_tg_reg __read_mostly = {
52 .name = "nflog",
53 .revision = 0,
54 .family = NFPROTO_BRIDGE,
55 .target = ebt_nflog_tg,
2d06d4a5 56 .checkentry = ebt_nflog_tg_check,
fc0e3df4 57 .targetsize = sizeof(struct ebt_nflog_info),
043ef46c 58 .me = THIS_MODULE,
e7bfd0a1
PW
59};
60
61static int __init ebt_nflog_init(void)
62{
043ef46c 63 return xt_register_target(&ebt_nflog_tg_reg);
e7bfd0a1
PW
64}
65
66static void __exit ebt_nflog_fini(void)
67{
043ef46c 68 xt_unregister_target(&ebt_nflog_tg_reg);
e7bfd0a1
PW
69}
70
71module_init(ebt_nflog_init);
72module_exit(ebt_nflog_fini);
73MODULE_LICENSE("GPL");
74MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
75MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");