act_simple.c (14f0290ba44de6ed435fea24bba26e7868421c66) act_simple.c (cc7ec456f82da7f89a5b376e613b3ac4311b3e9a)
1/*
2 * net/sched/simp.c Simple example of an action
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 *

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

42
43 spin_lock(&d->tcf_lock);
44 d->tcf_tm.lastuse = jiffies;
45 bstats_update(&d->tcf_bstats, skb);
46
47 /* print policy string followed by _ then packet count
48 * Example if this was the 3rd packet and the string was "hello"
49 * then it would look like "hello_3" (without quotes)
1/*
2 * net/sched/simp.c Simple example of an action
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 *

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

42
43 spin_lock(&d->tcf_lock);
44 d->tcf_tm.lastuse = jiffies;
45 bstats_update(&d->tcf_bstats, skb);
46
47 /* print policy string followed by _ then packet count
48 * Example if this was the 3rd packet and the string was "hello"
49 * then it would look like "hello_3" (without quotes)
50 **/
50 */
51 pr_info("simple: %s_%d\n",
52 (char *)d->tcfd_defdata, d->tcf_bstats.packets);
53 spin_unlock(&d->tcf_lock);
54 return d->tcf_action;
55}
56
57static int tcf_simp_release(struct tcf_defact *d, int bind)
58{

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

120 parm = nla_data(tb[TCA_DEF_PARMS]);
121 defdata = nla_data(tb[TCA_DEF_DATA]);
122
123 pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info);
124 if (!pc) {
125 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
126 &simp_idx_gen, &simp_hash_info);
127 if (IS_ERR(pc))
51 pr_info("simple: %s_%d\n",
52 (char *)d->tcfd_defdata, d->tcf_bstats.packets);
53 spin_unlock(&d->tcf_lock);
54 return d->tcf_action;
55}
56
57static int tcf_simp_release(struct tcf_defact *d, int bind)
58{

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

120 parm = nla_data(tb[TCA_DEF_PARMS]);
121 defdata = nla_data(tb[TCA_DEF_DATA]);
122
123 pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info);
124 if (!pc) {
125 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
126 &simp_idx_gen, &simp_hash_info);
127 if (IS_ERR(pc))
128 return PTR_ERR(pc);
128 return PTR_ERR(pc);
129
130 d = to_defact(pc);
131 ret = alloc_defdata(d, defdata);
132 if (ret < 0) {
133 kfree(pc);
134 return ret;
135 }
136 d->tcf_action = parm->action;

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

144 reset_policy(d, defdata, parm);
145 }
146
147 if (ret == ACT_P_CREATED)
148 tcf_hash_insert(pc, &simp_hash_info);
149 return ret;
150}
151
129
130 d = to_defact(pc);
131 ret = alloc_defdata(d, defdata);
132 if (ret < 0) {
133 kfree(pc);
134 return ret;
135 }
136 d->tcf_action = parm->action;

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

144 reset_policy(d, defdata, parm);
145 }
146
147 if (ret == ACT_P_CREATED)
148 tcf_hash_insert(pc, &simp_hash_info);
149 return ret;
150}
151
152static inline int tcf_simp_cleanup(struct tc_action *a, int bind)
152static int tcf_simp_cleanup(struct tc_action *a, int bind)
153{
154 struct tcf_defact *d = a->priv;
155
156 if (d)
157 return tcf_simp_release(d, bind);
158 return 0;
159}
160
153{
154 struct tcf_defact *d = a->priv;
155
156 if (d)
157 return tcf_simp_release(d, bind);
158 return 0;
159}
160
161static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
162 int bind, int ref)
161static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
162 int bind, int ref)
163{
164 unsigned char *b = skb_tail_pointer(skb);
165 struct tcf_defact *d = a->priv;
166 struct tc_defact opt = {
167 .index = d->tcf_index,
168 .refcnt = d->tcf_refcnt - ref,
169 .bindcnt = d->tcf_bindcnt - bind,
170 .action = d->tcf_action,

--- 48 unchanged lines hidden ---
163{
164 unsigned char *b = skb_tail_pointer(skb);
165 struct tcf_defact *d = a->priv;
166 struct tc_defact opt = {
167 .index = d->tcf_index,
168 .refcnt = d->tcf_refcnt - ref,
169 .bindcnt = d->tcf_bindcnt - bind,
170 .action = d->tcf_action,

--- 48 unchanged lines hidden ---