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 4/9] PKT_SCHED: fw: make use of tcf_exts API
Date: Thu, 30 Dec 2004 13:32:16 +0100 [thread overview]
Message-ID: <20041230123216.GQ32419@postel.suug.ch> (raw)
In-Reply-To: <20041230122652.GM32419@postel.suug.ch>
Transforms fw to use tcf_exts API. Makes the fw 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_fw.c 2004-12-29 20:16:24.000000000 +0100
+++ linux-2.6.10-bk2/net/sched/cls_fw.c 2004-12-29 20:20:26.000000000 +0100
@@ -59,13 +59,12 @@
#ifdef CONFIG_NET_CLS_IND
char indev[IFNAMSIZ];
#endif /* CONFIG_NET_CLS_IND */
-#ifdef CONFIG_NET_CLS_ACT
- struct tc_action *action;
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- struct tcf_police *police;
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
+ struct tcf_exts exts;
+};
+
+static struct tcf_ext_map fw_ext_map = {
+ .action = TCA_FW_ACT,
+ .police = TCA_FW_POLICE
};
static __inline__ int fw_hash(u32 handle)
@@ -78,6 +77,7 @@
{
struct fw_head *head = (struct fw_head*)tp->root;
struct fw_filter *f;
+ int r;
#ifdef CONFIG_NETFILTER
u32 id = skb->nfmark;
#else
@@ -92,20 +92,11 @@
if (!tcf_match_indev(skb, f->indev))
continue;
#endif /* CONFIG_NET_CLS_IND */
-#ifdef CONFIG_NET_CLS_ACT
- if (f->action) {
- int act_res = tcf_action_exec(skb, f->action, res);
- if (act_res >= 0)
- return act_res;
+ r = tcf_exts_exec(skb, &f->exts, res);
+ if (r < 0)
continue;
- }
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- if (f->police)
- return tcf_police(skb, f->police);
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
- return 0;
+
+ return r;
}
}
} else {
@@ -144,6 +135,14 @@
return 0;
}
+static inline void
+fw_delete_filter(struct tcf_proto *tp, struct fw_filter *f)
+{
+ tcf_unbind_filter(tp, &f->res);
+ tcf_exts_destroy(tp, &f->exts);
+ kfree(f);
+}
+
static void fw_destroy(struct tcf_proto *tp)
{
struct fw_head *head = (struct fw_head*)xchg(&tp->root, NULL);
@@ -156,18 +155,7 @@
for (h=0; h<256; h++) {
while ((f=head->ht[h]) != NULL) {
head->ht[h] = f->next;
- tcf_unbind_filter(tp, &f->res);
-#ifdef CONFIG_NET_CLS_ACT
- if (f->action)
- tcf_action_destroy(f->action, TCA_ACT_UNBIND);
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- if (f->police)
- tcf_police_release(f->police, TCA_ACT_UNBIND);
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
-
- kfree(f);
+ fw_delete_filter(tp, f);
}
}
kfree(head);
@@ -187,16 +175,7 @@
tcf_tree_lock(tp);
*fp = f->next;
tcf_tree_unlock(tp);
- tcf_unbind_filter(tp, &f->res);
-#ifdef CONFIG_NET_CLS_ACT
- if (f->action)
- tcf_action_destroy(f->action,TCA_ACT_UNBIND);
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- tcf_police_release(f->police,TCA_ACT_UNBIND);
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
- kfree(f);
+ fw_delete_filter(tp, f);
return 0;
}
}
@@ -208,8 +187,14 @@
fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
struct rtattr **tb, struct rtattr **tca, unsigned long base)
{
- int err = -EINVAL;
+ struct tcf_exts e;
+ int err;
+ err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &fw_ext_map);
+ if (err < 0)
+ return err;
+
+ err = -EINVAL;
if (tb[TCA_FW_CLASSID-1]) {
if (RTA_PAYLOAD(tb[TCA_FW_CLASSID-1]) != sizeof(u32))
goto errout;
@@ -225,33 +210,11 @@
}
#endif /* CONFIG_NET_CLS_IND */
-#ifdef CONFIG_NET_CLS_ACT
- if (tb[TCA_FW_POLICE-1]) {
- err = tcf_change_act_police(tp, &f->action, tb[TCA_FW_POLICE-1],
- tca[TCA_RATE-1]);
- if (err < 0)
- goto errout;
- }
-
- if (tb[TCA_FW_ACT-1]) {
- err = tcf_change_act(tp, &f->action, tb[TCA_FW_ACT-1],
- tca[TCA_RATE-1]);
- if (err < 0)
- goto errout;
- }
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- if (tb[TCA_FW_POLICE-1]) {
- err = tcf_change_police(tp, &f->police, tb[TCA_FW_POLICE-1],
- tca[TCA_RATE-1]);
- if (err < 0)
- goto errout;
- }
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
+ tcf_exts_change(tp, &f->exts, &e);
- err = 0;
+ return 0;
errout:
+ tcf_exts_destroy(tp, &e);
return err;
}
@@ -269,7 +232,7 @@
if (!opt)
return handle ? -EINVAL : 0;
- if (rtattr_parse(tb, TCA_FW_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)) < 0)
+ if (rtattr_parse_nested(tb, TCA_FW_MAX, opt) < 0)
return -EINVAL;
if (f != NULL) {
@@ -357,15 +320,7 @@
t->tcm_handle = f->id;
- if (!f->res.classid
-#ifdef CONFIG_NET_CLS_ACT
- && !f->action
-#else
-#ifdef CONFIG_NET_CLS_POLICE
- && !f->police
-#endif
-#endif
- )
+ if (!f->res.classid && !tcf_exts_is_available(&f->exts))
return skb->len;
rta = (struct rtattr*)b;
@@ -377,29 +332,15 @@
if (strlen(f->indev))
RTA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev);
#endif /* CONFIG_NET_CLS_IND */
-#ifdef CONFIG_NET_CLS_ACT
- if (tcf_dump_act(skb, f->action, TCA_FW_ACT, TCA_FW_POLICE) < 0)
- goto rtattr_failure;
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- if (tcf_dump_police(skb, f->police, TCA_FW_POLICE) < 0)
+
+ if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
goto rtattr_failure;
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
rta->rta_len = skb->tail - b;
-#ifdef CONFIG_NET_CLS_ACT
- if (f->action && f->action->type == TCA_OLD_COMPAT) {
- if (tcf_action_copy_stats(skb,f->action))
- goto rtattr_failure;
- }
-#else /* CONFIG_NET_CLS_ACT */
-#ifdef CONFIG_NET_CLS_POLICE
- if (f->police)
- if (tcf_police_dump_stats(skb, f->police) < 0)
- goto rtattr_failure;
-#endif /* CONFIG_NET_CLS_POLICE */
-#endif /* CONFIG_NET_CLS_ACT */
+
+ if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0)
+ goto rtattr_failure;
+
return skb->len;
rtattr_failure:
next prev parent reply other threads:[~2004-12-30 12:32 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 ` [PATCH 3/9] PKT_SCHED: u32: make use of tcf_exts API Thomas Graf
2004-12-31 4:43 ` jamal
2004-12-31 12:03 ` Thomas Graf
2004-12-30 12:32 ` Thomas Graf [this message]
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=20041230123216.GQ32419@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).