Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * This is a module which is used for setting the skb->priority field
0004  * of an skb for qdisc classification.
0005  */
0006 
0007 /* (C) 2001-2002 Patrick McHardy <kaber@trash.net>
0008  */
0009 
0010 #include <linux/module.h>
0011 #include <linux/skbuff.h>
0012 #include <linux/ip.h>
0013 #include <net/checksum.h>
0014 
0015 #include <linux/netfilter_ipv4.h>
0016 #include <linux/netfilter_ipv6.h>
0017 #include <linux/netfilter/x_tables.h>
0018 #include <linux/netfilter/xt_CLASSIFY.h>
0019 #include <linux/netfilter_arp.h>
0020 
0021 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
0022 MODULE_LICENSE("GPL");
0023 MODULE_DESCRIPTION("Xtables: Qdisc classification");
0024 MODULE_ALIAS("ipt_CLASSIFY");
0025 MODULE_ALIAS("ip6t_CLASSIFY");
0026 MODULE_ALIAS("arpt_CLASSIFY");
0027 
0028 static unsigned int
0029 classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
0030 {
0031     const struct xt_classify_target_info *clinfo = par->targinfo;
0032 
0033     skb->priority = clinfo->priority;
0034     return XT_CONTINUE;
0035 }
0036 
0037 static struct xt_target classify_tg_reg[] __read_mostly = {
0038     {
0039         .name       = "CLASSIFY",
0040         .revision   = 0,
0041         .family     = NFPROTO_UNSPEC,
0042         .hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
0043                       (1 << NF_INET_POST_ROUTING),
0044         .target     = classify_tg,
0045         .targetsize = sizeof(struct xt_classify_target_info),
0046         .me         = THIS_MODULE,
0047     },
0048     {
0049         .name       = "CLASSIFY",
0050         .revision   = 0,
0051         .family     = NFPROTO_ARP,
0052         .hooks      = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
0053         .target     = classify_tg,
0054         .targetsize = sizeof(struct xt_classify_target_info),
0055         .me         = THIS_MODULE,
0056     },
0057 };
0058 
0059 static int __init classify_tg_init(void)
0060 {
0061     return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
0062 }
0063 
0064 static void __exit classify_tg_exit(void)
0065 {
0066     xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
0067 }
0068 
0069 module_init(classify_tg_init);
0070 module_exit(classify_tg_exit);