From e100856a6988c35f60487663c3c28d149965eb0b Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 2 Jun 2019 11:36:12 +0200 Subject: [PATCH] batman-adv: Fix duplicated OGMs on NETDEV_UP MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The state of slave interfaces are handled differently depending on whether the interface is up or not. All active interfaces (IFF_UP) will transmit OGMs. But for B.A.T.M.A.N. IV, also non-active interfaces are scheduling (low TTL) OGMs on active interfaces. The code which setups and schedules the OGMs must therefore already be called when the interfaces gets added as slave interface and the transmit function must then check whether it has to send out the OGM or not on the specific slave interface. But v2016.3 moved the setup code from the enable function to the activate function. The latter is called either when the added slave was already up when batadv_hardif_enable_interface processed the new interface or when a NETDEV_UP event was received for this slave interfac. As result, each NETDEV_UP would schedule a new OGM worker for the interface and thus OGMs would be send a lot more than expected. Fixes: 549909f89dd7 ("batman-adv: upgrade package to latest release 2016.3") Reported-by: Linus Lüssing Signed-off-by: Sven Eckelmann --- batman-adv/Makefile | 2 +- ...adv-Fix-duplicated-OGMs-on-NETDEV_UP.patch | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 batman-adv/patches/0066-batman-adv-Fix-duplicated-OGMs-on-NETDEV_UP.patch diff --git a/batman-adv/Makefile b/batman-adv/Makefile index 6a27271..914d80b 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv PKG_VERSION:=2016.5 -PKG_RELEASE:=14 +PKG_RELEASE:=15 PKG_MD5SUM:=6717a933a08dd2a01b00df30cb9f16a8 PKG_HASH:=d0a0fc90c4f410b57d043215e253bb0b855efa5edbe165d87c17bfdcfafd0db7 diff --git a/batman-adv/patches/0066-batman-adv-Fix-duplicated-OGMs-on-NETDEV_UP.patch b/batman-adv/patches/0066-batman-adv-Fix-duplicated-OGMs-on-NETDEV_UP.patch new file mode 100644 index 0000000..debdc22 --- /dev/null +++ b/batman-adv/patches/0066-batman-adv-Fix-duplicated-OGMs-on-NETDEV_UP.patch @@ -0,0 +1,83 @@ +From: Sven Eckelmann +Date: Sun, 2 Jun 2019 10:57:31 +0200 +Subject: batman-adv: Fix duplicated OGMs on NETDEV_UP + +The state of slave interfaces are handled differently depending on whether +the interface is up or not. All active interfaces (IFF_UP) will transmit +OGMs. But for B.A.T.M.A.N. IV, also non-active interfaces are scheduling +(low TTL) OGMs on active interfaces. The code which setups and schedules +the OGMs must therefore already be called when the interfaces gets added as +slave interface and the transmit function must then check whether it has to +send out the OGM or not on the specific slave interface. + +But the commit 0d8468553c3c ("batman-adv: remove ogm_emit and ogm_schedule +API calls") moved the setup code from the enable function to the activate +function. The latter is called either when the added slave was already up +when batadv_hardif_enable_interface processed the new interface or when a +NETDEV_UP event was received for this slave interfac. As result, each +NETDEV_UP would schedule a new OGM worker for the interface and thus OGMs +would be send a lot more than expected. + +Fixes: 0d8468553c3c ("batman-adv: remove ogm_emit and ogm_schedule API calls") +Reported-by: Linus Lüssing +Signed-off-by: Sven Eckelmann + +Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/c92331e0df3c0c5645ee5a897eb018c5da5e4aa5 + +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c +index f0174a17b30d14e5c127106b364b8fbc8ec384ee..73ea771287fd8babc6c8858643e84c1d9cba3691 100644 +--- a/net/batman-adv/bat_iv_ogm.c ++++ b/net/batman-adv/bat_iv_ogm.c +@@ -2475,7 +2475,7 @@ batadv_iv_ogm_neigh_is_sob(struct batadv_neigh_node *neigh1, + return ret; + } + +-static void batadv_iv_iface_activate(struct batadv_hard_iface *hard_iface) ++static void batadv_iv_iface_enabled(struct batadv_hard_iface *hard_iface) + { + /* begin scheduling originator messages on that interface */ + batadv_iv_ogm_schedule(hard_iface); +@@ -2815,8 +2815,8 @@ unlock: + static struct batadv_algo_ops batadv_batman_iv __read_mostly = { + .name = "BATMAN_IV", + .iface = { +- .activate = batadv_iv_iface_activate, + .enable = batadv_iv_ogm_iface_enable, ++ .enabled = batadv_iv_iface_enabled, + .disable = batadv_iv_ogm_iface_disable, + .update_mac = batadv_iv_ogm_iface_update_mac, + .primary_set = batadv_iv_ogm_primary_iface_set, +diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c +index c9a3b7bc07bcc443281c4f12c750c4d925c3b2c3..6d96ecd14fb0881e3384850bc34063b999fe5c93 100644 +--- a/net/batman-adv/hard-interface.c ++++ b/net/batman-adv/hard-interface.c +@@ -799,6 +799,9 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, + + batadv_hardif_recalc_extra_skbroom(soft_iface); + ++ if (bat_priv->algo_ops->iface.enabled) ++ bat_priv->algo_ops->iface.enabled(hard_iface); ++ + out: + return 0; + +diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h +index 1d8ee2bdbe01067ae4dbb9441cebeaa20735cdf9..5c5762f0f89c8b79b52288104d975dc3753bbf82 100644 +--- a/net/batman-adv/types.h ++++ b/net/batman-adv/types.h +@@ -1428,6 +1428,7 @@ struct batadv_forw_packet { + * @activate: start routing mechanisms when hard-interface is brought up + * (optional) + * @enable: init routing info when hard-interface is enabled ++ * @enabled: notification when hard-interface was enabled (optional) + * @disable: de-init routing info when hard-interface is disabled + * @update_mac: (re-)init mac addresses of the protocol information + * belonging to this hard-interface +@@ -1436,6 +1437,7 @@ struct batadv_forw_packet { + struct batadv_algo_iface_ops { + void (*activate)(struct batadv_hard_iface *hard_iface); + int (*enable)(struct batadv_hard_iface *hard_iface); ++ void (*enabled)(struct batadv_hard_iface *hard_iface); + void (*disable)(struct batadv_hard_iface *hard_iface); + void (*update_mac)(struct batadv_hard_iface *hard_iface); + void (*primary_set)(struct batadv_hard_iface *hard_iface); -- 2.30.2