* [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims
@ 2018-02-24 11:03 Sven Eckelmann
2018-02-24 11:03 ` [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix netlink dumping of BLA backbones Sven Eckelmann
2018-02-26 16:34 ` [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims Simon Wunderlich
0 siblings, 2 replies; 3+ messages in thread
From: Sven Eckelmann @ 2018-02-24 11:03 UTC (permalink / raw)
To: b.a.t.m.a.n
The function batadv_bla_claim_dump_bucket must be able to handle
non-complete dumps of a single bucket. It tries to do that by saving the
latest dumped index in *idx_skip to inform the caller about the current
state.
But the caller only assumes that buckets were not completely dumped when
the return code is non-zero. This function must therefore also return a
non-zero index when the dumping of an entry failed. Otherwise the caller
will just skip all remaining buckets.
And the function must also reset *idx_skip back to zero when it finished a
bucket. Otherwise it will skip the same number of entries in the next
bucket as the previous one had.
Fixes: 3b7a63606020 ("batman-adv: add B.A.T.M.A.N. Dump BLA claims via netlink")
Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/bridge_loop_avoidance.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index cdd8e8e4..60ce119e 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -2161,22 +2161,25 @@ batadv_bla_claim_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq,
{
struct batadv_bla_claim *claim;
int idx = 0;
+ int ret = 0;
rcu_read_lock();
hlist_for_each_entry_rcu(claim, head, hash_entry) {
if (idx++ < *idx_skip)
continue;
- if (batadv_bla_claim_dump_entry(msg, portid, seq,
- primary_if, claim)) {
+
+ ret = batadv_bla_claim_dump_entry(msg, portid, seq,
+ primary_if, claim);
+ if (ret) {
*idx_skip = idx - 1;
goto unlock;
}
}
- *idx_skip = idx;
+ *idx_skip = 0;
unlock:
rcu_read_unlock();
- return 0;
+ return ret;
}
/**
--
2.16.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix netlink dumping of BLA backbones
2018-02-24 11:03 [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims Sven Eckelmann
@ 2018-02-24 11:03 ` Sven Eckelmann
2018-02-26 16:34 ` [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims Simon Wunderlich
1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2018-02-24 11:03 UTC (permalink / raw)
To: b.a.t.m.a.n
The function batadv_bla_backbone_dump_bucket must be able to handle
non-complete dumps of a single bucket. It tries to do that by saving the
latest dumped index in *idx_skip to inform the caller about the current
state.
But the caller only assumes that buckets were not completely dumped when
the return code is non-zero. This function must therefore also return a
non-zero index when the dumping of an entry failed. Otherwise the caller
will just skip all remaining buckets.
And the function must also reset *idx_skip back to zero when it finished a
bucket. Otherwise it will skip the same number of entries in the next
bucket as the previous one had.
Fixes: 7f609cab5123 ("batman-adv: add backbone table netlink support")
Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/bridge_loop_avoidance.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 60ce119e..422ee16b 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -2394,22 +2394,25 @@ batadv_bla_backbone_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq,
{
struct batadv_bla_backbone_gw *backbone_gw;
int idx = 0;
+ int ret = 0;
rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
if (idx++ < *idx_skip)
continue;
- if (batadv_bla_backbone_dump_entry(msg, portid, seq,
- primary_if, backbone_gw)) {
+
+ ret = batadv_bla_backbone_dump_entry(msg, portid, seq,
+ primary_if, backbone_gw);
+ if (ret) {
*idx_skip = idx - 1;
goto unlock;
}
}
- *idx_skip = idx;
+ *idx_skip = 0;
unlock:
rcu_read_unlock();
- return 0;
+ return ret;
}
/**
--
2.16.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims
2018-02-24 11:03 [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims Sven Eckelmann
2018-02-24 11:03 ` [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix netlink dumping of BLA backbones Sven Eckelmann
@ 2018-02-26 16:34 ` Simon Wunderlich
1 sibling, 0 replies; 3+ messages in thread
From: Simon Wunderlich @ 2018-02-26 16:34 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 838 bytes --]
On Saturday, February 24, 2018 12:03:36 PM CET Sven Eckelmann wrote:
> The function batadv_bla_claim_dump_bucket must be able to handle
> non-complete dumps of a single bucket. It tries to do that by saving the
> latest dumped index in *idx_skip to inform the caller about the current
> state.
>
> But the caller only assumes that buckets were not completely dumped when
> the return code is non-zero. This function must therefore also return a
> non-zero index when the dumping of an entry failed. Otherwise the caller
> will just skip all remaining buckets.
>
> And the function must also reset *idx_skip back to zero when it finished a
> bucket. Otherwise it will skip the same number of entries in the next
> bucket as the previous one had.
I've applied both patches in this series in 49197c00 and 29e4759e.
Thank you!
Simon
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-26 16:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-24 11:03 [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims Sven Eckelmann
2018-02-24 11:03 ` [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix netlink dumping of BLA backbones Sven Eckelmann
2018-02-26 16:34 ` [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix netlink dumping of BLA claims Simon Wunderlich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox