batman-adv: Merge bugfixes from 2018.0
[feed/routing.git] / batman-adv / patches / 0029-batman-adv-Fix-netlink-dumping-of-BLA-backbones.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sat, 24 Feb 2018 12:03:37 +0100
3 Subject: [PATCH] batman-adv: Fix netlink dumping of BLA backbones
4
5 The function batadv_bla_backbone_dump_bucket must be able to handle
6 non-complete dumps of a single bucket. It tries to do that by saving the
7 latest dumped index in *idx_skip to inform the caller about the current
8 state.
9
10 But the caller only assumes that buckets were not completely dumped when
11 the return code is non-zero. This function must therefore also return a
12 non-zero index when the dumping of an entry failed. Otherwise the caller
13 will just skip all remaining buckets.
14
15 And the function must also reset *idx_skip back to zero when it finished a
16 bucket. Otherwise it will skip the same number of entries in the next
17 bucket as the previous one had.
18
19 Fixes: 7f609cab5123 ("batman-adv: add backbone table netlink support")
20 Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
21 Signed-off-by: Sven Eckelmann <sven@narfation.org>
22 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
23
24 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/29e4759e49f06014b84791397ebe1b22546edd2d
25 ---
26 net/batman-adv/bridge_loop_avoidance.c | 11 +++++++----
27 1 file changed, 7 insertions(+), 4 deletions(-)
28
29 diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
30 index 4784469cadd4364b6239ce9ff0d1c7cc254de439..aecf34503e95d9aa723449ddbf0bb3035336b878 100644
31 --- a/net/batman-adv/bridge_loop_avoidance.c
32 +++ b/net/batman-adv/bridge_loop_avoidance.c
33 @@ -2382,22 +2382,25 @@ batadv_bla_backbone_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq,
34 {
35 struct batadv_bla_backbone_gw *backbone_gw;
36 int idx = 0;
37 + int ret = 0;
38
39 rcu_read_lock();
40 hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
41 if (idx++ < *idx_skip)
42 continue;
43 - if (batadv_bla_backbone_dump_entry(msg, portid, seq,
44 - primary_if, backbone_gw)) {
45 +
46 + ret = batadv_bla_backbone_dump_entry(msg, portid, seq,
47 + primary_if, backbone_gw);
48 + if (ret) {
49 *idx_skip = idx - 1;
50 goto unlock;
51 }
52 }
53
54 - *idx_skip = idx;
55 + *idx_skip = 0;
56 unlock:
57 rcu_read_unlock();
58 - return 0;
59 + return ret;
60 }
61
62 /**