From 017d89d569bf5a330deb4ddac1376d4dbe1dacda Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 21 Jul 2020 22:29:33 +0200 Subject: [PATCH 1/2] batctl: Enable build of mcast_flags subcommand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mcast_flags subcommand allows to query the mcast_flags of the current device and of the seen originators. It should be enabled for the default and full variants. But the configuration string wasn't correctly included in the list when the variants were prepared and thus disabled in all variants. Reported-by: Linus Lüssing Fixes: 129986825219 ("batctl: Provide different variants") Signed-off-by: Sven Eckelmann --- batctl/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batctl/Makefile b/batctl/Makefile index fcf05db..2772b1c 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batctl PKG_VERSION:=2019.2 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_HASH:=fb656208ff7d4cd8b1b422f60c9e6d8747302a347cbf6c199d7afa9b80f80ea3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz @@ -167,7 +167,7 @@ config-tables := \ claimtable \ dat_cache \ gateways \ - loglevel \ + mcast_flags \ nc_nodes \ neighbors \ originators \ From 6dea537c076e74da3455bf04f585fdd008c98a57 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 25 Aug 2020 20:36:05 +0200 Subject: [PATCH 2/2] batman-adv: Merge bugfixes from 2020.3 * Avoid uninitialized chaddr when handling DHCP * Fix own OGM check in aggregated OGMs * bla: use netif_rx_ni when not in interrupt context Signed-off-by: Sven Eckelmann --- batman-adv/Makefile | 2 +- ...-uninitialized-chaddr-when-handling-.patch | 42 +++++++++++++ ...Fix-own-OGM-check-in-aggregated-OGMs.patch | 59 +++++++++++++++++++ ...se-netif_rx_ni-when-not-in-interrupt.patch | 31 ++++++++++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 batman-adv/patches/0021-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch create mode 100644 batman-adv/patches/0022-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch create mode 100644 batman-adv/patches/0023-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch diff --git a/batman-adv/Makefile b/batman-adv/Makefile index 828fbde..e76cda8 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv PKG_VERSION:=2019.2 -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_HASH:=70c3f6a6cf88d2b25681a76768a52ed92d9fe992ba8e358368b6a8088757adc8 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz diff --git a/batman-adv/patches/0021-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch b/batman-adv/patches/0021-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch new file mode 100644 index 0000000..1b36259 --- /dev/null +++ b/batman-adv/patches/0021-batman-adv-Avoid-uninitialized-chaddr-when-handling-.patch @@ -0,0 +1,42 @@ +From: Sven Eckelmann +Date: Wed, 22 Jul 2020 20:49:23 +0200 +Subject: batman-adv: Avoid uninitialized chaddr when handling DHCP + +The gateway client code can try to optimize the delivery of DHCP packets to +avoid broadcasting them through the whole mesh. But also transmissions to +the client can be optimized by looking up the destination via the chaddr of +the DHCP packet. + +But the chaddr is currently only done when chaddr is fully inside the +non-paged area of the skbuff. Otherwise it will not be initialized and the +unoptimized path should have been taken. + +But the implementation didn't handle this correctly. It didn't retrieve the +correct chaddr but still tried to perform the TT lookup with this +uninitialized memory. + +Reported-by: syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com +Fixes: 2d5b555644b2 ("batman-adv: send every DHCP packet as bat-unicast") +Signed-off-by: Sven Eckelmann +Acked-by: Antonio Quartulli +Signed-off-by: Sven Eckelmann + +Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/fcdf008ffd749246632d1f9423163af5dc3f8c7f + +diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c +index 47df4c678988613f7410acb96889558eabdf396d..89c9097007c3a575836018df9e0fe97731a19619 100644 +--- a/net/batman-adv/gateway_client.c ++++ b/net/batman-adv/gateway_client.c +@@ -703,8 +703,10 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, + + chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET; + /* store the client address if the message is going to a client */ +- if (ret == BATADV_DHCP_TO_CLIENT && +- pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) { ++ if (ret == BATADV_DHCP_TO_CLIENT) { ++ if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) ++ return BATADV_DHCP_NO; ++ + /* check if the DHCP packet carries an Ethernet DHCP */ + p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET; + if (*p != BATADV_DHCP_HTYPE_ETHERNET) diff --git a/batman-adv/patches/0022-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch b/batman-adv/patches/0022-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch new file mode 100644 index 0000000..e1db268 --- /dev/null +++ b/batman-adv/patches/0022-batman-adv-Fix-own-OGM-check-in-aggregated-OGMs.patch @@ -0,0 +1,59 @@ +From: Linus Lüssing +Date: Fri, 31 Jul 2020 00:22:55 +0200 +Subject: batman-adv: Fix own OGM check in aggregated OGMs + +The own OGM check is currently misplaced and can lead to the following +issues: + +For one thing we might receive an aggregated OGM from a neighbor node +which has our own OGM in the first place. We would then not only skip +our own OGM but erroneously also any other, following OGM in the +aggregate. + +For another, we might receive an OGM aggregate which has our own OGM in +a place other then the first one. Then we would wrongly not skip this +OGM, leading to populating the orginator and gateway table with ourself. + +The latter seems to not only be a cosmetic issue, but there were reports +that this causes issues with various subsystems of batman-adv, too. For +instance there were reports about issues with DAT and either disabling +DAT or aggregation seemed to solve it. + +Fixing these issues by applying the own OGM check not on the first OGM +in an aggregate but for each OGM in an aggregate instead. + +Fixes: 667996ebeab ("batman-adv: OGMv2 - implement originators logic") +Signed-off-by: Linus Lüssing +Signed-off-by: Sven Eckelmann + +Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d41cc7cb62c184b2fb8ab97fda45815918200001 + +diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c +index 9c42152829c976a2fb6c4395ab4d17c34fe47682..330204a73a0d3d9e4083656b82ff7b9d73a48fdc 100644 +--- a/net/batman-adv/bat_v_ogm.c ++++ b/net/batman-adv/bat_v_ogm.c +@@ -704,6 +704,12 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset, + ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl, + ogm_packet->version, ntohs(ogm_packet->tvlv_len)); + ++ if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) { ++ batadv_dbg(BATADV_DBG_BATMAN, bat_priv, ++ "Drop packet: originator packet from ourself\n"); ++ return; ++ } ++ + /* If the throughput metric is 0, immediately drop the packet. No need + * to create orig_node / neigh_node for an unusable route. + */ +@@ -831,11 +837,6 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, + if (batadv_is_my_mac(bat_priv, ethhdr->h_source)) + goto free_skb; + +- ogm_packet = (struct batadv_ogm2_packet *)skb->data; +- +- if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) +- goto free_skb; +- + batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); + batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES, + skb->len + ETH_HLEN); diff --git a/batman-adv/patches/0023-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch b/batman-adv/patches/0023-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch new file mode 100644 index 0000000..53baee8 --- /dev/null +++ b/batman-adv/patches/0023-batman-adv-bla-use-netif_rx_ni-when-not-in-interrupt.patch @@ -0,0 +1,31 @@ +From: Jussi Kivilinna +Date: Tue, 18 Aug 2020 17:46:10 +0300 +Subject: batman-adv: bla: use netif_rx_ni when not in interrupt context + +batadv_bla_send_claim() gets called from worker thread context through +batadv_bla_periodic_work(), thus netif_rx_ni needs to be used in that +case. This fixes "NOHZ: local_softirq_pending 08" log messages seen +when batman-adv is enabled. + +Fixes: a9ce0dc43e2c ("batman-adv: add basic bridge loop avoidance code") +Signed-off-by: Jussi Kivilinna +Signed-off-by: Sven Eckelmann + +Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/3747f81a1380b65740fc52fc71c7a3af4c6e49de + +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c +index 663a53b6d36e65508b4296d86cecdd808c653836..5f6309ade1ea19f6a0bd27e8cbc5fcfba8f7dda5 100644 +--- a/net/batman-adv/bridge_loop_avoidance.c ++++ b/net/batman-adv/bridge_loop_avoidance.c +@@ -437,7 +437,10 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac, + batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, + skb->len + ETH_HLEN); + +- netif_rx(skb); ++ if (in_interrupt()) ++ netif_rx(skb); ++ else ++ netif_rx_ni(skb); + out: + if (primary_if) + batadv_hardif_put(primary_if);