Skip to contentSkip to conversation

act_simple dont ignore realloc code

NET_CLS_ACT Applied jamal 2 participants 2 messages May 5, 2008 – May 6, 2008

Subsystems (3)
lore
Share & tools
lore

jamal

author
#0 lore raw

A buglet i noticed after previous patch.

cheers,
jamal

[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.

---
commit 8ff83dfef72af6acb76fa2925c0be7b60da524f0
tree a68c20dfaeb4b30d2f633b9711a9dc253687c709
parent a189f0b99f377aeadd1d56046c4c0d2694cd9734
author Jamal Hadi Salim <[email protected]> Mon, 05 May 2008 08:43:45 -0400 committer Jamal Hadi Salim <[email protected]> Mon, 05 May 2008 08:43:45 -0400

 net/sched/act_simple.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
net/sched/act_simple.c +9 -8
index 269ab51..1d421d0 100644
@@ -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;
maintainer Applied
#1 lore raw

From: jamal <[email protected]>
Date: Mon, 05 May 2008 08:48:06 -0400

Quoted 1 line

A buglet i noticed after previous patch.

Applied, thanks Jamal.