diff options
author | Sven Eckelmann <sven@narfation.org> | 2018-02-24 06:03:36 -0500 |
---|---|---|
committer | Simon Wunderlich <sw@simonwunderlich.de> | 2018-02-25 14:11:42 -0500 |
commit | b0264ecdfeab5f889b02ec54af7ca8cc1c245e2f (patch) | |
tree | aadaa065e92955e244917e27e6ad28cc27ef22a9 | |
parent | 011c935fceae5252619ef730baa610c655281dda (diff) |
batman-adv: Fix netlink dumping of BLA claims
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: 04f3f5bf1883 ("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>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 11 |
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 fad47853ad3c..20b548ea5a0a 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, | |||
2161 | { | 2161 | { |
2162 | struct batadv_bla_claim *claim; | 2162 | struct batadv_bla_claim *claim; |
2163 | int idx = 0; | 2163 | int idx = 0; |
2164 | int ret = 0; | ||
2164 | 2165 | ||
2165 | rcu_read_lock(); | 2166 | rcu_read_lock(); |
2166 | hlist_for_each_entry_rcu(claim, head, hash_entry) { | 2167 | hlist_for_each_entry_rcu(claim, head, hash_entry) { |
2167 | if (idx++ < *idx_skip) | 2168 | if (idx++ < *idx_skip) |
2168 | continue; | 2169 | continue; |
2169 | if (batadv_bla_claim_dump_entry(msg, portid, seq, | 2170 | |
2170 | primary_if, claim)) { | 2171 | ret = batadv_bla_claim_dump_entry(msg, portid, seq, |
2172 | primary_if, claim); | ||
2173 | if (ret) { | ||
2171 | *idx_skip = idx - 1; | 2174 | *idx_skip = idx - 1; |
2172 | goto unlock; | 2175 | goto unlock; |
2173 | } | 2176 | } |
2174 | } | 2177 | } |
2175 | 2178 | ||
2176 | *idx_skip = idx; | 2179 | *idx_skip = 0; |
2177 | unlock: | 2180 | unlock: |
2178 | rcu_read_unlock(); | 2181 | rcu_read_unlock(); |
2179 | return 0; | 2182 | return ret; |
2180 | } | 2183 | } |
2181 | 2184 | ||
2182 | /** | 2185 | /** |