Commit 1d527812 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[PKT_SCHED]: cls_route: Use generic routines for class binding and police config/dump

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7bb29a64
...@@ -292,11 +292,8 @@ static void route4_destroy(struct tcf_proto *tp) ...@@ -292,11 +292,8 @@ static void route4_destroy(struct tcf_proto *tp)
struct route4_filter *f; struct route4_filter *f;
while ((f = b->ht[h2]) != NULL) { while ((f = b->ht[h2]) != NULL) {
unsigned long cl;
b->ht[h2] = f->next; b->ht[h2] = f->next;
if ((cl = __cls_set_class(&f->res.class, 0)) != 0) tcf_unbind_filter(tp, &f->res);
tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
tcf_police_release(f->police,TCA_ACT_UNBIND); tcf_police_release(f->police,TCA_ACT_UNBIND);
#endif #endif
...@@ -325,17 +322,12 @@ static int route4_delete(struct tcf_proto *tp, unsigned long arg) ...@@ -325,17 +322,12 @@ static int route4_delete(struct tcf_proto *tp, unsigned long arg)
for (fp = &b->ht[from_hash(h>>16)]; *fp; fp = &(*fp)->next) { for (fp = &b->ht[from_hash(h>>16)]; *fp; fp = &(*fp)->next) {
if (*fp == f) { if (*fp == f) {
unsigned long cl;
tcf_tree_lock(tp); tcf_tree_lock(tp);
*fp = f->next; *fp = f->next;
tcf_tree_unlock(tp); tcf_tree_unlock(tp);
route4_reset_fastmap(tp->q->dev, head, f->id); route4_reset_fastmap(tp->q->dev, head, f->id);
tcf_unbind_filter(tp, &f->res);
if ((cl = cls_set_class(tp, &f->res.class, 0)) != 0)
tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
tcf_police_release(f->police,TCA_ACT_UNBIND); tcf_police_release(f->police,TCA_ACT_UNBIND);
#endif #endif
...@@ -379,27 +371,18 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, ...@@ -379,27 +371,18 @@ static int route4_change(struct tcf_proto *tp, unsigned long base,
return -EINVAL; return -EINVAL;
if ((f = (struct route4_filter*)*arg) != NULL) { if ((f = (struct route4_filter*)*arg) != NULL) {
/* Node exists: adjust only classid */
if (f->handle != handle && handle) if (f->handle != handle && handle)
return -EINVAL; return -EINVAL;
if (tb[TCA_ROUTE4_CLASSID-1]) { if (tb[TCA_ROUTE4_CLASSID-1]) {
unsigned long cl;
f->res.classid = *(u32*)RTA_DATA(tb[TCA_ROUTE4_CLASSID-1]); f->res.classid = *(u32*)RTA_DATA(tb[TCA_ROUTE4_CLASSID-1]);
cl = cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid)); tcf_bind_filter(tp, &f->res, base);
if (cl)
tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
} }
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
if (tb[TCA_ROUTE4_POLICE-1]) { if (tb[TCA_ROUTE4_POLICE-1]) {
struct tcf_police *police = tcf_police_locate(tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]); err = tcf_change_police(tp, &f->police,
tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
tcf_tree_lock(tp); if (err < 0)
police = xchg(&f->police, police); return err;
tcf_tree_unlock(tp);
tcf_police_release(police,TCA_ACT_UNBIND);
} }
#endif #endif
return 0; return 0;
...@@ -492,10 +475,10 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, ...@@ -492,10 +475,10 @@ static int route4_change(struct tcf_proto *tp, unsigned long base,
goto errout; goto errout;
} }
cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid)); tcf_bind_filter(tp, &f->res, base);
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
if (tb[TCA_ROUTE4_POLICE-1]) if (tb[TCA_ROUTE4_POLICE-1])
f->police = tcf_police_locate(tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]); tcf_change_police(tp, &f->police, tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
#endif #endif
f->next = f1; f->next = f1;
...@@ -577,16 +560,8 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -577,16 +560,8 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
if (f->res.classid) if (f->res.classid)
RTA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid); RTA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid);
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
if (f->police) { if (tcf_dump_police(skb, f->police, TCA_ROUTE4_POLICE) < 0)
struct rtattr * p_rta = (struct rtattr*)skb->tail; goto rtattr_failure;
RTA_PUT(skb, TCA_ROUTE4_POLICE, 0, NULL);
if (tcf_police_dump(skb, f->police) < 0)
goto rtattr_failure;
p_rta->rta_len = skb->tail - (u8*)p_rta;
}
#endif #endif
rta->rta_len = skb->tail - b; rta->rta_len = skb->tail - b;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment