12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
17 #include <linux/rtnetlink.h>
18 #include <linux/module.h>
20 #include <linux/slab.h>
26 #define PEDIT_TAB_MASK 15
28 static u32 pedit_idx_gen;
42 struct tc_action *
a,
int ovr,
int bind)
71 &pedit_idx_gen, &pedit_hash_info);
97 spin_lock_bh(&p->tcf_lock);
99 p->tcf_action = parm->action;
106 spin_unlock_bh(&p->tcf_lock);
107 if (ret == ACT_P_CREATED)
112 static int tcf_pedit_cleanup(
struct tc_action *a,
int bind)
133 if (skb_cloned(skb) &&
135 return p->tcf_action;
137 off = skb_network_offset(skb);
139 spin_lock(&p->tcf_lock);
153 d = skb_header_pointer(skb, off + tkey->
at, 1,
162 " offset must be on 32 bit boundaries\n");
165 if (offset > 0 && offset > skb->
len) {
167 " offset %d can't exceed pkt length %d\n",
172 ptr = skb_header_pointer(skb, off + offset, 4, &_data);
176 *ptr = ((*ptr & tkey->
mask) ^ tkey->
val);
186 WARN(1,
"pedit BUG: index %d\n", p->tcf_index);
189 p->tcf_qstats.overlimits++;
191 bstats_update(&p->tcf_bstats, skb);
192 spin_unlock(&p->tcf_lock);
193 return p->tcf_action;
196 static int tcf_pedit_dump(
struct sk_buff *skb,
struct tc_action *a,
199 unsigned char *
b = skb_tail_pointer(skb);
214 opt->index = p->tcf_index;
217 opt->action = p->tcf_action;
218 opt->refcnt = p->tcf_refcnt - ref;
219 opt->bindcnt = p->tcf_bindcnt - bind;
221 if (
nla_put(skb, TCA_PEDIT_PARMS, s, opt))
222 goto nla_put_failure;
227 goto nla_put_failure;
237 static struct tc_action_ops act_pedit_ops = {
239 .hinfo = &pedit_hash_info,
241 .capab = TCA_CAP_NONE,
244 .dump = tcf_pedit_dump,
245 .cleanup = tcf_pedit_cleanup,
247 .init = tcf_pedit_init,
255 static int __init pedit_init_module(
void)
260 static void __exit pedit_cleanup_module(
void)