cls_basic.c (f43dc23d5ea91fca257be02138a255f02d98e806) cls_basic.c (cc7ec456f82da7f89a5b376e613b3ac4311b3e9a)
1/*
2 * net/sched/cls_basic.c Basic Packet Classifier.
3 *
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.
8 *

--- 7 unchanged lines hidden (view full) ---

16#include <linux/string.h>
17#include <linux/errno.h>
18#include <linux/rtnetlink.h>
19#include <linux/skbuff.h>
20#include <net/netlink.h>
21#include <net/act_api.h>
22#include <net/pkt_cls.h>
23
1/*
2 * net/sched/cls_basic.c Basic Packet Classifier.
3 *
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.
8 *

--- 7 unchanged lines hidden (view full) ---

16#include <linux/string.h>
17#include <linux/errno.h>
18#include <linux/rtnetlink.h>
19#include <linux/skbuff.h>
20#include <net/netlink.h>
21#include <net/act_api.h>
22#include <net/pkt_cls.h>
23
24struct basic_head
25{
24struct basic_head {
26 u32 hgenerator;
27 struct list_head flist;
28};
29
25 u32 hgenerator;
26 struct list_head flist;
27};
28
30struct basic_filter
31{
29struct basic_filter {
32 u32 handle;
33 struct tcf_exts exts;
34 struct tcf_ematch_tree ematches;
35 struct tcf_result res;
36 struct list_head link;
37};
38
39static const struct tcf_ext_map basic_ext_map = {

--- 47 unchanged lines hidden (view full) ---

87 head = kzalloc(sizeof(*head), GFP_KERNEL);
88 if (head == NULL)
89 return -ENOBUFS;
90 INIT_LIST_HEAD(&head->flist);
91 tp->root = head;
92 return 0;
93}
94
30 u32 handle;
31 struct tcf_exts exts;
32 struct tcf_ematch_tree ematches;
33 struct tcf_result res;
34 struct list_head link;
35};
36
37static const struct tcf_ext_map basic_ext_map = {

--- 47 unchanged lines hidden (view full) ---

85 head = kzalloc(sizeof(*head), GFP_KERNEL);
86 if (head == NULL)
87 return -ENOBUFS;
88 INIT_LIST_HEAD(&head->flist);
89 tp->root = head;
90 return 0;
91}
92
95static inline void basic_delete_filter(struct tcf_proto *tp,
96 struct basic_filter *f)
93static void basic_delete_filter(struct tcf_proto *tp, struct basic_filter *f)
97{
98 tcf_unbind_filter(tp, &f->res);
99 tcf_exts_destroy(tp, &f->exts);
100 tcf_em_tree_destroy(tp, &f->ematches);
101 kfree(f);
102}
103
104static void basic_destroy(struct tcf_proto *tp)

--- 25 unchanged lines hidden (view full) ---

130 return -ENOENT;
131}
132
133static const struct nla_policy basic_policy[TCA_BASIC_MAX + 1] = {
134 [TCA_BASIC_CLASSID] = { .type = NLA_U32 },
135 [TCA_BASIC_EMATCHES] = { .type = NLA_NESTED },
136};
137
94{
95 tcf_unbind_filter(tp, &f->res);
96 tcf_exts_destroy(tp, &f->exts);
97 tcf_em_tree_destroy(tp, &f->ematches);
98 kfree(f);
99}
100
101static void basic_destroy(struct tcf_proto *tp)

--- 25 unchanged lines hidden (view full) ---

127 return -ENOENT;
128}
129
130static const struct nla_policy basic_policy[TCA_BASIC_MAX + 1] = {
131 [TCA_BASIC_CLASSID] = { .type = NLA_U32 },
132 [TCA_BASIC_EMATCHES] = { .type = NLA_NESTED },
133};
134
138static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f,
139 unsigned long base, struct nlattr **tb,
140 struct nlattr *est)
135static int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f,
136 unsigned long base, struct nlattr **tb,
137 struct nlattr *est)
141{
142 int err = -EINVAL;
143 struct tcf_exts e;
144 struct tcf_ematch_tree t;
145
146 err = tcf_exts_validate(tp, tb, est, &e, &basic_ext_map);
147 if (err < 0)
148 return err;

--- 49 unchanged lines hidden (view full) ---

198 else {
199 unsigned int i = 0x80000000;
200 do {
201 if (++head->hgenerator == 0x7FFFFFFF)
202 head->hgenerator = 1;
203 } while (--i > 0 && basic_get(tp, head->hgenerator));
204
205 if (i <= 0) {
138{
139 int err = -EINVAL;
140 struct tcf_exts e;
141 struct tcf_ematch_tree t;
142
143 err = tcf_exts_validate(tp, tb, est, &e, &basic_ext_map);
144 if (err < 0)
145 return err;

--- 49 unchanged lines hidden (view full) ---

195 else {
196 unsigned int i = 0x80000000;
197 do {
198 if (++head->hgenerator == 0x7FFFFFFF)
199 head->hgenerator = 1;
200 } while (--i > 0 && basic_get(tp, head->hgenerator));
201
202 if (i <= 0) {
206 printk(KERN_ERR "Insufficient number of handles\n");
203 pr_err("Insufficient number of handles\n");
207 goto errout;
208 }
209
210 f->handle = head->hgenerator;
211 }
212
213 err = basic_set_parms(tp, f, base, tb, tca[TCA_RATE]);
214 if (err < 0)

--- 95 unchanged lines hidden ---
204 goto errout;
205 }
206
207 f->handle = head->hgenerator;
208 }
209
210 err = basic_set_parms(tp, f, base, tb, tca[TCA_RATE]);
211 if (err < 0)

--- 95 unchanged lines hidden ---