net: Fix continued iteration in rtnl_bridge_getlink()

Commit e5a55a8987 ('net: create generic
bridge ops') broke the handling of a non-zero starting index in
rtnl_bridge_getlink() (based on the old br_dump_ifinfo()).

When the starting index is non-zero, we need to increment the current
index for each entry that we are skipping.  Also, we need to check the
index before both cases, since we may previously have stopped
iteration between getting information about a device from its master
and from itself.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Tested-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ben Hutchings 2012-11-02 12:56:52 +00:00 committed by David S. Miller
parent 1a72418bd7
commit 25b1e67921
1 changed files with 7 additions and 16 deletions

View File

@ -2315,28 +2315,19 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
const struct net_device_ops *ops = dev->netdev_ops; const struct net_device_ops *ops = dev->netdev_ops;
struct net_device *master = dev->master; struct net_device *master = dev->master;
if (idx < cb->args[0])
continue;
if (master && master->netdev_ops->ndo_bridge_getlink) { if (master && master->netdev_ops->ndo_bridge_getlink) {
const struct net_device_ops *bops = master->netdev_ops; if (idx >= cb->args[0] &&
int err = bops->ndo_bridge_getlink(skb, portid, master->netdev_ops->ndo_bridge_getlink(
seq, dev); skb, portid, seq, dev) < 0)
if (err < 0)
break; break;
else idx++;
idx++;
} }
if (ops->ndo_bridge_getlink) { if (ops->ndo_bridge_getlink) {
int err = ops->ndo_bridge_getlink(skb, portid, if (idx >= cb->args[0] &&
seq, dev); ops->ndo_bridge_getlink(skb, portid, seq, dev) < 0)
if (err < 0)
break; break;
else idx++;
idx++;
} }
} }
rcu_read_unlock(); rcu_read_unlock();