From: jamal <hadi@cyberus.ca>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [NET_CLS_ACT] act_simple dont ignore realloc code
Date: Mon, 05 May 2008 08:48:06 -0400 [thread overview]
Message-ID: <1209991686.6972.185.camel@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 57 bytes --]
A buglet i noticed after previous patch.
cheers,
jamal
[-- Attachment #2: act_simp2 --]
[-- Type: text/plain, Size: 1951 bytes --]
[NET_CLS_ACT] act_simple dont ignore realloc code
reallocation of the policy data was being ignored. It could fail.
Simplify so that there is no need for reallocating.
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
---
commit 8ff83dfef72af6acb76fa2925c0be7b60da524f0
tree a68c20dfaeb4b30d2f633b9711a9dc253687c709
parent a189f0b99f377aeadd1d56046c4c0d2694cd9734
author Jamal Hadi Salim <hadi@cyberus.ca> Mon, 05 May 2008 08:43:45 -0400
committer Jamal Hadi Salim <hadi@cyberus.ca> Mon, 05 May 2008 08:43:45 -0400
net/sched/act_simple.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index 269ab51..1d421d0 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -79,10 +79,14 @@ static int alloc_defdata(struct tcf_defact *d, char *defdata)
return 0;
}
-static int realloc_defdata(struct tcf_defact *d, char *defdata)
+static void reset_policy(struct tcf_defact *d, char *defdata,
+ struct tc_defact *p)
{
- kfree(d->tcfd_defdata);
- return alloc_defdata(d, defdata);
+ spin_lock_bh(&d->tcf_lock);
+ d->tcf_action = p->action;
+ memset(d->tcfd_defdata, 0, SIMP_MAX_DATA);
+ strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA);
+ spin_unlock_bh(&d->tcf_lock);
}
static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = {
@@ -129,6 +133,7 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
kfree(pc);
return ret;
}
+ d->tcf_action = parm->action;
ret = ACT_P_CREATED;
} else {
d = to_defact(pc);
@@ -136,13 +141,9 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
tcf_simp_release(d, bind);
return -EEXIST;
}
- realloc_defdata(d, defdata);
+ reset_policy(d, defdata, parm);
}
- spin_lock_bh(&d->tcf_lock);
- d->tcf_action = parm->action;
- spin_unlock_bh(&d->tcf_lock);
-
if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, &simp_hash_info);
return ret;
next reply other threads:[~2008-05-05 12:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-05 12:48 jamal [this message]
2008-05-06 7:11 ` [NET_CLS_ACT] act_simple dont ignore realloc code David 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=1209991686.6972.185.camel@localhost \
--to=hadi@cyberus.ca \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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).