aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-11-26 00:12:32 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-26 00:13:25 -0500
commit0e991ec6a0340916d3f29bd5dcb35299069e7226 (patch)
treef8353915d1100b780e057a52f5be84102454af85 /net/sched
parent4ef8e768335637749af8d83327b174be0ea798a2 (diff)
tc: propogate errors from tcf_hash_create
Allow tcf_hash_create to return different errors on estimator failure. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/act_api.c18
-rw-r--r--net/sched/act_gact.c4
-rw-r--r--net/sched/act_ipt.c4
-rw-r--r--net/sched/act_mirred.c4
-rw-r--r--net/sched/act_nat.c4
-rw-r--r--net/sched/act_pedit.c4
-rw-r--r--net/sched/act_simple.c4
-rw-r--r--net/sched/act_skbedit.c4
8 files changed, 27 insertions, 19 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 8f457f1e0acf..9d03cc33b6cc 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -214,12 +214,14 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
214} 214}
215EXPORT_SYMBOL(tcf_hash_check); 215EXPORT_SYMBOL(tcf_hash_check);
216 216
217struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a, int size, int bind, u32 *idx_gen, struct tcf_hashinfo *hinfo) 217struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
218 struct tc_action *a, int size, int bind,
219 u32 *idx_gen, struct tcf_hashinfo *hinfo)
218{ 220{
219 struct tcf_common *p = kzalloc(size, GFP_KERNEL); 221 struct tcf_common *p = kzalloc(size, GFP_KERNEL);
220 222
221 if (unlikely(!p)) 223 if (unlikely(!p))
222 return p; 224 return ERR_PTR(-ENOMEM);
223 p->tcfc_refcnt = 1; 225 p->tcfc_refcnt = 1;
224 if (bind) 226 if (bind)
225 p->tcfc_bindcnt = 1; 227 p->tcfc_bindcnt = 1;
@@ -228,9 +230,15 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, struct tc_acti
228 p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo); 230 p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo);
229 p->tcfc_tm.install = jiffies; 231 p->tcfc_tm.install = jiffies;
230 p->tcfc_tm.lastuse = jiffies; 232 p->tcfc_tm.lastuse = jiffies;
231 if (est) 233 if (est) {
232 gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est, 234 int err = gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est,
233 &p->tcfc_lock, est); 235 &p->tcfc_lock, est);
236 if (err) {
237 kfree(p);
238 return ERR_PTR(err);
239 }
240 }
241
234 a->priv = (void *) p; 242 a->priv = (void *) p;
235 return p; 243 return p;
236} 244}
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index ac04289da5d7..e7f796aec657 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -88,8 +88,8 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
88 if (!pc) { 88 if (!pc) {
89 pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), 89 pc = tcf_hash_create(parm->index, est, a, sizeof(*gact),
90 bind, &gact_idx_gen, &gact_hash_info); 90 bind, &gact_idx_gen, &gact_hash_info);
91 if (unlikely(!pc)) 91 if (IS_ERR(pc))
92 return -ENOMEM; 92 return PTR_ERR(pc);
93 ret = ACT_P_CREATED; 93 ret = ACT_P_CREATED;
94 } else { 94 } else {
95 if (!ovr) { 95 if (!ovr) {
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 0453d79ebf57..082c520b0def 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -136,8 +136,8 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
136 if (!pc) { 136 if (!pc) {
137 pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind, 137 pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind,
138 &ipt_idx_gen, &ipt_hash_info); 138 &ipt_idx_gen, &ipt_hash_info);
139 if (unlikely(!pc)) 139 if (IS_ERR(pc))
140 return -ENOMEM; 140 return PTR_ERR(pc);
141 ret = ACT_P_CREATED; 141 ret = ACT_P_CREATED;
142 } else { 142 } else {
143 if (!ovr) { 143 if (!ovr) {
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 70341c020b6d..b9aaab4e0354 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -105,8 +105,8 @@ static int tcf_mirred_init(struct nlattr *nla, struct nlattr *est,
105 return -EINVAL; 105 return -EINVAL;
106 pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind, 106 pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
107 &mirred_idx_gen, &mirred_hash_info); 107 &mirred_idx_gen, &mirred_hash_info);
108 if (unlikely(!pc)) 108 if (IS_ERR(pc))
109 return -ENOMEM; 109 return PTR_ERR(pc);
110 ret = ACT_P_CREATED; 110 ret = ACT_P_CREATED;
111 } else { 111 } else {
112 if (!ovr) { 112 if (!ovr) {
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index 7b39ed485bca..d885ba311564 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -68,8 +68,8 @@ static int tcf_nat_init(struct nlattr *nla, struct nlattr *est,
68 if (!pc) { 68 if (!pc) {
69 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, 69 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
70 &nat_idx_gen, &nat_hash_info); 70 &nat_idx_gen, &nat_hash_info);
71 if (unlikely(!pc)) 71 if (IS_ERR(pc))
72 return -ENOMEM; 72 return PTR_ERR(pc);
73 p = to_tcf_nat(pc); 73 p = to_tcf_nat(pc);
74 ret = ACT_P_CREATED; 74 ret = ACT_P_CREATED;
75 } else { 75 } else {
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index d5f4e3404864..96c0ed115e2a 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -68,8 +68,8 @@ static int tcf_pedit_init(struct nlattr *nla, struct nlattr *est,
68 return -EINVAL; 68 return -EINVAL;
69 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, 69 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
70 &pedit_idx_gen, &pedit_hash_info); 70 &pedit_idx_gen, &pedit_hash_info);
71 if (unlikely(!pc)) 71 if (IS_ERR(pc))
72 return -ENOMEM; 72 return PTR_ERR(pc);
73 p = to_pedit(pc); 73 p = to_pedit(pc);
74 keys = kmalloc(ksize, GFP_KERNEL); 74 keys = kmalloc(ksize, GFP_KERNEL);
75 if (keys == NULL) { 75 if (keys == NULL) {
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index e7851ce92cfe..8daa1ebc7413 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -124,8 +124,8 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
124 if (!pc) { 124 if (!pc) {
125 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, 125 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
126 &simp_idx_gen, &simp_hash_info); 126 &simp_idx_gen, &simp_hash_info);
127 if (unlikely(!pc)) 127 if (IS_ERR(pc))
128 return -ENOMEM; 128 return PTR_ERR(pc);
129 129
130 d = to_defact(pc); 130 d = to_defact(pc);
131 ret = alloc_defdata(d, defdata); 131 ret = alloc_defdata(d, defdata);
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index fe9777e77f35..4ab916b8074b 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -104,8 +104,8 @@ static int tcf_skbedit_init(struct nlattr *nla, struct nlattr *est,
104 if (!pc) { 104 if (!pc) {
105 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, 105 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
106 &skbedit_idx_gen, &skbedit_hash_info); 106 &skbedit_idx_gen, &skbedit_hash_info);
107 if (unlikely(!pc)) 107 if (IS_ERR(pc))
108 return -ENOMEM; 108 return PTR_ERR(pc);
109 109
110 d = to_skbedit(pc); 110 d = to_skbedit(pc);
111 ret = ACT_P_CREATED; 111 ret = ACT_P_CREATED;