Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / net / sched / cls_api.c
index 9a04b981bc137d52ef3ba427870f2f474dc40451..8e118af9097345a500e1006bff6fa5c108435603 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
-#include <linux/netlink.h>
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <net/net_namespace.h>
@@ -141,7 +140,12 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
 
        if ((n->nlmsg_type != RTM_GETTFILTER) && !capable(CAP_NET_ADMIN))
                return -EPERM;
+
 replay:
+       err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL);
+       if (err < 0)
+               return err;
+
        t = nlmsg_data(n);
        protocol = TC_H_MIN(t->tcm_info);
        prio = TC_H_MAJ(t->tcm_info);
@@ -164,10 +168,6 @@ replay:
        if (dev == NULL)
                return -ENODEV;
 
-       err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL);
-       if (err < 0)
-               return err;
-
        /* Find qdisc */
        if (!parent) {
                q = dev->qdisc;
@@ -427,7 +427,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
        const struct Qdisc_class_ops *cops;
        struct tcf_dump_args arg;
 
-       if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))
+       if (nlmsg_len(cb->nlh) < sizeof(*tcm))
                return skb->len;
        dev = __dev_get_by_index(net, tcm->tcm_ifindex);
        if (!dev)