Commit fce672db authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Simon Wunderlich

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: ea4152e1 ("batman-adv: add backbone table netlink support")
Reported-by: default avatarLinus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
parent b0264ecd
...@@ -2394,22 +2394,25 @@ batadv_bla_backbone_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq, ...@@ -2394,22 +2394,25 @@ batadv_bla_backbone_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq,
{ {
struct batadv_bla_backbone_gw *backbone_gw; struct batadv_bla_backbone_gw *backbone_gw;
int idx = 0; int idx = 0;
int ret = 0;
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) { hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
if (idx++ < *idx_skip) if (idx++ < *idx_skip)
continue; 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; *idx_skip = idx - 1;
goto unlock; goto unlock;
} }
} }
*idx_skip = idx; *idx_skip = 0;
unlock: unlock:
rcu_read_unlock(); rcu_read_unlock();
return 0; return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment