aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_api.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-27 00:50:05 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-27 00:54:15 -0400
commit02ef22ca4044fe90867f77cba720e4a442122826 (patch)
tree3a530233f93d6c7f20708064581f32499575a64f /net/sched/sch_api.c
parent942b81653a5252fc0d7071f685113fc0ada28d4b (diff)
pkt_sched: sch_api: Move away from NLMSG_NEW().
And use nlmsg_data() while we're here too, as well as remove a useless cast. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_api.c')
-rw-r--r--net/sched/sch_api.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 085ce53d570a..a08b4ab3e421 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -973,7 +973,7 @@ check_loop_fn(struct Qdisc *q, unsigned long cl, struct qdisc_walker *w)
973static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg) 973static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
974{ 974{
975 struct net *net = sock_net(skb->sk); 975 struct net *net = sock_net(skb->sk);
976 struct tcmsg *tcm = NLMSG_DATA(n); 976 struct tcmsg *tcm = nlmsg_data(n);
977 struct nlattr *tca[TCA_MAX + 1]; 977 struct nlattr *tca[TCA_MAX + 1];
978 struct net_device *dev; 978 struct net_device *dev;
979 u32 clid = tcm->tcm_parent; 979 u32 clid = tcm->tcm_parent;
@@ -1046,7 +1046,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
1046 1046
1047replay: 1047replay:
1048 /* Reinit, just in case something touches this. */ 1048 /* Reinit, just in case something touches this. */
1049 tcm = NLMSG_DATA(n); 1049 tcm = nlmsg_data(n);
1050 clid = tcm->tcm_parent; 1050 clid = tcm->tcm_parent;
1051 q = p = NULL; 1051 q = p = NULL;
1052 1052
@@ -1193,8 +1193,10 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
1193 struct gnet_dump d; 1193 struct gnet_dump d;
1194 struct qdisc_size_table *stab; 1194 struct qdisc_size_table *stab;
1195 1195
1196 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); 1196 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*tcm), flags);
1197 tcm = NLMSG_DATA(nlh); 1197 if (!nlh)
1198 goto out_nlmsg_trim;
1199 tcm = nlmsg_data(nlh);
1198 tcm->tcm_family = AF_UNSPEC; 1200 tcm->tcm_family = AF_UNSPEC;
1199 tcm->tcm__pad1 = 0; 1201 tcm->tcm__pad1 = 0;
1200 tcm->tcm__pad2 = 0; 1202 tcm->tcm__pad2 = 0;
@@ -1230,7 +1232,7 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
1230 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 1232 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1231 return skb->len; 1233 return skb->len;
1232 1234
1233nlmsg_failure: 1235out_nlmsg_trim:
1234nla_put_failure: 1236nla_put_failure:
1235 nlmsg_trim(skb, b); 1237 nlmsg_trim(skb, b);
1236 return -1; 1238 return -1;
@@ -1366,7 +1368,7 @@ done:
1366static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg) 1368static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
1367{ 1369{
1368 struct net *net = sock_net(skb->sk); 1370 struct net *net = sock_net(skb->sk);
1369 struct tcmsg *tcm = NLMSG_DATA(n); 1371 struct tcmsg *tcm = nlmsg_data(n);
1370 struct nlattr *tca[TCA_MAX + 1]; 1372 struct nlattr *tca[TCA_MAX + 1];
1371 struct net_device *dev; 1373 struct net_device *dev;
1372 struct Qdisc *q = NULL; 1374 struct Qdisc *q = NULL;
@@ -1498,8 +1500,10 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
1498 struct gnet_dump d; 1500 struct gnet_dump d;
1499 const struct Qdisc_class_ops *cl_ops = q->ops->cl_ops; 1501 const struct Qdisc_class_ops *cl_ops = q->ops->cl_ops;
1500 1502
1501 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); 1503 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*tcm), flags);
1502 tcm = NLMSG_DATA(nlh); 1504 if (!nlh)
1505 goto out_nlmsg_trim;
1506 tcm = nlmsg_data(nlh);
1503 tcm->tcm_family = AF_UNSPEC; 1507 tcm->tcm_family = AF_UNSPEC;
1504 tcm->tcm__pad1 = 0; 1508 tcm->tcm__pad1 = 0;
1505 tcm->tcm__pad2 = 0; 1509 tcm->tcm__pad2 = 0;
@@ -1525,7 +1529,7 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
1525 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 1529 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1526 return skb->len; 1530 return skb->len;
1527 1531
1528nlmsg_failure: 1532out_nlmsg_trim:
1529nla_put_failure: 1533nla_put_failure:
1530 nlmsg_trim(skb, b); 1534 nlmsg_trim(skb, b);
1531 return -1; 1535 return -1;
@@ -1616,7 +1620,7 @@ static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb,
1616 1620
1617static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) 1621static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
1618{ 1622{
1619 struct tcmsg *tcm = (struct tcmsg *)NLMSG_DATA(cb->nlh); 1623 struct tcmsg *tcm = nlmsg_data(cb->nlh);
1620 struct net *net = sock_net(skb->sk); 1624 struct net *net = sock_net(skb->sk);
1621 struct netdev_queue *dev_queue; 1625 struct netdev_queue *dev_queue;
1622 struct net_device *dev; 1626 struct net_device *dev;