batman-adv: Request iflink once in batadv-on-batadv check
authorSven Eckelmann <sven@narfation.org>
Sun, 27 Feb 2022 23:01:24 +0000 (00:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Mar 2022 18:07:47 +0000 (19:07 +0100)
commita1ccea6183eb7468dea4726d9b716b62f70e77d8
tree09909627c612fdca9bba0e98c02e23980932189d
parent43c25da41e3091b31a906651a43e80a2719aa1ff
batman-adv: Request iflink once in batadv-on-batadv check

commit 690bb6fb64f5dc7437317153902573ecad67593d upstream.

There is no need to call dev_get_iflink multiple times for the same
net_device in batadv_is_on_batman_iface. And since some of the
.ndo_get_iflink callbacks are dynamic (for example via RCUs like in
vxcan_get_iflink), it could easily happen that the returned values are not
stable. The pre-checks before __dev_get_by_index are then of course bogus.

Fixes: b7eddd0b3950 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/batman-adv/hard-interface.c