Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
extern int tcf_unregister_action(struct tc_action_ops *a);
extern void tcf_action_destroy(struct tc_action *a, int bind);
extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
extern int tcf_unregister_action(struct tc_action_ops *a);
extern void tcf_action_destroy(struct tc_action *a, int bind);
extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
-extern struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind, int *err);
-extern struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind, int *err);
+extern struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind);
+extern struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind);
extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/sch_generic.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/sch_generic.h>
}
struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
}
struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
- char *name, int ovr, int bind, int *err)
+ char *name, int ovr, int bind)
{
struct tc_action *a;
struct tc_action_ops *a_o;
char act_name[IFNAMSIZ];
struct nlattr *tb[TCA_ACT_MAX+1];
struct nlattr *kind;
{
struct tc_action *a;
struct tc_action_ops *a_o;
char act_name[IFNAMSIZ];
struct nlattr *tb[TCA_ACT_MAX+1];
struct nlattr *kind;
if (name == NULL) {
if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
if (name == NULL) {
if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
* indicate this using -EAGAIN.
*/
if (a_o != NULL) {
* indicate this using -EAGAIN.
*/
if (a_o != NULL) {
a = kzalloc(sizeof(*a), GFP_KERNEL);
if (a == NULL)
goto err_mod;
/* backward compatibility for policer */
if (name == NULL)
a = kzalloc(sizeof(*a), GFP_KERNEL);
if (a == NULL)
goto err_mod;
/* backward compatibility for policer */
if (name == NULL)
- *err = a_o->init(tb[TCA_ACT_OPTIONS], est, a, ovr, bind);
+ err = a_o->init(tb[TCA_ACT_OPTIONS], est, a, ovr, bind);
- *err = a_o->init(nla, est, a, ovr, bind);
- if (*err < 0)
+ err = a_o->init(nla, est, a, ovr, bind);
+ if (err < 0)
goto err_free;
/* module count goes up only when brand new policy is created
if it exists and is only bound to in a_o->init() then
ACT_P_CREATED is not returned (a zero is).
*/
goto err_free;
/* module count goes up only when brand new policy is created
if it exists and is only bound to in a_o->init() then
ACT_P_CREATED is not returned (a zero is).
*/
- if (*err != ACT_P_CREATED)
+ if (err != ACT_P_CREATED)
module_put(a_o->owner);
a->ops = a_o;
module_put(a_o->owner);
a->ops = a_o;
err_mod:
module_put(a_o->owner);
err_out:
err_mod:
module_put(a_o->owner);
err_out:
}
struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
}
struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
- char *name, int ovr, int bind, int *err)
+ char *name, int ovr, int bind)
{
struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
struct tc_action *head = NULL, *act, *act_prev = NULL;
int i;
{
struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
struct tc_action *head = NULL, *act, *act_prev = NULL;
int i;
- if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0) {
- *err = -EINVAL;
- return head;
- }
+ if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0)
+ return ERR_PTR(-EINVAL);
for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
- act = tcf_action_init_1(tb[i], est, name, ovr, bind, err);
- if (act == NULL)
+ act = tcf_action_init_1(tb[i], est, name, ovr, bind);
+ if (IS_ERR(act))
goto err;
act->order = i;
goto err;
act->order = i;
err:
if (head != NULL)
tcf_action_destroy(head, bind);
err:
if (head != NULL)
tcf_action_destroy(head, bind);
}
int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
}
int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
}
static struct tc_action *
}
static struct tc_action *
-tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int *err)
+tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
{
struct nlattr *tb[TCA_ACT_MAX+1];
struct tc_action *a;
int index;
{
struct nlattr *tb[TCA_ACT_MAX+1];
struct tc_action *a;
int index;
if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
if (tb[TCA_ACT_INDEX] == NULL ||
nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
if (tb[TCA_ACT_INDEX] == NULL ||
nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
index = *(int *)nla_data(tb[TCA_ACT_INDEX]);
index = *(int *)nla_data(tb[TCA_ACT_INDEX]);
a = kzalloc(sizeof(struct tc_action), GFP_KERNEL);
if (a == NULL)
a = kzalloc(sizeof(struct tc_action), GFP_KERNEL);
if (a == NULL)
a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
if (a->ops == NULL)
goto err_free;
if (a->ops->lookup == NULL)
goto err_mod;
a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
if (a->ops == NULL)
goto err_free;
if (a->ops->lookup == NULL)
goto err_mod;
if (a->ops->lookup(a, index) == 0)
goto err_mod;
module_put(a->ops->owner);
if (a->ops->lookup(a, index) == 0)
goto err_mod;
module_put(a->ops->owner);
err_mod:
module_put(a->ops->owner);
err_free:
kfree(a);
err_mod:
module_put(a->ops->owner);
err_free:
kfree(a);
+err_out:
+ return ERR_PTR(err);
}
static void cleanup_a(struct tc_action *act)
}
static void cleanup_a(struct tc_action *act)
}
for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
}
for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
- act = tcf_action_get_1(tb[i], n, pid, &ret);
- if (act == NULL)
+ act = tcf_action_get_1(tb[i], n, pid);
+ if (IS_ERR(act)) {
+ ret = PTR_ERR(act);
act->order = i;
if (head == NULL)
act->order = i;
if (head == NULL)
struct tc_action *a;
u32 seq = n->nlmsg_seq;
struct tc_action *a;
u32 seq = n->nlmsg_seq;
- act = tcf_action_init(nla, NULL, NULL, ovr, 0, &ret);
+ act = tcf_action_init(nla, NULL, NULL, ovr, 0);
if (act == NULL)
goto done;
if (act == NULL)
goto done;
+ if (IS_ERR(act)) {
+ ret = PTR_ERR(act);
+ goto done;
+ }
/* dump then free all the actions after update; inserted policy
* stays intact
/* dump then free all the actions after update; inserted policy
* stays intact
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/netlink.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/netlink.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/netlink.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/netlink.h>
#ifdef CONFIG_NET_CLS_ACT
{
#ifdef CONFIG_NET_CLS_ACT
{
struct tc_action *act;
if (map->police && tb[map->police]) {
act = tcf_action_init_1(tb[map->police], rate_tlv,
"police", TCA_ACT_NOREPLACE,
struct tc_action *act;
if (map->police && tb[map->police]) {
act = tcf_action_init_1(tb[map->police], rate_tlv,
"police", TCA_ACT_NOREPLACE,
- TCA_ACT_BIND, &err);
- if (act == NULL)
- return err;
+ TCA_ACT_BIND);
+ if (IS_ERR(act))
+ return PTR_ERR(act);
act->type = TCA_OLD_COMPAT;
exts->action = act;
} else if (map->action && tb[map->action]) {
act = tcf_action_init(tb[map->action], rate_tlv, NULL,
act->type = TCA_OLD_COMPAT;
exts->action = act;
} else if (map->action && tb[map->action]) {
act = tcf_action_init(tb[map->action], rate_tlv, NULL,
- TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
- if (act == NULL)
- return err;
+ TCA_ACT_NOREPLACE, TCA_ACT_BIND);
+ if (IS_ERR(act))
+ return PTR_ERR(act);