Commit d1e5704b authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[PKT_SCHED]: act_api.c: clean up init path, propagate errors properly

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8ae25cf0
...@@ -283,55 +283,39 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, ...@@ -283,55 +283,39 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
RTA_PAYLOAD(rta)) < 0) RTA_PAYLOAD(rta)) < 0)
goto err_out; goto err_out;
kind = tb[TCA_ACT_KIND-1]; kind = tb[TCA_ACT_KIND-1];
if (kind != NULL) { if (kind == NULL)
if (rtattr_strlcpy(act_name, kind,
IFNAMSIZ) >= IFNAMSIZ)
goto err_out; goto err_out;
} else { if (rtattr_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
printk("Action bad kind\n");
goto err_out; goto err_out;
}
a_o = tc_lookup_action(kind);
} else { } else {
sprintf(act_name, "%s", name); if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)
DPRINTK("tcf_action_init_1: finding %s\n", act_name); goto err_out;
a_o = tc_lookup_action_n(name);
} }
*err = -ENOENT;
a_o = tc_lookup_action_n(act_name);
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (a_o == NULL) { if (a_o == NULL) {
DPRINTK("tcf_action_init_1: trying to load module %s\n",
act_name);
request_module(act_name); request_module(act_name);
a_o = tc_lookup_action_n(act_name); a_o = tc_lookup_action_n(act_name);
} }
#endif #endif
if (a_o == NULL) { if (a_o == NULL)
printk("failed to find %s\n", act_name);
goto err_out; goto err_out;
}
a = kmalloc(sizeof(*a), GFP_KERNEL);
if (a == NULL) {
*err = -ENOMEM; *err = -ENOMEM;
a = kmalloc(sizeof(*a), GFP_KERNEL);
if (a == NULL)
goto err_mod; goto err_mod;
}
memset(a, 0, sizeof(*a)); memset(a, 0, sizeof(*a));
/* backward compatibility for policer */ /* backward compatibility for policer */
if (name == NULL) { if (name == NULL)
*err = a_o->init(tb[TCA_ACT_OPTIONS-1], est, a, ovr, bind); *err = a_o->init(tb[TCA_ACT_OPTIONS-1], est, a, ovr, bind);
if (*err < 0) { else
*err = -EINVAL;
goto err_free;
}
} else {
*err = a_o->init(rta, est, a, ovr, bind); *err = a_o->init(rta, est, a, ovr, bind);
if (*err < 0) { if (*err < 0)
*err = -EINVAL;
goto err_free; goto err_free;
}
}
/* module count goes up only when brand new policy is created /* module count goes up only when brand new policy is created
if it exists and is only bound to in a_o->init() then if it exists and is only bound to in a_o->init() then
...@@ -370,10 +354,8 @@ struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est, ...@@ -370,10 +354,8 @@ struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est,
if (tb[i]) { if (tb[i]) {
act = tcf_action_init_1(tb[i], est, name, ovr, bind, act = tcf_action_init_1(tb[i], est, name, ovr, bind,
err); err);
if (act == NULL) { if (act == NULL)
printk("Error processing action order %d\n", i);
goto bad_ret; goto bad_ret;
}
act->order = i+1; act->order = i+1;
if (a == NULL) if (a == NULL)
...@@ -838,8 +820,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) ...@@ -838,8 +820,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
ret = tca_action_gd(tca[TCA_ACT_TAB-1], n, pid, RTM_GETACTION); ret = tca_action_gd(tca[TCA_ACT_TAB-1], n, pid, RTM_GETACTION);
break; break;
default: default:
printk("Unknown cmd was detected\n"); BUG();
break;
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment