13 #include <linux/module.h>
14 #include <linux/slab.h>
16 #include <linux/kernel.h>
18 #include <linux/rtnetlink.h>
22 #define TCA_ACT_SIMP 22
27 #define SIMP_TAB_MASK 7
29 static u32 simp_idx_gen;
38 #define SIMP_MAX_DATA 32
39 static int tcf_simp(
struct sk_buff *
skb,
const struct tc_action *
a,
44 spin_lock(&d->tcf_lock);
46 bstats_update(&d->tcf_bstats, skb);
54 spin_unlock(&d->tcf_lock);
58 static int tcf_simp_release(
struct tcf_defact *
d,
int bind)
65 if (d->tcf_bindcnt <= 0 && d->tcf_refcnt <= 0) {
74 static int alloc_defdata(
struct tcf_defact *d,
char *defdata)
83 static void reset_policy(
struct tcf_defact *d,
char *defdata,
86 spin_lock_bh(&d->tcf_lock);
87 d->tcf_action = p->action;
90 spin_unlock_bh(&d->tcf_lock);
99 struct tc_action *
a,
int ovr,
int bind)
127 &simp_idx_gen, &simp_hash_info);
132 ret = alloc_defdata(d, defdata);
140 d->tcf_action = parm->action;
145 tcf_simp_release(d, bind);
148 reset_policy(d, defdata, parm);
151 if (ret == ACT_P_CREATED)
156 static int tcf_simp_cleanup(
struct tc_action *a,
int bind)
161 return tcf_simp_release(d, bind);
165 static int tcf_simp_dump(
struct sk_buff *
skb,
struct tc_action *a,
168 unsigned char *
b = skb_tail_pointer(skb);
171 .index = d->tcf_index,
172 .refcnt = d->tcf_refcnt - ref,
173 .bindcnt = d->tcf_bindcnt - bind,
174 .action = d->tcf_action,
180 goto nla_put_failure;
185 goto nla_put_failure;
193 static struct tc_action_ops act_simp_ops = {
195 .hinfo = &simp_hash_info,
197 .capab = TCA_CAP_NONE,
200 .dump = tcf_simp_dump,
201 .cleanup = tcf_simp_cleanup,
202 .init = tcf_simp_init,
210 static int __init simp_init_module(
void)
214 pr_info(
"Simple TC action Loaded\n");
218 static void __exit simp_cleanup_module(
void)