Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /* This is a module which is used to mark packets for tracing.
0003  */
0004 #include <linux/module.h>
0005 #include <linux/skbuff.h>
0006 
0007 #include <linux/netfilter/x_tables.h>
0008 #include <net/netfilter/nf_log.h>
0009 
0010 MODULE_DESCRIPTION("Xtables: packet flow tracing");
0011 MODULE_LICENSE("GPL");
0012 MODULE_ALIAS("ipt_TRACE");
0013 MODULE_ALIAS("ip6t_TRACE");
0014 
0015 static int trace_tg_check(const struct xt_tgchk_param *par)
0016 {
0017     return nf_logger_find_get(par->family, NF_LOG_TYPE_LOG);
0018 }
0019 
0020 static void trace_tg_destroy(const struct xt_tgdtor_param *par)
0021 {
0022     nf_logger_put(par->family, NF_LOG_TYPE_LOG);
0023 }
0024 
0025 static unsigned int
0026 trace_tg(struct sk_buff *skb, const struct xt_action_param *par)
0027 {
0028     skb->nf_trace = 1;
0029     return XT_CONTINUE;
0030 }
0031 
0032 static struct xt_target trace_tg_reg __read_mostly = {
0033     .name       = "TRACE",
0034     .revision   = 0,
0035     .family     = NFPROTO_UNSPEC,
0036     .table      = "raw",
0037     .target     = trace_tg,
0038     .checkentry = trace_tg_check,
0039     .destroy    = trace_tg_destroy,
0040     .me     = THIS_MODULE,
0041 };
0042 
0043 static int __init trace_tg_init(void)
0044 {
0045     return xt_register_target(&trace_tg_reg);
0046 }
0047 
0048 static void __exit trace_tg_exit(void)
0049 {
0050     xt_unregister_target(&trace_tg_reg);
0051 }
0052 
0053 module_init(trace_tg_init);
0054 module_exit(trace_tg_exit);
0055 MODULE_SOFTDEP("pre: nf_log_syslog");