batctl: Merge bugfixes from 2021.0

* Don't stop when create_interface detected existing interface

Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
Sven Eckelmann 2021-01-28 21:34:50 +01:00
parent 7448ab9d65
commit c116c97a21
2 changed files with 32 additions and 1 deletions

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=batctl PKG_NAME:=batctl
PKG_VERSION:=2018.1 PKG_VERSION:=2018.1
PKG_RELEASE:=4 PKG_RELEASE:=5
PKG_HASH:=27877d0da6916f88a6cecbbb3f3d23cc4558ef7c7294324bf4fd050ed606b553 PKG_HASH:=27877d0da6916f88a6cecbbb3f3d23cc4558ef7c7294324bf4fd050ed606b553
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View file

@ -0,0 +1,31 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 15 Jan 2021 23:38:31 +0100
Subject: batctl: Don't stop when create_interface detected existing interface
"batctl meshif bat0 interface add ..." should never be called in parallel.
But when something still does this, it could be that the code first detects
the missing meshif and then tries to create it - which fails when another
process requested the creation of the same interface slightly before batctl
did it.
But this should not prevent batctl to add the lower interface to the
meshif. It is not really important that the batctl process was the one
which created it - only that it exists is important.
Fixes: 25022e0b154d ("batctl: Use rtnl to add/remove interfaces")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/5d465bfd9a19c4bda20fb4e36c6e4b22c56ceb17
diff --git a/interface.c b/interface.c
index 1ad36826fdb91a3e0254ed4dec758e7c383596e9..ac95641953f76d77ef91bf77bb7a086a673c1dd2 100644
--- a/interface.c
+++ b/interface.c
@@ -398,7 +398,7 @@ int interface(char *mesh_iface, int argc, char **argv)
ifmaster = if_nametoindex(mesh_iface);
if (!manual_mode && !ifmaster && rest_argv[0][0] == 'a') {
ret = create_interface(mesh_iface);
- if (ret < 0) {
+ if (ret < 0 && ret != -EEXIST) {
fprintf(stderr,
"Error - failed to create batman-adv interface: %s\n",
strerror(-ret));