[PATCH] sched: fix interactive ceiling code
[linux-2.6/linux-mips.git] / net / sched / em_u32.c
blob34e7e51e601e0f3e4baec3e5e1dba4ec1a0e8841
1 /*
2 * net/sched/em_u32.c U32 Ematch
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Thomas Graf <tgraf@suug.ch>
10 * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
12 * Based on net/sched/cls_u32.c
15 #include <linux/config.h>
16 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/skbuff.h>
20 #include <net/pkt_cls.h>
22 static int em_u32_match(struct sk_buff *skb, struct tcf_ematch *em,
23 struct tcf_pkt_info *info)
25 struct tc_u32_key *key = (struct tc_u32_key *) em->data;
26 unsigned char *ptr = skb->nh.raw;
28 if (info) {
29 if (info->ptr)
30 ptr = info->ptr;
31 ptr += (info->nexthdr & key->offmask);
34 ptr += key->off;
36 if (!tcf_valid_offset(skb, ptr, sizeof(u32)))
37 return 0;
39 return !(((*(u32*) ptr) ^ key->val) & key->mask);
42 static struct tcf_ematch_ops em_u32_ops = {
43 .kind = TCF_EM_U32,
44 .datalen = sizeof(struct tc_u32_key),
45 .match = em_u32_match,
46 .owner = THIS_MODULE,
47 .link = LIST_HEAD_INIT(em_u32_ops.link)
50 static int __init init_em_u32(void)
52 return tcf_em_register(&em_u32_ops);
55 static void __exit exit_em_u32(void)
57 tcf_em_unregister(&em_u32_ops);
60 MODULE_LICENSE("GPL");
62 module_init(init_em_u32);
63 module_exit(exit_em_u32);