From 0d22982f3067652e3e3d98bc5a8380ed409bc2fc Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Fri, 13 Dec 2019 22:11:22 +0100 Subject: [PATCH] batman-adv: Merge bugfixes from 2019.5 * fix DAT candidate selection on little endian systems Signed-off-by: Sven Eckelmann --- batman-adv/Makefile | 2 +- ...init-value-in-batadv_netlink_get_if.patch} | 0 ...ead-OGM-tvlv_len-after-buffer-len-c.patch} | 2 +- ...ead-OGM2-tvlv_len-after-buffer-len-.patch} | 0 ...free-alloc-race-when-handling-OGM2-.patch} | 4 +- ...free-alloc-race-when-handling-OGM-b.patch} | 4 +- ...adv-Introduce-own-OGM2-buffer-mutex.patch} | 4 +- ...OGM-workqueue-synchronous-cancel-de.patch} | 10 ++--- ...AT-candidate-selection-on-little-end.patch | 43 +++++++++++++++++++ 9 files changed, 56 insertions(+), 13 deletions(-) rename batman-adv/patches/{0010-batman-adv-fix-uninit-value-in-batadv_netlink_get_if.patch => 0033-batman-adv-fix-uninit-value-in-batadv_netlink_get_if.patch} (100%) rename batman-adv/patches/{0011-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch => 0034-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch} (96%) rename batman-adv/patches/{0012-batman-adv-Only-read-OGM2-tvlv_len-after-buffer-len-.patch => 0035-batman-adv-Only-read-OGM2-tvlv_len-after-buffer-len-.patch} (100%) rename batman-adv/patches/{0013-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch => 0036-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch} (96%) rename batman-adv/patches/{0014-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch => 0037-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch} (96%) rename batman-adv/patches/{0015-batman-adv-Introduce-own-OGM2-buffer-mutex.patch => 0038-batman-adv-Introduce-own-OGM2-buffer-mutex.patch} (96%) rename batman-adv/patches/{0016-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch => 0039-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch} (95%) create mode 100644 batman-adv/patches/0040-batman-adv-Fix-DAT-candidate-selection-on-little-end.patch diff --git a/batman-adv/Makefile b/batman-adv/Makefile index ae43490..20bcf0a 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv PKG_VERSION:=2018.1 -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_HASH:=b866b28dbbe5c9238abbdf5abbc30fc526dea56898ce4c1bd76d5c017843048b PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz diff --git a/batman-adv/patches/0010-batman-adv-fix-uninit-value-in-batadv_netlink_get_if.patch b/batman-adv/patches/0033-batman-adv-fix-uninit-value-in-batadv_netlink_get_if.patch similarity index 100% rename from batman-adv/patches/0010-batman-adv-fix-uninit-value-in-batadv_netlink_get_if.patch rename to batman-adv/patches/0033-batman-adv-fix-uninit-value-in-batadv_netlink_get_if.patch diff --git a/batman-adv/patches/0011-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch b/batman-adv/patches/0034-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch similarity index 96% rename from batman-adv/patches/0011-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch rename to batman-adv/patches/0034-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch index 6ba3239..a6fc524 100644 --- a/batman-adv/patches/0011-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch +++ b/batman-adv/patches/0034-batman-adv-Only-read-OGM-tvlv_len-after-buffer-len-c.patch @@ -22,7 +22,7 @@ Acked-by: Antonio Quartulli Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/07b6051ebcfaa7ea89b4f278eca2ff4070d29e56 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c -index 73bf6a93a3cf1141a34657bf1284893199e04db9..3db8a0278046c0a9f4d2604f0067ba4efe3ef588 100644 +index 0b7b36fa0d5cd440ddef141ad27acfe7b20aee43..36f244125d24c800d35249af7639d39a516588d4 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -463,17 +463,23 @@ static u8 batadv_hop_penalty(u8 tq, const struct batadv_priv *bat_priv) diff --git a/batman-adv/patches/0012-batman-adv-Only-read-OGM2-tvlv_len-after-buffer-len-.patch b/batman-adv/patches/0035-batman-adv-Only-read-OGM2-tvlv_len-after-buffer-len-.patch similarity index 100% rename from batman-adv/patches/0012-batman-adv-Only-read-OGM2-tvlv_len-after-buffer-len-.patch rename to batman-adv/patches/0035-batman-adv-Only-read-OGM2-tvlv_len-after-buffer-len-.patch diff --git a/batman-adv/patches/0013-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch b/batman-adv/patches/0036-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch similarity index 96% rename from batman-adv/patches/0013-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch rename to batman-adv/patches/0036-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch index ff4866f..b4afbf3 100644 --- a/batman-adv/patches/0013-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch +++ b/batman-adv/patches/0036-batman-adv-Avoid-free-alloc-race-when-handling-OGM2-.patch @@ -101,10 +101,10 @@ index d241ccc0ca0278173853512c8aa4bfb8b041f996..a9f949501ff3c354d38e3ad333901310 ogm_buff = kzalloc(bat_priv->bat_v.ogm_buff_len, GFP_ATOMIC); if (!ogm_buff) diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h -index 476b052ad9824d4cbcd6218dce40b603e3400fd2..8eaec92aff8919f0c6ca6b05be22e592b7ae0e1a 100644 +index 86f37db7dd01592aff95ada5ba5441667971e1bc..3392198ff146ba77d320104663e97ab21559d556 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h -@@ -1474,10 +1474,10 @@ struct batadv_softif_vlan { +@@ -1479,10 +1479,10 @@ struct batadv_softif_vlan { * struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data */ struct batadv_priv_bat_v { diff --git a/batman-adv/patches/0014-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch b/batman-adv/patches/0037-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch similarity index 96% rename from batman-adv/patches/0014-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch rename to batman-adv/patches/0037-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch index d07d693..67f635c 100644 --- a/batman-adv/patches/0014-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch +++ b/batman-adv/patches/0037-batman-adv-Avoid-free-alloc-race-when-handling-OGM-b.patch @@ -21,7 +21,7 @@ Signed-off-by: Sven Eckelmann Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9b8ceef26c697d0c8319748428944c3339a498dc diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c -index 3db8a0278046c0a9f4d2604f0067ba4efe3ef588..cb27949f4086643ebd018a0a01ab0b848ce5123f 100644 +index 36f244125d24c800d35249af7639d39a516588d4..5b2ef12cfabb24ccbe2c1848cfff4d1ded9bd0b0 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -42,6 +42,7 @@ @@ -118,7 +118,7 @@ index 3db8a0278046c0a9f4d2604f0067ba4efe3ef588..cb27949f4086643ebd018a0a01ab0b84 struct batadv_hard_iface *if_incoming) { diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h -index 8eaec92aff8919f0c6ca6b05be22e592b7ae0e1a..d43f1ec4532d1fda1d50061e581f4770a6037739 100644 +index 3392198ff146ba77d320104663e97ab21559d556..49e4e6cb506f192e85e96e8b3e68be3fdc2dca57 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -82,10 +82,10 @@ enum batadv_dhcp_recipient { diff --git a/batman-adv/patches/0015-batman-adv-Introduce-own-OGM2-buffer-mutex.patch b/batman-adv/patches/0038-batman-adv-Introduce-own-OGM2-buffer-mutex.patch similarity index 96% rename from batman-adv/patches/0015-batman-adv-Introduce-own-OGM2-buffer-mutex.patch rename to batman-adv/patches/0038-batman-adv-Introduce-own-OGM2-buffer-mutex.patch index afe1853..0a0d32e 100644 --- a/batman-adv/patches/0015-batman-adv-Introduce-own-OGM2-buffer-mutex.patch +++ b/batman-adv/patches/0038-batman-adv-Introduce-own-OGM2-buffer-mutex.patch @@ -104,7 +104,7 @@ index a9f949501ff3c354d38e3ad333901310391f27d8..bf9ea404abe7cbe1dd2113881856cd35 + mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex); } diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h -index d43f1ec4532d1fda1d50061e581f4770a6037739..05542a32f8c9c00b9d0cd7dbbab60cb773724613 100644 +index 49e4e6cb506f192e85e96e8b3e68be3fdc2dca57..44c423447fe163eb3b9df5ec5cf229bed6b8d65b 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -28,6 +28,7 @@ @@ -115,7 +115,7 @@ index d43f1ec4532d1fda1d50061e581f4770a6037739..05542a32f8c9c00b9d0cd7dbbab60cb7 #include #include #include /* for linux/wait.h */ -@@ -1474,15 +1475,18 @@ struct batadv_softif_vlan { +@@ -1479,15 +1480,18 @@ struct batadv_softif_vlan { * struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data */ struct batadv_priv_bat_v { diff --git a/batman-adv/patches/0016-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch b/batman-adv/patches/0039-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch similarity index 95% rename from batman-adv/patches/0016-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch rename to batman-adv/patches/0039-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch index 9dc85a7..1b0a1de 100644 --- a/batman-adv/patches/0016-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch +++ b/batman-adv/patches/0039-batman-adv-Avoid-OGM-workqueue-synchronous-cancel-de.patch @@ -25,7 +25,7 @@ Signed-off-by: Sven Eckelmann Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d3be478f1aa27b47f61c4a62e18eb063d47c9168 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c -index cb27949f4086643ebd018a0a01ab0b848ce5123f..b87bf2e511e0cd702a94594b8ddfe107ee17cef2 100644 +index 5b2ef12cfabb24ccbe2c1848cfff4d1ded9bd0b0..f5941837c3ad463f276cffdb25f9b6cd87af0e92 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -35,6 +35,7 @@ @@ -217,10 +217,10 @@ index cb27949f4086643ebd018a0a01ab0b848ce5123f..b87bf2e511e0cd702a94594b8ddfe107 struct batadv_hard_iface *if_incoming) { diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c -index 2f0d42f2f913e74cf10c0c6ce89320434994cac5..48123e9e3a6d221a9033bc2949e19a306e973546 100644 +index 36f0962040d16af4f9ed82629ff03ce85c83ed57..c4e0435c952db87c89727633c184320820812cda 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c -@@ -30,6 +30,7 @@ +@@ -29,6 +29,7 @@ #include #include #include @@ -228,7 +228,7 @@ index 2f0d42f2f913e74cf10c0c6ce89320434994cac5..48123e9e3a6d221a9033bc2949e19a30 #include #include #include -@@ -929,6 +930,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) +@@ -933,6 +934,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) INIT_LIST_HEAD(&hard_iface->list); INIT_HLIST_HEAD(&hard_iface->neigh_list); @@ -237,7 +237,7 @@ index 2f0d42f2f913e74cf10c0c6ce89320434994cac5..48123e9e3a6d221a9033bc2949e19a30 kref_init(&hard_iface->refcount); diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h -index 05542a32f8c9c00b9d0cd7dbbab60cb773724613..c843a69677d1e0eefaf6a1432541052b7cd2965a 100644 +index 44c423447fe163eb3b9df5ec5cf229bed6b8d65b..85f52dc42e17f7ed550f13048a2e2bd9d372196b 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -83,14 +83,17 @@ enum batadv_dhcp_recipient { diff --git a/batman-adv/patches/0040-batman-adv-Fix-DAT-candidate-selection-on-little-end.patch b/batman-adv/patches/0040-batman-adv-Fix-DAT-candidate-selection-on-little-end.patch new file mode 100644 index 0000000..05b0636 --- /dev/null +++ b/batman-adv/patches/0040-batman-adv-Fix-DAT-candidate-selection-on-little-end.patch @@ -0,0 +1,43 @@ +From: Sven Eckelmann +Date: Thu, 28 Nov 2019 12:43:49 +0100 +Subject: batman-adv: Fix DAT candidate selection on little endian systems + +The distributed arp table is using a DHT to store and retrieve MAC address +information for an IP address. This is done using unicast messages to +selected peers. The potential peers are looked up using the IP address and +the VID. + +While the IP address is always stored in big endian byte order, it is not +the case of the VID. It can (depending on the host system) either be big +endian or little endian. The host must therefore always convert it to big +endian to ensure that all devices calculate the same peers for the same +lookup data. + +Fixes: 3e26722bc9f2 ("batman-adv: make the Distributed ARP Table vlan aware") +Signed-off-by: Sven Eckelmann +Acked-by: Antonio Quartulli + +Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/728aea06f38e0e4d70f4f7d43698187f7f7055c5 + +diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c +index a60bacf7120be88ba7626cf0a87dd34eef0a2eec..21783805a3afd974cebc7e640249402d637d731a 100644 +--- a/net/batman-adv/distributed-arp-table.c ++++ b/net/batman-adv/distributed-arp-table.c +@@ -251,6 +251,7 @@ static u32 batadv_hash_dat(const void *data, u32 size) + u32 hash = 0; + const struct batadv_dat_entry *dat = data; + const unsigned char *key; ++ __be16 vid; + u32 i; + + key = (const unsigned char *)&dat->ip; +@@ -260,7 +261,8 @@ static u32 batadv_hash_dat(const void *data, u32 size) + hash ^= (hash >> 6); + } + +- key = (const unsigned char *)&dat->vid; ++ vid = htons(dat->vid); ++ key = (__force const unsigned char *)&vid; + for (i = 0; i < sizeof(dat->vid); i++) { + hash += key[i]; + hash += (hash << 10); -- 2.30.2