aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2018-02-24 06:03:37 -0500
committerSimon Wunderlich <sw@simonwunderlich.de>2018-02-25 14:11:59 -0500
commitfce672db548ff19e76a08a32a829544617229bc2 (patch)
tree90530a29bc6c58bc93944250a9030163d0501887
parentb0264ecdfeab5f889b02ec54af7ca8cc1c245e2f (diff)
batman-adv: Fix netlink dumping of BLA backbones
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: ea4152e11716 ("batman-adv: add backbone table netlink support") Reported-by: Linus Lüssing <linus.luessing@c0d3.blue> Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 20b548ea5a0a..b1a08374088b 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,
2394{ 2394{
2395 struct batadv_bla_backbone_gw *backbone_gw; 2395 struct batadv_bla_backbone_gw *backbone_gw;
2396 int idx = 0; 2396 int idx = 0;
2397 int ret = 0;
2397 2398
2398 rcu_read_lock(); 2399 rcu_read_lock();
2399 hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) { 2400 hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
2400 if (idx++ < *idx_skip) 2401 if (idx++ < *idx_skip)
2401 continue; 2402 continue;
2402 if (batadv_bla_backbone_dump_entry(msg, portid, seq, 2403
2403 primary_if, backbone_gw)) { 2404 ret = batadv_bla_backbone_dump_entry(msg, portid, seq,
2405 primary_if, backbone_gw);
2406 if (ret) {
2404 *idx_skip = idx - 1; 2407 *idx_skip = idx - 1;
2405 goto unlock; 2408 goto unlock;
2406 } 2409 }
2407 } 2410 }
2408 2411
2409 *idx_skip = idx; 2412 *idx_skip = 0;
2410unlock: 2413unlock:
2411 rcu_read_unlock(); 2414 rcu_read_unlock();
2412 return 0; 2415 return ret;
2413} 2416}
2414 2417
2415/** 2418/**