diff options
author | Patrick McHardy <kaber@trash.net> | 2005-01-09 21:56:53 -0800 |
---|---|---|
committer | David S. Miller <davem@nuts.davemloft.net> | 2005-01-09 21:56:53 -0800 |
commit | c938f19241461fc54db1d4492b303269569d571a (patch) | |
tree | 985cca4e803d57c0d4669070279f3eae51b6c473 /net | |
parent | b9058337034ede2ea08a9d202cc7179a3bd7af20 (diff) | |
download | history-c938f19241461fc54db1d4492b303269569d571a.tar.gz |
[PKT_SCHED]: act_api.c: push memory allocation to tcf_action_get_1
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/act_api.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index a1d7e65ed10eb2..d4bedc7d9c31fa 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -463,31 +463,46 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event) return err; } -static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a, - struct nlmsghdr *n, u32 pid) +static struct tc_action * +tcf_action_get_1(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int *err) { struct rtattr *tb[TCA_ACT_MAX+1]; + struct tc_action *a; int index; - int err = 0; + *err = -EINVAL; if (rtattr_parse(tb, TCA_ACT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0) - return -EINVAL; + return NULL; if (tb[TCA_ACT_INDEX - 1] == NULL || RTA_PAYLOAD(tb[TCA_ACT_INDEX - 1]) < sizeof(index)) - return -EINVAL; + return NULL; index = *(int *)RTA_DATA(tb[TCA_ACT_INDEX - 1]); + *err = -ENOMEM; + a = kmalloc(sizeof(struct tc_action), GFP_KERNEL); + if (a == NULL) + return NULL; + memset(a, 0, sizeof(struct tc_action)); + + *err = -EINVAL; a->ops = tc_lookup_action(tb[TCA_ACT_KIND - 1]); if (a->ops == NULL) - return -EINVAL; + goto err_free; if (a->ops->lookup == NULL) - err = -EINVAL; - else if (a->ops->lookup(a, index) == 0) - err = -ENOENT; + goto err_mod; + *err = -ENOENT; + if (a->ops->lookup(a, index) == 0) + goto err_mod; module_put(a->ops->owner); - return err; + *err = 0; + return a; +err_mod: + module_put(a->ops->owner); +err_free: + kfree(a); + return NULL; } static void cleanup_a(struct tc_action *act) @@ -606,7 +621,11 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event) for (i=0; i < TCA_ACT_MAX_PRIO; i++) { if (tb[i] == NULL) break; - act = create_a(i+1); + act = tcf_action_get_1(tb[i], n, pid, &ret); + if (act == NULL) + goto rtattr_failure; + act->order = i+1; + if (a != NULL) { a->next = act; a = act; @@ -615,13 +634,6 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event) if (a_s == NULL) a_s = a; - - ret = tcf_action_get_1(tb[i], act, n, pid); - if (ret < 0) { - printk("tcf_action_get: failed to get!\n"); - ret = -EINVAL; - goto rtattr_failure; - } } if (event == RTM_GETACTION) |