Skip to content

Commit

Permalink
net: Fix continued iteration in rtnl_bridge_getlink()
Browse files Browse the repository at this point in the history
Commit e5a55a8 ('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>
  • Loading branch information
Ben Hutchings authored and David S. Miller committed Nov 3, 2012
1 parent 1a72418 commit 25b1e67
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
struct net_device *master = dev->master;

if (idx < cb->args[0])
continue;

if (master && master->netdev_ops->ndo_bridge_getlink) {
const struct net_device_ops *bops = master->netdev_ops;
int err = bops->ndo_bridge_getlink(skb, portid,
seq, dev);

if (err < 0)
if (idx >= cb->args[0] &&
master->netdev_ops->ndo_bridge_getlink(
skb, portid, seq, dev) < 0)
break;
else
idx++;
idx++;
}

if (ops->ndo_bridge_getlink) {
int err = ops->ndo_bridge_getlink(skb, portid,
seq, dev);

if (err < 0)
if (idx >= cb->args[0] &&
ops->ndo_bridge_getlink(skb, portid, seq, dev) < 0)
break;
else
idx++;
idx++;
}
}
rcu_read_unlock();
Expand Down

0 comments on commit 25b1e67

Please sign in to comment.