* [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink()
@ 2012-11-02 22:56 Ben Hutchings
2012-11-02 23:04 ` Ben Hutchings
2012-11-03 1:42 ` John Fastabend
0 siblings, 2 replies; 4+ messages in thread
From: Ben Hutchings @ 2012-11-02 22:56 UTC (permalink / raw)
To: David Miller; +Cc: netdev, John Fastabend, Stephen Hemminger
Commit e5a55a898720096f43bc24938f8875c0a1b34cd7 ('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>
---
This is compile-tested only, as I don't know what userland code to test
with. I'm still not sure it's correct to break iteration if
ndo_bridge_getlink returns -EOPNOTSUPP (possible if the driver supports
a mixture of bridging and non-bridging devices).
Ben.
net/core/rtnetlink.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 51dc58f..a0e35076 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();
--
1.7.7.6
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink()
2012-11-02 22:56 [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink() Ben Hutchings
@ 2012-11-02 23:04 ` Ben Hutchings
2012-11-03 1:42 ` John Fastabend
1 sibling, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2012-11-02 23:04 UTC (permalink / raw)
To: David Miller; +Cc: netdev, John Fastabend, Stephen Hemminger
On Fri, 2012-11-02 at 22:56 +0000, Ben Hutchings wrote:
[...]
> I'm still not sure it's correct to break iteration if
> ndo_bridge_getlink returns -EOPNOTSUPP (possible if the driver supports
> a mixture of bridging and non-bridging devices).
[...]
Never mind that - the driver can just return 0 for those devices, as
ixgbe is doing. But the bug this patch addresses seems to be real.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink()
2012-11-02 22:56 [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink() Ben Hutchings
2012-11-02 23:04 ` Ben Hutchings
@ 2012-11-03 1:42 ` John Fastabend
2012-11-03 1:54 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: John Fastabend @ 2012-11-03 1:42 UTC (permalink / raw)
To: Ben Hutchings; +Cc: David Miller, netdev, Stephen Hemminger
On 11/2/2012 3:56 PM, Ben Hutchings wrote:
> Commit e5a55a898720096f43bc24938f8875c0a1b34cd7 ('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>
> ---
I needed to be testing with more interfaces. Its clearly broke
with >41 veth devices. This patch fixes it thanks a lot Ben!
Tested-by: John Fastabend <john.r.fastabend@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink()
2012-11-03 1:42 ` John Fastabend
@ 2012-11-03 1:54 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-11-03 1:54 UTC (permalink / raw)
To: john.r.fastabend; +Cc: bhutchings, netdev, shemminger
From: John Fastabend <john.r.fastabend@intel.com>
Date: Fri, 02 Nov 2012 18:42:03 -0700
> On 11/2/2012 3:56 PM, Ben Hutchings wrote:
>> Commit e5a55a898720096f43bc24938f8875c0a1b34cd7 ('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>
>> ---
>
> I needed to be testing with more interfaces. Its clearly broke
> with >41 veth devices. This patch fixes it thanks a lot Ben!
>
> Tested-by: John Fastabend <john.r.fastabend@intel.com>
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-03 1:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02 22:56 [PATCH net-next] net: Fix continued iteration in rtnl_bridge_getlink() Ben Hutchings
2012-11-02 23:04 ` Ben Hutchings
2012-11-03 1:42 ` John Fastabend
2012-11-03 1:54 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox