Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * ebt_nflog
0004  *
0005  *  Author:
0006  *  Peter Warasin <peter@endian.com>
0007  *
0008  *  February, 2008
0009  *
0010  * Based on:
0011  *  xt_NFLOG.c, (C) 2006 by Patrick McHardy <kaber@trash.net>
0012  *  ebt_ulog.c, (C) 2004 by Bart De Schuymer <bdschuym@pandora.be>
0013  *
0014  */
0015 
0016 #include <linux/module.h>
0017 #include <linux/spinlock.h>
0018 #include <linux/netfilter/x_tables.h>
0019 #include <linux/netfilter_bridge/ebtables.h>
0020 #include <linux/netfilter_bridge/ebt_nflog.h>
0021 #include <net/netfilter/nf_log.h>
0022 
0023 static unsigned int
0024 ebt_nflog_tg(struct sk_buff *skb, const struct xt_action_param *par)
0025 {
0026     const struct ebt_nflog_info *info = par->targinfo;
0027     struct net *net = xt_net(par);
0028     struct nf_loginfo li;
0029 
0030     li.type = NF_LOG_TYPE_ULOG;
0031     li.u.ulog.copy_len = info->len;
0032     li.u.ulog.group = info->group;
0033     li.u.ulog.qthreshold = info->threshold;
0034     li.u.ulog.flags = 0;
0035 
0036     nf_log_packet(net, PF_BRIDGE, xt_hooknum(par), skb, xt_in(par),
0037               xt_out(par), &li, "%s", info->prefix);
0038     return EBT_CONTINUE;
0039 }
0040 
0041 static int ebt_nflog_tg_check(const struct xt_tgchk_param *par)
0042 {
0043     struct ebt_nflog_info *info = par->targinfo;
0044 
0045     if (info->flags & ~EBT_NFLOG_MASK)
0046         return -EINVAL;
0047     info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
0048     return 0;
0049 }
0050 
0051 static struct xt_target ebt_nflog_tg_reg __read_mostly = {
0052     .name       = "nflog",
0053     .revision   = 0,
0054     .family     = NFPROTO_BRIDGE,
0055     .target     = ebt_nflog_tg,
0056     .checkentry = ebt_nflog_tg_check,
0057     .targetsize = sizeof(struct ebt_nflog_info),
0058     .me         = THIS_MODULE,
0059 };
0060 
0061 static int __init ebt_nflog_init(void)
0062 {
0063     return xt_register_target(&ebt_nflog_tg_reg);
0064 }
0065 
0066 static void __exit ebt_nflog_fini(void)
0067 {
0068     xt_unregister_target(&ebt_nflog_tg_reg);
0069 }
0070 
0071 module_init(ebt_nflog_init);
0072 module_exit(ebt_nflog_fini);
0073 MODULE_LICENSE("GPL");
0074 MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
0075 MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");