From: Thomas Graf <tgraf@suug.ch>
To: "David S. Miller" <davem@davemloft.net>
Cc: Jamal Hadi Salim <hadi@cyberus.ca>,
Patrick McHardy <kaber@trash.net>,
netdev@oss.sgi.com
Subject: [PATCH 3/9] PKT_SCHED: u32: make use of tcf_exts API
Date: Thu, 30 Dec 2004 13:31:08 +0100 [thread overview]
Message-ID: <20041230123108.GP32419@postel.suug.ch> (raw)
In-Reply-To: <20041230122652.GM32419@postel.suug.ch>
Transforms u32 to use tcf_exts API. Makes the u32 changing
procedure consistent upon failures except for indev failures but
indev will be removed very soon.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
--- linux-2.6.10-bk2.orig/net/sched/cls_u32.c 2004-12-29 20:16:24.000000000 +0100
+++ linux-2.6.10-bk2/net/sched/cls_u32.c 2004-12-29 20:19:49.000000000 +0100
@@ -61,9 +61,9 @@
struct tc_u32_mark
{
- __u32 val;
- __u32 mask;
- __u32 success;
+ u32 val;
+ u32 mask;
+ u32 success;
};
struct tc_u_knode
@@ -71,13 +71,7 @@
struct tc_u_knode *next;
u32 handle;
struct tc_u_hnode *ht_up;
-#ifdef CONFIG_NET_CLS_ACT
- struct tc_action *action;
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- struct tcf_police *police;
-#endif
-#endif
+ struct tcf_exts exts;
#ifdef CONFIG_NET_CLS_IND
char indev[IFNAMSIZ];
#endif
@@ -112,6 +106,11 @@
u32 hgenerator;
};
+static struct tcf_ext_map u32_ext_map = {
+ .action = TCA_U32_ACT,
+ .police = TCA_U32_POLICE
+};
+
static struct tc_u_common *u32_list;
static __inline__ unsigned u32_hash_fold(u32 key, struct tc_u32_sel *sel, u8 fshift)
@@ -137,7 +136,7 @@
#ifdef CONFIG_CLS_U32_PERF
int j;
#endif
- int i;
+ int i, r;
next_ht:
n = ht->ht[sel];
@@ -185,22 +184,13 @@
#ifdef CONFIG_CLS_U32_PERF
n->pf->rhit +=1;
#endif
-#ifdef CONFIG_NET_CLS_ACT
- if (n->action) {
- int pol_res = tcf_action_exec(skb, n->action, res);
- if (pol_res >= 0)
- return pol_res;
- } else
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- if (n->police) {
- int pol_res = tcf_police(skb, n->police);
- if (pol_res >= 0)
- return pol_res;
- } else
-#endif
-#endif
- return 0;
+ r = tcf_exts_exec(skb, &n->exts, res);
+ if (r < 0) {
+ n = n->next;
+ goto next_knode;
+ }
+
+ return r;
}
n = n->next;
goto next_knode;
@@ -359,15 +349,7 @@
static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
{
tcf_unbind_filter(tp, &n->res);
-#ifdef CONFIG_NET_CLS_ACT
- if (n->action) {
- tcf_action_destroy(n->action, TCA_ACT_UNBIND);
- }
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- tcf_police_release(n->police, TCA_ACT_UNBIND);
-#endif
-#endif
+ tcf_exts_destroy(tp, &n->exts);
if (n->ht_down)
n->ht_down->refcnt--;
#ifdef CONFIG_CLS_U32_PERF
@@ -509,18 +491,26 @@
struct tc_u_knode *n, struct rtattr **tb,
struct rtattr *est)
{
+ int err;
+ struct tcf_exts e;
+
+ err = tcf_exts_validate(tp, tb, est, &e, &u32_ext_map);
+ if (err < 0)
+ return err;
+
+ err = -EINVAL;
if (tb[TCA_U32_LINK-1]) {
u32 handle = *(u32*)RTA_DATA(tb[TCA_U32_LINK-1]);
struct tc_u_hnode *ht_down = NULL;
if (TC_U32_KEY(handle))
- return -EINVAL;
+ goto errout;
if (handle) {
ht_down = u32_lookup_ht(ht->tp_c, handle);
if (ht_down == NULL)
- return -EINVAL;
+ goto errout;
ht_down->refcnt++;
}
@@ -535,36 +525,20 @@
n->res.classid = *(u32*)RTA_DATA(tb[TCA_U32_CLASSID-1]);
tcf_bind_filter(tp, &n->res, base);
}
-#ifdef CONFIG_NET_CLS_ACT
- if (tb[TCA_U32_POLICE-1]) {
- int err = tcf_change_act_police(tp, &n->action, tb[TCA_U32_POLICE-1], est);
- if (err < 0)
- return err;
- }
- if (tb[TCA_U32_ACT-1]) {
- int err = tcf_change_act(tp, &n->action, tb[TCA_U32_ACT-1], est);
- if (err < 0)
- return err;
- }
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- if (tb[TCA_U32_POLICE-1]) {
- int err = tcf_change_police(tp, &n->police, tb[TCA_U32_POLICE-1], est);
- if (err < 0)
- return err;
- }
-#endif
-#endif
#ifdef CONFIG_NET_CLS_IND
if (tb[TCA_U32_INDEV-1]) {
int err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV-1]);
if (err < 0)
- return err;
+ goto errout;
}
#endif
+ tcf_exts_change(tp, &n->exts, &e);
return 0;
+errout:
+ tcf_exts_destroy(tp, &e);
+ return err;
}
static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
@@ -584,7 +558,7 @@
if (opt == NULL)
return handle ? -EINVAL : 0;
- if (rtattr_parse(tb, TCA_U32_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)) < 0)
+ if (rtattr_parse_nested(tb, TCA_U32_MAX, opt) < 0)
return -EINVAL;
if ((n = (struct tc_u_knode*)*arg) != NULL) {
@@ -657,12 +631,12 @@
memset(n, 0, sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key));
#ifdef CONFIG_CLS_U32_PERF
- n->pf = kmalloc(sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(__u64), GFP_KERNEL);
+ n->pf = kmalloc(sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(u64), GFP_KERNEL);
if (n->pf == NULL) {
kfree(n);
return -ENOBUFS;
}
- memset(n->pf, 0, sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(__u64));
+ memset(n->pf, 0, sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(u64));
#endif
memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
@@ -783,15 +757,8 @@
RTA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark);
#endif
-#ifdef CONFIG_NET_CLS_ACT
- if (tcf_dump_act(skb, n->action, TCA_U32_ACT, TCA_U32_POLICE) < 0)
- goto rtattr_failure;
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- if (tcf_dump_police(skb, n->police, TCA_U32_POLICE) < 0)
+ if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0)
goto rtattr_failure;
-#endif
-#endif
#ifdef CONFIG_NET_CLS_IND
if(strlen(n->indev))
@@ -799,26 +766,15 @@
#endif
#ifdef CONFIG_CLS_U32_PERF
RTA_PUT(skb, TCA_U32_PCNT,
- sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(__u64),
+ sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64),
n->pf);
#endif
}
rta->rta_len = skb->tail - b;
-#ifdef CONFIG_NET_CLS_ACT
- if (TC_U32_KEY(n->handle) != 0) {
- if (TC_U32_KEY(n->handle) && n->action && n->action->type == TCA_OLD_COMPAT) {
- if (tcf_action_copy_stats(skb,n->action))
- goto rtattr_failure;
- }
- }
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- if (TC_U32_KEY(n->handle) && n->police)
- if (tcf_police_dump_stats(skb, n->police) < 0)
+ if (TC_U32_KEY(n->handle))
+ if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0)
goto rtattr_failure;
-#endif
-#endif
return skb->len;
rtattr_failure:
next prev parent reply other threads:[~2004-12-30 12:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-30 12:26 [PATCH 0/9] PKT_SCHED: tcf_exts API & make classifier changes consistent upon failure Thomas Graf
2004-12-30 12:28 ` [PATCH 1/9] PKT_SCHED: rtattr_parse shortcut for nested TLVs Thomas Graf
2004-12-30 12:30 ` [PATCH 2/9] PKT_SCHED: tc filter extension API Thomas Graf
2004-12-30 13:51 ` jamal
2004-12-30 14:09 ` Thomas Graf
2004-12-31 4:42 ` jamal
2004-12-30 16:33 ` [RESEND " Thomas Graf
2004-12-31 14:12 ` Thomas Graf
2005-01-01 12:21 ` [FINAL RESEND " Thomas Graf
2004-12-31 1:01 ` [PATCH " Patrick McHardy
2004-12-31 2:04 ` Arnaldo Carvalho de Melo
2004-12-31 5:04 ` jamal
2004-12-31 5:02 ` jamal
2004-12-31 9:52 ` Patrick McHardy
2004-12-31 11:18 ` Thomas Graf
2004-12-31 4:36 ` jamal
2004-12-31 13:10 ` Thomas Graf
2004-12-31 14:18 ` Patrick McHardy
2004-12-31 14:35 ` Thomas Graf
2004-12-30 12:31 ` Thomas Graf [this message]
2004-12-31 4:43 ` [PATCH 3/9] PKT_SCHED: u32: make use of tcf_exts API jamal
2004-12-31 12:03 ` Thomas Graf
2004-12-30 12:32 ` [PATCH 4/9] PKT_SCHED: fw: " Thomas Graf
2004-12-30 12:33 ` [PATCH 5/9] PKT_SCHED: route: allow changing parameters for existing filters and use " Thomas Graf
2004-12-30 12:34 ` [PATCH 6/9] PKT_SCHED: tcindex: " Thomas Graf
2004-12-30 12:34 ` [PATCH 7/9] PKT_SCHED: rsvp: " Thomas Graf
2004-12-30 12:35 ` [PATCH 8/9] PKT_SCHED: Remove old action/police helpers Thomas Graf
2004-12-30 12:36 ` [PATCH 9/9] PKT_SCHED: Actions are now available for all classifiers Thomas Graf
2004-12-31 14:17 ` [RESEND 9/9] PKT_SCHED: Actions are now available for all classifiers & Fix police Kconfig dependencies Thomas Graf
2005-01-10 21:56 ` 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=20041230123108.GP32419@postel.suug.ch \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=hadi@cyberus.ca \
--cc=kaber@trash.net \
--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).