From 4481d7c4e5d13e1f513e099315c9c4e3f650649c Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 2 Nov 2012 12:56:52 +0000 Subject: [PATCH] net: Fix continued iteration in rtnl_bridge_getlink() Commit 06c4884954d8669e2683c0f8684f7efba4bd011a ('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 Tested-by: John Fastabend Signed-off-by: David S. Miller --- net/core/rtnetlink.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 51dc58ff00910..a0e350763fbef 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -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(); -- 2.39.5