net: rtnetlink: fdb dflt dump must set idx used for cb->arg[0]
[firefly-linux-kernel-4.4.55.git] / net / core / rtnetlink.c
index 751f1244b6489e73d4493e7e76a4f4ad13aa4e59..d2322d7f0f7bbcd968ad7b610b5f1888c171369a 100644 (file)
@@ -1929,8 +1929,11 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
                if (rtnl_msg_handlers[idx] == NULL ||
                    rtnl_msg_handlers[idx][type].dumpit == NULL)
                        continue;
-               if (idx > s_idx)
+               if (idx > s_idx) {
                        memset(&cb->args[0], 0, sizeof(cb->args));
+                       cb->prev_seq = 0;
+                       cb->seq = 0;
+               }
                if (rtnl_msg_handlers[idx][type].dumpit(skb, cb))
                        break;
        }
@@ -2259,7 +2262,7 @@ skip:
  * @dev: netdevice
  *
  * Default netdevice operation to dump the existing unicast address list.
- * Returns zero on success.
+ * Returns number of addresses from list put in skb.
  */
 int ndo_dflt_fdb_dump(struct sk_buff *skb,
                      struct netlink_callback *cb,
@@ -2300,7 +2303,7 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
                if (dev->netdev_ops->ndo_fdb_dump)
                        idx = dev->netdev_ops->ndo_fdb_dump(skb, cb, dev, idx);
                else
-                       ndo_dflt_fdb_dump(skb, cb, dev, idx);
+                       idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
        }
        rcu_read_unlock();
 
@@ -2610,10 +2613,10 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
        type -= RTM_BASE;
 
        /* All the messages must have at least 1 byte length */
-       if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(struct rtgenmsg)))
+       if (nlmsg_len(nlh) < sizeof(struct rtgenmsg))
                return 0;
 
-       family = ((struct rtgenmsg *)NLMSG_DATA(nlh))->rtgen_family;
+       family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
        sz_idx = type>>2;
        kind = type&3;