netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@oss.sgi.com, hadi@cyberus.ca
Subject: [PATCH 1/4] cls_route: Use generic routines for class binding and police config/dump
Date: Fri, 29 Oct 2004 16:06:59 +0200	[thread overview]
Message-ID: <20041029140659.GP12289@postel.suug.ch> (raw)
In-Reply-To: <20041029140612.GO12289@postel.suug.ch>

Signed-off-by: Thomas Graf <tgraf@suug.ch>

--- linux-2.6.10-rc1-bk7.orig/net/sched/cls_route.c	2004-10-29 11:18:17.000000000 +0200
+++ linux-2.6.10-rc1-bk7/net/sched/cls_route.c	2004-10-29 10:57:07.000000000 +0200
@@ -292,11 +292,8 @@
 				struct route4_filter *f;
 
 				while ((f = b->ht[h2]) != NULL) {
-					unsigned long cl;
-
 					b->ht[h2] = f->next;
-					if ((cl = __cls_set_class(&f->res.class, 0)) != 0)
-						tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+					tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_POLICE
 					tcf_police_release(f->police,TCA_ACT_UNBIND);
 #endif
@@ -325,17 +322,12 @@
 
 	for (fp = &b->ht[from_hash(h>>16)]; *fp; fp = &(*fp)->next) {
 		if (*fp == f) {
-			unsigned long cl;
-
 			tcf_tree_lock(tp);
 			*fp = f->next;
 			tcf_tree_unlock(tp);
 
 			route4_reset_fastmap(tp->q->dev, head, f->id);
-
-			if ((cl = cls_set_class(tp, &f->res.class, 0)) != 0)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
-
+			tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_POLICE
 			tcf_police_release(f->police,TCA_ACT_UNBIND);
 #endif
@@ -379,27 +371,18 @@
 		return -EINVAL;
 
 	if ((f = (struct route4_filter*)*arg) != NULL) {
-		/* Node exists: adjust only classid */
-
 		if (f->handle != handle && handle)
 			return -EINVAL;
 		if (tb[TCA_ROUTE4_CLASSID-1]) {
-			unsigned long cl;
-
 			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));
-			if (cl)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+			tcf_bind_filter(tp, &f->res, base);
 		}
 #ifdef CONFIG_NET_CLS_POLICE
 		if (tb[TCA_ROUTE4_POLICE-1]) {
-			struct tcf_police *police = tcf_police_locate(tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
-
-			tcf_tree_lock(tp);
-			police = xchg(&f->police, police);
-			tcf_tree_unlock(tp);
-
-			tcf_police_release(police,TCA_ACT_UNBIND);
+			err = tcf_change_police(tp, &f->police,
+				tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
+			if (err < 0)
+				return err;
 		}
 #endif
 		return 0;
@@ -492,10 +475,10 @@
 			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
 	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
 
 	f->next = f1;
@@ -577,16 +560,8 @@
 	if (f->res.classid)
 		RTA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid);
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		struct rtattr * p_rta = (struct rtattr*)skb->tail;
-
-		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;
-	}
+	if (tcf_dump_police(skb, f->police, TCA_ROUTE4_POLICE) < 0)
+		goto rtattr_failure;
 #endif
 
 	rta->rta_len = skb->tail - b;

  reply	other threads:[~2004-10-29 14:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-29 14:06 [PATCHSET 0/4] PKT_SCHED: More classifier cleanups Thomas Graf
2004-10-29 14:06 ` Thomas Graf [this message]
2004-10-29 14:07 ` [PATCH 2/4] cls_rsvp*: Use generic routines for class binding and police config/dump Thomas Graf
2004-10-30  0:01   ` [RESEND " Thomas Graf
2004-10-29 14:08 ` [PATCH 3/4] cls_tcindex: " Thomas Graf
2004-10-29 14:09 ` [PATCH 4/4] cls_u32: Use generic routines for class binding and police/action config/dump Thomas Graf
2004-11-02  1:06 ` [PATCHSET 0/4] PKT_SCHED: More classifier cleanups David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041029140659.GP12289@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=hadi@cyberus.ca \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).