Commit 02ef22ca4044fe90867f77cba720e4a442122826
1 parent
942b81653a
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 14 additions and 10 deletions Side-by-side Diff
net/sched/sch_api.c
... | ... | @@ -973,7 +973,7 @@ |
973 | 973 | static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg) |
974 | 974 | { |
975 | 975 | struct net *net = sock_net(skb->sk); |
976 | - struct tcmsg *tcm = NLMSG_DATA(n); | |
976 | + struct tcmsg *tcm = nlmsg_data(n); | |
977 | 977 | struct nlattr *tca[TCA_MAX + 1]; |
978 | 978 | struct net_device *dev; |
979 | 979 | u32 clid = tcm->tcm_parent; |
... | ... | @@ -1046,7 +1046,7 @@ |
1046 | 1046 | |
1047 | 1047 | replay: |
1048 | 1048 | /* Reinit, just in case something touches this. */ |
1049 | - tcm = NLMSG_DATA(n); | |
1049 | + tcm = nlmsg_data(n); | |
1050 | 1050 | clid = tcm->tcm_parent; |
1051 | 1051 | q = p = NULL; |
1052 | 1052 | |
... | ... | @@ -1193,8 +1193,10 @@ |
1193 | 1193 | struct gnet_dump d; |
1194 | 1194 | struct qdisc_size_table *stab; |
1195 | 1195 | |
1196 | - nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); | |
1197 | - tcm = NLMSG_DATA(nlh); | |
1196 | + nlh = nlmsg_put(skb, pid, seq, event, sizeof(*tcm), flags); | |
1197 | + if (!nlh) | |
1198 | + goto out_nlmsg_trim; | |
1199 | + tcm = nlmsg_data(nlh); | |
1198 | 1200 | tcm->tcm_family = AF_UNSPEC; |
1199 | 1201 | tcm->tcm__pad1 = 0; |
1200 | 1202 | tcm->tcm__pad2 = 0; |
... | ... | @@ -1230,7 +1232,7 @@ |
1230 | 1232 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1231 | 1233 | return skb->len; |
1232 | 1234 | |
1233 | -nlmsg_failure: | |
1235 | +out_nlmsg_trim: | |
1234 | 1236 | nla_put_failure: |
1235 | 1237 | nlmsg_trim(skb, b); |
1236 | 1238 | return -1; |
... | ... | @@ -1366,7 +1368,7 @@ |
1366 | 1368 | static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg) |
1367 | 1369 | { |
1368 | 1370 | struct net *net = sock_net(skb->sk); |
1369 | - struct tcmsg *tcm = NLMSG_DATA(n); | |
1371 | + struct tcmsg *tcm = nlmsg_data(n); | |
1370 | 1372 | struct nlattr *tca[TCA_MAX + 1]; |
1371 | 1373 | struct net_device *dev; |
1372 | 1374 | struct Qdisc *q = NULL; |
... | ... | @@ -1498,8 +1500,10 @@ |
1498 | 1500 | struct gnet_dump d; |
1499 | 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); | |
1502 | - tcm = NLMSG_DATA(nlh); | |
1503 | + nlh = nlmsg_put(skb, pid, seq, event, sizeof(*tcm), flags); | |
1504 | + if (!nlh) | |
1505 | + goto out_nlmsg_trim; | |
1506 | + tcm = nlmsg_data(nlh); | |
1503 | 1507 | tcm->tcm_family = AF_UNSPEC; |
1504 | 1508 | tcm->tcm__pad1 = 0; |
1505 | 1509 | tcm->tcm__pad2 = 0; |
... | ... | @@ -1525,7 +1529,7 @@ |
1525 | 1529 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1526 | 1530 | return skb->len; |
1527 | 1531 | |
1528 | -nlmsg_failure: | |
1532 | +out_nlmsg_trim: | |
1529 | 1533 | nla_put_failure: |
1530 | 1534 | nlmsg_trim(skb, b); |
1531 | 1535 | return -1; |
... | ... | @@ -1616,7 +1620,7 @@ |
1616 | 1620 | |
1617 | 1621 | static 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 | 1624 | struct net *net = sock_net(skb->sk); |
1621 | 1625 | struct netdev_queue *dev_queue; |
1622 | 1626 | struct net_device *dev; |