Merge tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc...
[linux.git] / net / bridge / netfilter / ebt_nflog.c
blob61bf8f4465ab7db82116c35fc69f5099200e6828
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ebt_nflog
5 * Author:
6 * Peter Warasin <peter@endian.com>
8 * February, 2008
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>
16 #include <linux/module.h>
17 #include <linux/spinlock.h>
18 #include <linux/netfilter/x_tables.h>
19 #include <linux/netfilter_bridge/ebtables.h>
20 #include <linux/netfilter_bridge/ebt_nflog.h>
21 #include <net/netfilter/nf_log.h>
23 static unsigned int
24 ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
26 const struct ebt_nflog_info *info = par->targinfo;
27 struct net *net = xt_net(par);
28 struct nf_loginfo li;
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;
34 li.u.ulog.flags = 0;
36 nf_log_packet(net, PF_BRIDGE, xt_hooknum(par), skb, xt_in(par),
37 xt_out(par), &li, "%s", info->prefix);
38 return EBT_CONTINUE;
41 static int ebt_nflog_tg_check(const struct xt_tgchk_param *par)
43 struct ebt_nflog_info *info = par->targinfo;
45 if (info->flags & ~EBT_NFLOG_MASK)
46 return -EINVAL;
47 info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
48 return 0;
51 static struct xt_target ebt_nflog_tg_reg __read_mostly = {
52 .name = "nflog",
53 .revision = 0,
54 .family = NFPROTO_BRIDGE,
55 .target = ebt_nflog_tg,
56 .checkentry = ebt_nflog_tg_check,
57 .targetsize = sizeof(struct ebt_nflog_info),
58 .me = THIS_MODULE,
61 static int __init ebt_nflog_init(void)
63 return xt_register_target(&ebt_nflog_tg_reg);
66 static void __exit ebt_nflog_fini(void)
68 xt_unregister_target(&ebt_nflog_tg_reg);
71 module_init(ebt_nflog_init);
72 module_exit(ebt_nflog_fini);
73 MODULE_LICENSE("GPL");
74 MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
75 MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");