pkt_sched: act_api: Move away from NLMSG_PUT().
Move away from NLMSG_NEW() as well. And use nlmsg_data() while we're here too. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -652,27 +652,27 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
|
|||||||
unsigned char *b = skb_tail_pointer(skb);
|
unsigned char *b = skb_tail_pointer(skb);
|
||||||
struct nlattr *nest;
|
struct nlattr *nest;
|
||||||
|
|
||||||
nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
|
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*t), flags);
|
||||||
|
if (!nlh)
|
||||||
t = NLMSG_DATA(nlh);
|
goto out_nlmsg_trim;
|
||||||
|
t = nlmsg_data(nlh);
|
||||||
t->tca_family = AF_UNSPEC;
|
t->tca_family = AF_UNSPEC;
|
||||||
t->tca__pad1 = 0;
|
t->tca__pad1 = 0;
|
||||||
t->tca__pad2 = 0;
|
t->tca__pad2 = 0;
|
||||||
|
|
||||||
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
||||||
if (nest == NULL)
|
if (nest == NULL)
|
||||||
goto nla_put_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
if (tcf_action_dump(skb, a, bind, ref) < 0)
|
if (tcf_action_dump(skb, a, bind, ref) < 0)
|
||||||
goto nla_put_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
nla_nest_end(skb, nest);
|
nla_nest_end(skb, nest);
|
||||||
|
|
||||||
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
|
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
|
||||||
return skb->len;
|
return skb->len;
|
||||||
|
|
||||||
nla_put_failure:
|
out_nlmsg_trim:
|
||||||
nlmsg_failure:
|
|
||||||
nlmsg_trim(skb, b);
|
nlmsg_trim(skb, b);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -799,19 +799,21 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
|
|||||||
if (a->ops == NULL)
|
if (a->ops == NULL)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
nlh = NLMSG_PUT(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t));
|
nlh = nlmsg_put(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
|
||||||
t = NLMSG_DATA(nlh);
|
if (!nlh)
|
||||||
|
goto out_module_put;
|
||||||
|
t = nlmsg_data(nlh);
|
||||||
t->tca_family = AF_UNSPEC;
|
t->tca_family = AF_UNSPEC;
|
||||||
t->tca__pad1 = 0;
|
t->tca__pad1 = 0;
|
||||||
t->tca__pad2 = 0;
|
t->tca__pad2 = 0;
|
||||||
|
|
||||||
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
||||||
if (nest == NULL)
|
if (nest == NULL)
|
||||||
goto nla_put_failure;
|
goto out_module_put;
|
||||||
|
|
||||||
err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
|
err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto nla_put_failure;
|
goto out_module_put;
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
goto noflush_out;
|
goto noflush_out;
|
||||||
|
|
||||||
@@ -828,8 +830,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
nla_put_failure:
|
out_module_put:
|
||||||
nlmsg_failure:
|
|
||||||
module_put(a->ops->owner);
|
module_put(a->ops->owner);
|
||||||
err_out:
|
err_out:
|
||||||
noflush_out:
|
noflush_out:
|
||||||
@@ -919,18 +920,20 @@ static int tcf_add_notify(struct net *net, struct tc_action *a,
|
|||||||
|
|
||||||
b = skb_tail_pointer(skb);
|
b = skb_tail_pointer(skb);
|
||||||
|
|
||||||
nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
|
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*t), flags);
|
||||||
t = NLMSG_DATA(nlh);
|
if (!nlh)
|
||||||
|
goto out_kfree_skb;
|
||||||
|
t = nlmsg_data(nlh);
|
||||||
t->tca_family = AF_UNSPEC;
|
t->tca_family = AF_UNSPEC;
|
||||||
t->tca__pad1 = 0;
|
t->tca__pad1 = 0;
|
||||||
t->tca__pad2 = 0;
|
t->tca__pad2 = 0;
|
||||||
|
|
||||||
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
||||||
if (nest == NULL)
|
if (nest == NULL)
|
||||||
goto nla_put_failure;
|
goto out_kfree_skb;
|
||||||
|
|
||||||
if (tcf_action_dump(skb, a, 0, 0) < 0)
|
if (tcf_action_dump(skb, a, 0, 0) < 0)
|
||||||
goto nla_put_failure;
|
goto out_kfree_skb;
|
||||||
|
|
||||||
nla_nest_end(skb, nest);
|
nla_nest_end(skb, nest);
|
||||||
|
|
||||||
@@ -942,8 +945,7 @@ static int tcf_add_notify(struct net *net, struct tc_action *a,
|
|||||||
err = 0;
|
err = 0;
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
nla_put_failure:
|
out_kfree_skb:
|
||||||
nlmsg_failure:
|
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1062,7 +1064,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
struct tc_action_ops *a_o;
|
struct tc_action_ops *a_o;
|
||||||
struct tc_action a;
|
struct tc_action a;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
|
struct tcamsg *t = (struct tcamsg *) nlmsg_data(cb->nlh);
|
||||||
struct nlattr *kind = find_dump_kind(cb->nlh);
|
struct nlattr *kind = find_dump_kind(cb->nlh);
|
||||||
|
|
||||||
if (kind == NULL) {
|
if (kind == NULL) {
|
||||||
@@ -1080,23 +1082,25 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
if (a_o->walk == NULL) {
|
if (a_o->walk == NULL) {
|
||||||
WARN(1, "tc_dump_action: %s !capable of dumping table\n",
|
WARN(1, "tc_dump_action: %s !capable of dumping table\n",
|
||||||
a_o->kind);
|
a_o->kind);
|
||||||
goto nla_put_failure;
|
goto out_module_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
|
nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
|
||||||
cb->nlh->nlmsg_type, sizeof(*t));
|
cb->nlh->nlmsg_type, sizeof(*t), 0);
|
||||||
t = NLMSG_DATA(nlh);
|
if (!nlh)
|
||||||
|
goto out_module_put;
|
||||||
|
t = nlmsg_data(nlh);
|
||||||
t->tca_family = AF_UNSPEC;
|
t->tca_family = AF_UNSPEC;
|
||||||
t->tca__pad1 = 0;
|
t->tca__pad1 = 0;
|
||||||
t->tca__pad2 = 0;
|
t->tca__pad2 = 0;
|
||||||
|
|
||||||
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
nest = nla_nest_start(skb, TCA_ACT_TAB);
|
||||||
if (nest == NULL)
|
if (nest == NULL)
|
||||||
goto nla_put_failure;
|
goto out_module_put;
|
||||||
|
|
||||||
ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
|
ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto nla_put_failure;
|
goto out_module_put;
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
nla_nest_end(skb, nest);
|
nla_nest_end(skb, nest);
|
||||||
@@ -1110,8 +1114,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
module_put(a_o->owner);
|
module_put(a_o->owner);
|
||||||
return skb->len;
|
return skb->len;
|
||||||
|
|
||||||
nla_put_failure:
|
out_module_put:
|
||||||
nlmsg_failure:
|
|
||||||
module_put(a_o->owner);
|
module_put(a_o->owner);
|
||||||
nlmsg_trim(skb, b);
|
nlmsg_trim(skb, b);
|
||||||
return skb->len;
|
return skb->len;
|
||||||
|
Reference in New Issue
Block a user