From f5b3c0c3bc7e795b4b544cbaa49e9c6ca7581ce9 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 3 Jun 2018 18:37:03 +0200 Subject: [PATCH] batman-adv: Add maint patches between v2017.2 and 2018.1-maint 2018-06-03 Gluon 2017.1.x decided to use a batman-adv version (v2017.2 + maint patches from 2017.3) which was not part of the openwrt-routing branch lede-17.01. All the fixes which were added in the meantime to this branch must therefore be ported manually to the gluon fork. v2017.4 ======= * Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq * Fix check of retrieved orig_gw in batadv_v_gw_is_eligible * Always initialize fragment header priority * Avoid spurious warnings from bat_v neigh_cmp implementation v2018.0 ======= * fix packet checksum in receive path * invalidate checksum on fragment reassembly * Ignore invalid batadv_iv_gw during netlink send * Ignore invalid batadv_v_gw during netlink send * Fix netlink dumping of BLA claims * Fix netlink dumping of BLA backbones * Fix internal interface indices types v2018.1 ======= * Fix skbuff rcsum on packet reroute * update data pointers after skb_cow() * fix header size check in batadv_dbg_arp() * Fix multicast packet loss with a single WANT_ALL_IPV4/6 flag * fix multicast-via-unicast transmission with AP isolation * fix packet loss for broadcasted DHCP packets to a server v2018.1-maint 2018-06-03 ======================== * Avoid race in TT TVLV allocator helper * Fix TT sync flags for intermediate TT responses * prevent TT request storms by not sending inconsistent TT TLVLs * Fix bat_ogm_iv best gw refcnt after netlink dump * Fix bat_v best gw refcnt after netlink dump * Fix debugfs path for renamed hardif * Fix debugfs path for renamed softif Signed-off-by: Sven Eckelmann --- ...ix-best-gw-refcnt-after-netlink-dump.patch | 119 --- ...atman-adv-Merge-bugfixes-from-2017.4.patch | 209 +++++ ...atman-adv-Merge-bugfixes-from-2018.0.patch | 584 +++++++++++++ ...atman-adv-Merge-bugfixes-from-2018.1.patch | 456 ++++++++++ ...ugfixes-from-2018.1-maint-2018-06-03.patch | 779 ++++++++++++++++++ 5 files changed, 2028 insertions(+), 119 deletions(-) delete mode 100644 patches/packages/routing/0002-batman-adv-Fix-best-gw-refcnt-after-netlink-dump.patch create mode 100644 patches/packages/routing/0002-batman-adv-Merge-bugfixes-from-2017.4.patch create mode 100644 patches/packages/routing/0003-batman-adv-Merge-bugfixes-from-2018.0.patch create mode 100644 patches/packages/routing/0004-batman-adv-Merge-bugfixes-from-2018.1.patch create mode 100644 patches/packages/routing/0005-batman-adv-Merge-bugfixes-from-2018.1-maint-2018-06-03.patch diff --git a/patches/packages/routing/0002-batman-adv-Fix-best-gw-refcnt-after-netlink-dump.patch b/patches/packages/routing/0002-batman-adv-Fix-best-gw-refcnt-after-netlink-dump.patch deleted file mode 100644 index 6a56631c..00000000 --- a/patches/packages/routing/0002-batman-adv-Fix-best-gw-refcnt-after-netlink-dump.patch +++ /dev/null @@ -1,119 +0,0 @@ -From: Sven Eckelmann -Date: Sat, 2 Jun 2018 16:25:16 +0200 -Subject: batman-adv: Fix best gw refcnt after netlink dump - -A reference to the best gateway is taken when the list of gateways in the -mesh is sent via netlink. This is necessary to check whether the currently -dumped entry is the currently selected gateway or not. This information is -then transferred as flag BATADV_ATTR_FLAG_BEST. - -After the comparison of the current entry is done, -batadv_*_gw_dump_entry() has to decrease the reference counter again. -Otherwise the reference will be held and thus prevents a proper shutdown of -the batman-adv interfaces (and some of the interfaces enslaved in it). - -Fixes: 215d6b834fd1 ("batman-adv: upgrade package to latest release 2016.4") -Reported-by: Andreas Ziegler -Signed-off-by: Sven Eckelmann - -diff --git a/batman-adv/patches/0002-batman-adv-Fix-bat_ogm_iv-best-gw-refcnt-after-netli.patch b/batman-adv/patches/0002-batman-adv-Fix-bat_ogm_iv-best-gw-refcnt-after-netli.patch -new file mode 100644 -index 0000000000000000000000000000000000000000..cd384e847ff14beda3051e67d5c93762dd786ddd ---- /dev/null -+++ b/batman-adv/patches/0002-batman-adv-Fix-bat_ogm_iv-best-gw-refcnt-after-netli.patch -@@ -0,0 +1,45 @@ -+From: Sven Eckelmann -+Date: Sat, 2 Jun 2018 16:08:22 +0200 -+Subject: [PATCH] batman-adv: Fix bat_ogm_iv best gw refcnt after netlink dump -+ -+A reference to the best gateway is taken when the list of gateways in the -+mesh is sent via netlink. This is necessary to check whether the currently -+dumped entry is the currently selected gateway or not. This information is -+then transferred as flag BATADV_ATTR_FLAG_BEST. -+ -+After the comparison of the current entry is done, -+batadv_iv_gw_dump_entry() has to decrease the reference counter again. -+Otherwise the reference will be held and thus prevents a proper shutdown of -+the batman-adv interfaces (and some of the interfaces enslaved in it). -+ -+Fixes: fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations") -+Reported-by: Andreas Ziegler -+Signed-off-by: Sven Eckelmann -+--- -+ net/batman-adv/bat_iv_ogm.c | 6 ++++-- -+ 1 file changed, 4 insertions(+), 2 deletions(-) -+ -+diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c -+index 8769fa1b17c8486e68041ee15fae08178b75567f..d8f2ca7a0122ba906d5df3e042c969e0ed2dd5ea 100644 -+--- a/net/batman-adv/bat_iv_ogm.c -++++ b/net/batman-adv/bat_iv_ogm.c -+@@ -2718,8 +2718,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, -+ { -+ struct batadv_neigh_ifinfo *router_ifinfo = NULL; -+ struct batadv_neigh_node *router; -+- struct batadv_gw_node *curr_gw; -+- int ret = -EINVAL; -++ struct batadv_gw_node *curr_gw = NULL; -++ int ret = 0; -+ void *hdr; -+ -+ router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); -+@@ -2766,6 +2766,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, -+ ret = 0; -+ -+ out: -++ if (curr_gw) -++ batadv_gw_node_put(curr_gw); -+ if (router_ifinfo) -+ batadv_neigh_ifinfo_put(router_ifinfo); -+ if (router) -diff --git a/batman-adv/patches/0003-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch b/batman-adv/patches/0003-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch -new file mode 100644 -index 0000000000000000000000000000000000000000..0d0e08202af6410748f56662f2abc07175ece5a7 ---- /dev/null -+++ b/batman-adv/patches/0003-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch -@@ -0,0 +1,44 @@ -+From: Sven Eckelmann -+Date: Sat, 2 Jun 2018 16:08:22 +0200 -+Subject: [PATCH] batman-adv: Fix bat_v best gw refcnt after netlink dump -+ -+A reference to the best gateway is taken when the list of gateways in the -+mesh is sent via netlink. This is necessary to check whether the currently -+dumped entry is the currently selected gateway or not. This information is -+then transferred as flag BATADV_ATTR_FLAG_BEST. -+ -+After the comparison of the current entry is done, -+batadv_v_gw_dump_entry() has to decrease the reference counter again. -+Otherwise the reference will be held and thus prevents a proper shutdown of -+the batman-adv interfaces (and some of the interfaces enslaved in it). -+ -+Fixes: 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations") -+Signed-off-by: Sven Eckelmann -+--- -+ net/batman-adv/bat_v.c | 6 ++++-- -+ 1 file changed, 4 insertions(+), 2 deletions(-) -+ -+diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c -+index 4e2724c5b33d8bda27339ffe65fc7d76f91fd119..371a1f1651b48d58beef141f002eec7bf3cfe556 100644 -+--- a/net/batman-adv/bat_v.c -++++ b/net/batman-adv/bat_v.c -+@@ -929,8 +929,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, -+ { -+ struct batadv_neigh_ifinfo *router_ifinfo = NULL; -+ struct batadv_neigh_node *router; -+- struct batadv_gw_node *curr_gw; -+- int ret = -EINVAL; -++ struct batadv_gw_node *curr_gw = NULL; -++ int ret = 0; -+ void *hdr; -+ -+ router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); -+@@ -997,6 +997,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, -+ ret = 0; -+ -+ out: -++ if (curr_gw) -++ batadv_gw_node_put(curr_gw); -+ if (router_ifinfo) -+ batadv_neigh_ifinfo_put(router_ifinfo); -+ if (router) diff --git a/patches/packages/routing/0002-batman-adv-Merge-bugfixes-from-2017.4.patch b/patches/packages/routing/0002-batman-adv-Merge-bugfixes-from-2017.4.patch new file mode 100644 index 00000000..2c98ec61 --- /dev/null +++ b/patches/packages/routing/0002-batman-adv-Merge-bugfixes-from-2017.4.patch @@ -0,0 +1,209 @@ +From: Sven Eckelmann +Date: Tue, 26 Dec 2017 13:07:40 +0100 +Subject: batman-adv: Merge bugfixes from 2017.4 + +* Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq +* Fix check of retrieved orig_gw in batadv_v_gw_is_eligible +* Always initialize fragment header priority +* Avoid spurious warnings from bat_v neigh_cmp implementation + +Signed-off-by: Sven Eckelmann + +Origin: backport, https://github.com/openwrt-routing/packages/commit/285c803c0a39d05d9a5906ba844981a10647b088 + +diff --git a/batman-adv/Makefile b/batman-adv/Makefile +index d51bc65bbdc9d1511d4f0bbc9d3a8a13ebc34201..d3d68160662894887eb9fa43c78fdd7479764b7c 100644 +--- a/batman-adv/Makefile ++++ b/batman-adv/Makefile +@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk + PKG_NAME:=batman-adv + + PKG_VERSION:=2017.2 +-PKG_RELEASE:=1 ++PKG_RELEASE:=2 + PKG_MD5SUM:=937b5f1d0188e3522d67ad45ee0a4f5a + PKG_HASH:=d487974e21cb53d39f139e93a2cf297807df5b7bf63ba6d810bad6d91537394f + +diff --git a/batman-adv/patches/0002-batman-adv-Avoid-spurious-warnings-from-bat_v-neigh_.patch b/batman-adv/patches/0002-batman-adv-Avoid-spurious-warnings-from-bat_v-neigh_.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..3ccb9493ee82cb3ab8433d0d88b3871fad227061 +--- /dev/null ++++ b/batman-adv/patches/0002-batman-adv-Avoid-spurious-warnings-from-bat_v-neigh_.patch +@@ -0,0 +1,56 @@ ++From: Sven Eckelmann ++Date: Mon, 16 Oct 2017 09:48:03 +0200 ++Subject: [PATCH] batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation ++ ++The neighbor compare API implementation for B.A.T.M.A.N. V checks whether ++the neigh_ifinfo for this neighbor on a specific interface exists. A ++warning is printed when it isn't found. ++ ++But it is not called inside a lock which would prevent that this ++information is lost right before batadv_neigh_ifinfo_get. It must therefore ++be expected that batadv_v_neigh_(cmp|is_sob) might not be able to get the ++requested neigh_ifinfo. ++ ++A WARN_ON for such a situation seems not to be appropriate because this ++will only flood the kernel logs. The warnings must therefore be removed. ++ ++Signed-off-by: Sven Eckelmann ++Acked-by: Antonio Quartulli ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/0dee8aba4702f82197ed3428ede6b3884fdff5ca ++--- ++ net/batman-adv/bat_v.c | 8 ++++---- ++ 1 file changed, 4 insertions(+), 4 deletions(-) ++ ++diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c ++index 4e2724c5b33d8bda27339ffe65fc7d76f91fd119..1a46382a6008d5b6ba4f2c71aa07df761d544457 100644 ++--- a/net/batman-adv/bat_v.c +++++ b/net/batman-adv/bat_v.c ++@@ -623,11 +623,11 @@ static int batadv_v_neigh_cmp(struct batadv_neigh_node *neigh1, ++ int ret = 0; ++ ++ ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); ++- if (WARN_ON(!ifinfo1)) +++ if (!ifinfo1) ++ goto err_ifinfo1; ++ ++ ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); ++- if (WARN_ON(!ifinfo2)) +++ if (!ifinfo2) ++ goto err_ifinfo2; ++ ++ ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput; ++@@ -649,11 +649,11 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1, ++ bool ret = false; ++ ++ ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); ++- if (WARN_ON(!ifinfo1)) +++ if (!ifinfo1) ++ goto err_ifinfo1; ++ ++ ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); ++- if (WARN_ON(!ifinfo2)) +++ if (!ifinfo2) ++ goto err_ifinfo2; ++ ++ threshold = ifinfo1->bat_v.throughput / 4; +diff --git a/batman-adv/patches/0003-batman-adv-Always-initialize-fragment-header-priorit.patch b/batman-adv/patches/0003-batman-adv-Always-initialize-fragment-header-priorit.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..0d30dbc520ba73bd6cb86ecbba02d8a5a96f0745 +--- /dev/null ++++ b/batman-adv/patches/0003-batman-adv-Always-initialize-fragment-header-priorit.patch +@@ -0,0 +1,30 @@ ++From: Sven Eckelmann ++Date: Wed, 29 Nov 2017 10:25:02 +0100 ++Subject: [PATCH] batman-adv: Always initialize fragment header priority ++ ++The batman-adv unuicast fragment header contains 3 bits for the priority of ++the packet. These bits will be initialized when the skb->priority contains ++a value between 256 and 263. But otherwise, the uninitialized bits from the ++stack will be used. ++ ++Fixes: 4f241fcea704 ("batman-adv: Include frame priority in fragment header") ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/e45a75c82feae23a20d2744ccfde03780ccdafc7 ++--- ++ net/batman-adv/fragmentation.c | 2 ++ ++ 1 file changed, 2 insertions(+) ++ ++diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c ++index a98cf1104a30a30e66fb6018bef59dea83dc4b7a..ebe6e38934e46ed5de4d30204e791dbe40285fcc 100644 ++--- a/net/batman-adv/fragmentation.c +++++ b/net/batman-adv/fragmentation.c ++@@ -499,6 +499,8 @@ int batadv_frag_send_packet(struct sk_buff *skb, ++ */ ++ if (skb->priority >= 256 && skb->priority <= 263) ++ frag_header.priority = skb->priority - 256; +++ else +++ frag_header.priority = 0; ++ ++ ether_addr_copy(frag_header.orig, primary_if->net_dev->dev_addr); ++ ether_addr_copy(frag_header.dest, orig_node->orig); +diff --git a/batman-adv/patches/0004-batman-adv-Fix-check-of-retrieved-orig_gw-in-batadv_.patch b/batman-adv/patches/0004-batman-adv-Fix-check-of-retrieved-orig_gw-in-batadv_.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..05b0f91d039b634f80022367b85674e168de8056 +--- /dev/null ++++ b/batman-adv/patches/0004-batman-adv-Fix-check-of-retrieved-orig_gw-in-batadv_.patch +@@ -0,0 +1,31 @@ ++From: Sven Eckelmann ++Date: Wed, 29 Nov 2017 10:50:42 +0100 ++Subject: [PATCH] batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible ++ ++The batadv_v_gw_is_eligible function already assumes that orig_node is not ++NULL. But batadv_gw_node_get may have failed to find the originator. It ++must therefore be checked whether the batadv_gw_node_get failed and not ++whether orig_node is NULL to detect this error. ++ ++Fixes: 80b2d47be2c7 ("batman-adv: B.A.T.M.A.N. V - implement GW selection logic") ++Signed-off-by: Sven Eckelmann ++Acked-by: Antonio Quartulli ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/c7380677d6167f3798d3ea7a4f1a93663f3c7915 ++--- ++ net/batman-adv/bat_v.c | 2 +- ++ 1 file changed, 1 insertion(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c ++index 1a46382a6008d5b6ba4f2c71aa07df761d544457..cb227bcdc35c3a48b3fd85cd2749730bf857c704 100644 ++--- a/net/batman-adv/bat_v.c +++++ b/net/batman-adv/bat_v.c ++@@ -815,7 +815,7 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv, ++ } ++ ++ orig_gw = batadv_gw_node_get(bat_priv, orig_node); ++- if (!orig_node) +++ if (!orig_gw) ++ goto out; ++ ++ if (batadv_v_gw_throughput_get(orig_gw, &orig_throughput) < 0) +diff --git a/batman-adv/patches/0005-batman-adv-Fix-lock-for-ogm-cnt-access-in-batadv_iv_.patch b/batman-adv/patches/0005-batman-adv-Fix-lock-for-ogm-cnt-access-in-batadv_iv_.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..d4685faf23dd4e0fd4a7f46745f3f2f4ec82bffa +--- /dev/null ++++ b/batman-adv/patches/0005-batman-adv-Fix-lock-for-ogm-cnt-access-in-batadv_iv_.patch +@@ -0,0 +1,42 @@ ++From: Sven Eckelmann ++Date: Sun, 3 Dec 2017 11:26:45 +0100 ++Subject: [PATCH] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq ++ ++The originator node object orig_neigh_node is used to when accessing the ++bcast_own(_sum) and real_packet_count information. The access to them has ++to be protected with the spinlock in orig_neigh_node. ++ ++But the function uses the lock in orig_node instead. This is incorrect ++because they could be two different originator node objects. ++ ++Fixes: f14416760b62 ("batman-adv: protect bit operations to count OGMs with spinlock") ++Signed-off-by: Sven Eckelmann ++Signed-off-by: Simon Wunderlich ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9a3b195410e5d2f285cdf0073fef721ff8d9474d ++--- ++ net/batman-adv/bat_iv_ogm.c | 4 ++-- ++ 1 file changed, 2 insertions(+), 2 deletions(-) ++ ++diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c ++index 8769fa1b17c8486e68041ee15fae08178b75567f..0f9749c780056df271c1b1167299de75dbdbd770 100644 ++--- a/net/batman-adv/bat_iv_ogm.c +++++ b/net/batman-adv/bat_iv_ogm.c ++@@ -1214,7 +1214,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ++ orig_node->last_seen = jiffies; ++ ++ /* find packet count of corresponding one hop neighbor */ ++- spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock); +++ spin_lock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock); ++ if_num = if_incoming->if_num; ++ orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num]; ++ neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing); ++@@ -1224,7 +1224,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ++ } else { ++ neigh_rq_count = 0; ++ } ++- spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock); +++ spin_unlock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock); ++ ++ /* pay attention to not get a value bigger than 100 % */ ++ if (orig_eq_count > neigh_rq_count) diff --git a/patches/packages/routing/0003-batman-adv-Merge-bugfixes-from-2018.0.patch b/patches/packages/routing/0003-batman-adv-Merge-bugfixes-from-2018.0.patch new file mode 100644 index 00000000..621186e0 --- /dev/null +++ b/patches/packages/routing/0003-batman-adv-Merge-bugfixes-from-2018.0.patch @@ -0,0 +1,584 @@ +From: Sven Eckelmann +Date: Tue, 27 Feb 2018 18:21:45 +0100 +Subject: batman-adv: Merge bugfixes from 2018.0 + +* fix packet checksum in receive path +* invalidate checksum on fragment reassembly +* Ignore invalid batadv_iv_gw during netlink send +* Ignore invalid batadv_v_gw during netlink send +* Fix netlink dumping of BLA claims +* Fix netlink dumping of BLA backbones +* Fix internal interface indices types + +Signed-off-by: Sven Eckelmann + +Origin: backport, https://github.com/openwrt-routing/packages/commit/08935dfaa0844d3b544a1c7d0bb83260be07302e + +diff --git a/batman-adv/Makefile b/batman-adv/Makefile +index d3d68160662894887eb9fa43c78fdd7479764b7c..3765c0273e7fc3923a6234514e0478f80277d2e5 100644 +--- a/batman-adv/Makefile ++++ b/batman-adv/Makefile +@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk + PKG_NAME:=batman-adv + + PKG_VERSION:=2017.2 +-PKG_RELEASE:=2 ++PKG_RELEASE:=3 + PKG_MD5SUM:=937b5f1d0188e3522d67ad45ee0a4f5a + PKG_HASH:=d487974e21cb53d39f139e93a2cf297807df5b7bf63ba6d810bad6d91537394f + +diff --git a/batman-adv/patches/0006-batman-adv-fix-packet-checksum-in-receive-path.patch b/batman-adv/patches/0006-batman-adv-fix-packet-checksum-in-receive-path.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..d37c7bb82eac3b790dccb72fb9233be2298b2aeb +--- /dev/null ++++ b/batman-adv/patches/0006-batman-adv-fix-packet-checksum-in-receive-path.patch +@@ -0,0 +1,43 @@ ++From: Matthias Schiffer ++Date: Tue, 23 Jan 2018 10:59:49 +0100 ++Subject: [PATCH] batman-adv: fix packet checksum in receive path ++ ++eth_type_trans() internally calls skb_pull(), which does not adjust the ++skb checksum; skb_postpull_rcsum() is necessary to avoid log spam of the ++form "bat0: hw csum failure" when packets with CHECKSUM_COMPLETE are ++received. ++ ++Note that in usual setups, packets don't reach batman-adv with ++CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see ++batadv's ethtype?), which is why the log messages do not occur on every ++system using batman-adv. I could reproduce this issue by stacking ++batman-adv on top of a VXLAN interface. ++ ++Fixes: fe28a94c01e1 ("batman-adv: receive packets directly using skbs") ++Signed-off-by: Matthias Schiffer ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/798174b15153afd88268f2f87811602f68b3f2c6 ++--- ++ net/batman-adv/soft-interface.c | 8 +------- ++ 1 file changed, 1 insertion(+), 7 deletions(-) ++ ++diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c ++index 10f7edfb176ebd49c680ff4132db87aa00d3f04e..aa2c49fa31cec5ffd234204844a6874f0149a9ae 100644 ++--- a/net/batman-adv/soft-interface.c +++++ b/net/batman-adv/soft-interface.c ++@@ -451,13 +451,7 @@ void batadv_interface_rx(struct net_device *soft_iface, ++ ++ /* skb->dev & skb->pkt_type are set here */ ++ skb->protocol = eth_type_trans(skb, soft_iface); ++- ++- /* should not be necessary anymore as we use skb_pull_rcsum() ++- * TODO: please verify this and remove this TODO ++- * -- Dec 21st 2009, Simon Wunderlich ++- */ ++- ++- /* skb->ip_summed = CHECKSUM_UNNECESSARY; */ +++ skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); ++ ++ batadv_inc_counter(bat_priv, BATADV_CNT_RX); ++ batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, +diff --git a/batman-adv/patches/0007-batman-adv-invalidate-checksum-on-fragment-reassembl.patch b/batman-adv/patches/0007-batman-adv-invalidate-checksum-on-fragment-reassembl.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..6babc190ecd0c105251eea68b8452b593600a3ba +--- /dev/null ++++ b/batman-adv/patches/0007-batman-adv-invalidate-checksum-on-fragment-reassembl.patch +@@ -0,0 +1,39 @@ ++From: Matthias Schiffer ++Date: Tue, 23 Jan 2018 10:59:50 +0100 ++Subject: [PATCH] batman-adv: invalidate checksum on fragment reassembly ++ ++A more sophisticated implementation could try to combine fragment checksums ++when all fragments have CHECKSUM_COMPLETE and are split at even offsets. ++For now, we just set ip_summed to CHECKSUM_NONE to avoid "hw csum failure" ++warnings in the kernel log when fragmented frames are received. In ++consequence, skb_pull_rcsum() can be replaced with skb_pull(). ++ ++Note that in usual setups, packets don't reach batman-adv with ++CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see ++batadv's ethtype?), which is why the log messages do not occur on every ++system using batman-adv. I could reproduce this issue by stacking ++batman-adv on top of a VXLAN interface. ++ ++Fixes: 9b3eab61754d ("batman-adv: Receive fragmented packets and merge") ++Signed-off-by: Matthias Schiffer ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/2c1bce065baa688bc1eca4116f83ca3b790432a5 ++--- ++ net/batman-adv/fragmentation.c | 3 ++- ++ 1 file changed, 2 insertions(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c ++index ebe6e38934e46ed5de4d30204e791dbe40285fcc..1bb2b43f356af89a4231557de25dc2197b5c0177 100644 ++--- a/net/batman-adv/fragmentation.c +++++ b/net/batman-adv/fragmentation.c ++@@ -287,7 +287,8 @@ batadv_frag_merge_packets(struct hlist_head *chain) ++ /* Move the existing MAC header to just before the payload. (Override ++ * the fragment header.) ++ */ ++- skb_pull_rcsum(skb_out, hdr_size); +++ skb_pull(skb_out, hdr_size); +++ skb_out->ip_summed = CHECKSUM_NONE; ++ memmove(skb_out->data - ETH_HLEN, skb_mac_header(skb_out), ETH_HLEN); ++ skb_set_mac_header(skb_out, -ETH_HLEN); ++ skb_reset_network_header(skb_out); +diff --git a/batman-adv/patches/0008-batman-adv-Ignore-invalid-batadv_iv_gw-during-netlin.patch b/batman-adv/patches/0008-batman-adv-Ignore-invalid-batadv_iv_gw-during-netlin.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..ec6b6b57ac61d3f283c99fe89d40cc984da14702 +--- /dev/null ++++ b/batman-adv/patches/0008-batman-adv-Ignore-invalid-batadv_iv_gw-during-netlin.patch +@@ -0,0 +1,33 @@ ++From: Sven Eckelmann ++Date: Mon, 19 Feb 2018 14:08:52 +0100 ++Subject: [PATCH] batman-adv: Ignore invalid batadv_iv_gw during netlink send ++ ++The function batadv_iv_gw_dump stops the processing loop when ++batadv_iv_gw_dump_entry returns a non-0 return code. This should only ++happen when the buffer is full. Otherwise, an empty message may be ++returned by batadv_gw_dump. This empty message will then stop the netlink ++dumping of gateway entries. At worst, not a single entry is returned to ++userspace even when plenty of possible gateways exist. ++ ++Fixes: fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations") ++Signed-off-by: Sven Eckelmann ++Signed-off-by: Simon Wunderlich ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/c58f37c248bb4926cda82fd0463b6fecb3d3654f ++--- ++ net/batman-adv/bat_iv_ogm.c | 2 +- ++ 1 file changed, 1 insertion(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c ++index 0f9749c780056df271c1b1167299de75dbdbd770..bdcfec618ad57fa77b7c239ffdf5d3ca37593cc5 100644 ++--- a/net/batman-adv/bat_iv_ogm.c +++++ b/net/batman-adv/bat_iv_ogm.c ++@@ -2719,7 +2719,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ++ struct batadv_neigh_ifinfo *router_ifinfo = NULL; ++ struct batadv_neigh_node *router; ++ struct batadv_gw_node *curr_gw; ++- int ret = -EINVAL; +++ int ret = 0; ++ void *hdr; ++ ++ router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); +diff --git a/batman-adv/patches/0009-batman-adv-Ignore-invalid-batadv_v_gw-during-netlink.patch b/batman-adv/patches/0009-batman-adv-Ignore-invalid-batadv_v_gw-during-netlink.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..9a1a907b34ad70b975c252f779eacbf48995ae14 +--- /dev/null ++++ b/batman-adv/patches/0009-batman-adv-Ignore-invalid-batadv_v_gw-during-netlink.patch +@@ -0,0 +1,33 @@ ++From: Sven Eckelmann ++Date: Mon, 19 Feb 2018 14:08:53 +0100 ++Subject: [PATCH] batman-adv: Ignore invalid batadv_v_gw during netlink send ++ ++The function batadv_v_gw_dump stops the processing loop when ++batadv_v_gw_dump_entry returns a non-0 return code. This should only ++happen when the buffer is full. Otherwise, an empty message may be ++returned by batadv_gw_dump. This empty message will then stop the netlink ++dumping of gateway entries. At worst, not a single entry is returned to ++userspace even when plenty of possible gateways exist. ++ ++Fixes: 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations") ++Signed-off-by: Sven Eckelmann ++Signed-off-by: Simon Wunderlich ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/12f1d3a6bf4d157928fec509aab981e5243ee438 ++--- ++ net/batman-adv/bat_v.c | 2 +- ++ 1 file changed, 1 insertion(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c ++index cb227bcdc35c3a48b3fd85cd2749730bf857c704..73954b8be5dca6c72f34b3be236cac89562b3b74 100644 ++--- a/net/batman-adv/bat_v.c +++++ b/net/batman-adv/bat_v.c ++@@ -930,7 +930,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ++ struct batadv_neigh_ifinfo *router_ifinfo = NULL; ++ struct batadv_neigh_node *router; ++ struct batadv_gw_node *curr_gw; ++- int ret = -EINVAL; +++ int ret = 0; ++ void *hdr; ++ ++ router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); +diff --git a/batman-adv/patches/0010-batman-adv-Fix-netlink-dumping-of-BLA-claims.patch b/batman-adv/patches/0010-batman-adv-Fix-netlink-dumping-of-BLA-claims.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..4c4bf85996dcc6513a1fd7906710db1a64d67935 +--- /dev/null ++++ b/batman-adv/patches/0010-batman-adv-Fix-netlink-dumping-of-BLA-claims.patch +@@ -0,0 +1,62 @@ ++From: Sven Eckelmann ++Date: Sat, 24 Feb 2018 12:03:36 +0100 ++Subject: [PATCH] batman-adv: Fix netlink dumping of BLA claims ++ ++The function batadv_bla_claim_dump_bucket must be able to handle ++non-complete dumps of a single bucket. It tries to do that by saving the ++latest dumped index in *idx_skip to inform the caller about the current ++state. ++ ++But the caller only assumes that buckets were not completely dumped when ++the return code is non-zero. This function must therefore also return a ++non-zero index when the dumping of an entry failed. Otherwise the caller ++will just skip all remaining buckets. ++ ++And the function must also reset *idx_skip back to zero when it finished a ++bucket. Otherwise it will skip the same number of entries in the next ++bucket as the previous one had. ++ ++Fixes: 3b7a63606020 ("batman-adv: add B.A.T.M.A.N. Dump BLA claims via netlink") ++Reported-by: Linus Lüssing ++Signed-off-by: Sven Eckelmann ++Signed-off-by: Simon Wunderlich ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/49197c00f82cfcfeef963ef9367841d38a6ff207 ++--- ++ net/batman-adv/bridge_loop_avoidance.c | 11 +++++++---- ++ 1 file changed, 7 insertions(+), 4 deletions(-) ++ ++diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c ++index cdd8e8e4df0b382b21ff674b9aafcd19e9a581e7..60ce119e0b50edf8a4ecc22f54faeb4b720211b9 100644 ++--- a/net/batman-adv/bridge_loop_avoidance.c +++++ b/net/batman-adv/bridge_loop_avoidance.c ++@@ -2161,22 +2161,25 @@ batadv_bla_claim_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq, ++ { ++ struct batadv_bla_claim *claim; ++ int idx = 0; +++ int ret = 0; ++ ++ rcu_read_lock(); ++ hlist_for_each_entry_rcu(claim, head, hash_entry) { ++ if (idx++ < *idx_skip) ++ continue; ++- if (batadv_bla_claim_dump_entry(msg, portid, seq, ++- primary_if, claim)) { +++ +++ ret = batadv_bla_claim_dump_entry(msg, portid, seq, +++ primary_if, claim); +++ if (ret) { ++ *idx_skip = idx - 1; ++ goto unlock; ++ } ++ } ++ ++- *idx_skip = idx; +++ *idx_skip = 0; ++ unlock: ++ rcu_read_unlock(); ++- return 0; +++ return ret; ++ } ++ ++ /** +diff --git a/batman-adv/patches/0011-batman-adv-Fix-netlink-dumping-of-BLA-backbones.patch b/batman-adv/patches/0011-batman-adv-Fix-netlink-dumping-of-BLA-backbones.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..8f6c473f6daf51015c37fe80cfacf6f30e80e7d6 +--- /dev/null ++++ b/batman-adv/patches/0011-batman-adv-Fix-netlink-dumping-of-BLA-backbones.patch +@@ -0,0 +1,62 @@ ++From: Sven Eckelmann ++Date: Sat, 24 Feb 2018 12:03:37 +0100 ++Subject: [PATCH] batman-adv: Fix netlink dumping of BLA backbones ++ ++The function batadv_bla_backbone_dump_bucket must be able to handle ++non-complete dumps of a single bucket. It tries to do that by saving the ++latest dumped index in *idx_skip to inform the caller about the current ++state. ++ ++But the caller only assumes that buckets were not completely dumped when ++the return code is non-zero. This function must therefore also return a ++non-zero index when the dumping of an entry failed. Otherwise the caller ++will just skip all remaining buckets. ++ ++And the function must also reset *idx_skip back to zero when it finished a ++bucket. Otherwise it will skip the same number of entries in the next ++bucket as the previous one had. ++ ++Fixes: 7f609cab5123 ("batman-adv: add backbone table netlink support") ++Reported-by: Linus Lüssing ++Signed-off-by: Sven Eckelmann ++Signed-off-by: Simon Wunderlich ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/29e4759e49f06014b84791397ebe1b22546edd2d ++--- ++ net/batman-adv/bridge_loop_avoidance.c | 11 +++++++---- ++ 1 file changed, 7 insertions(+), 4 deletions(-) ++ ++diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c ++index 60ce119e0b50edf8a4ecc22f54faeb4b720211b9..422ee16b7854de39259bd171584f8dd0301a2ab6 100644 ++--- a/net/batman-adv/bridge_loop_avoidance.c +++++ b/net/batman-adv/bridge_loop_avoidance.c ++@@ -2394,22 +2394,25 @@ batadv_bla_backbone_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq, ++ { ++ struct batadv_bla_backbone_gw *backbone_gw; ++ int idx = 0; +++ int ret = 0; ++ ++ rcu_read_lock(); ++ hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) { ++ if (idx++ < *idx_skip) ++ continue; ++- if (batadv_bla_backbone_dump_entry(msg, portid, seq, ++- primary_if, backbone_gw)) { +++ +++ ret = batadv_bla_backbone_dump_entry(msg, portid, seq, +++ primary_if, backbone_gw); +++ if (ret) { ++ *idx_skip = idx - 1; ++ goto unlock; ++ } ++ } ++ ++- *idx_skip = idx; +++ *idx_skip = 0; ++ unlock: ++ rcu_read_unlock(); ++- return 0; +++ return ret; ++ } ++ ++ /** +diff --git a/batman-adv/patches/0012-batman-adv-Fix-internal-interface-indices-types.patch b/batman-adv/patches/0012-batman-adv-Fix-internal-interface-indices-types.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..dca78fdf75fa614e3964c94ba1103a59f621986a +--- /dev/null ++++ b/batman-adv/patches/0012-batman-adv-Fix-internal-interface-indices-types.patch +@@ -0,0 +1,241 @@ ++From: Sven Eckelmann ++Date: Tue, 26 Dec 2017 15:14:01 +0100 ++Subject: [PATCH] batman-adv: Fix internal interface indices types ++ ++batman-adv uses internal indices for each enabled and active interface. ++It is currently used by the B.A.T.M.A.N. IV algorithm to identifify the ++correct position in the ogm_cnt bitmaps. ++ ++The type for the number of enabled interfaces (which defines the next ++interface index) was set to char. This type can be (depending on the ++architecture) either signed (limiting batman-adv to 127 active slave ++interfaces) or unsigned (limiting batman-adv to 255 active slave ++interfaces). ++ ++This limit was not correctly checked when an interface was enabled and thus ++an overflow happened. This was only catched on systems with the signed char ++type when the B.A.T.M.A.N. IV code tried to resize its counter arrays with ++a negative size. ++ ++The if_num interface index was only a s16 and therefore significantly ++smaller than the ifindex (int) used by the code net code. ++ ++Both &batadv_hard_iface->if_num and &batadv_priv->num_ifaces must be ++(unsigned) int to support the same number of slave interfaces as the net ++core code. And the interface activation code must check the number of ++active slave interfaces to avoid integer overflows. ++ ++Fixes: d1fbb61d0534 ("raw socket operations added: create / destroy / bind / send broadcast of own OGMs implemented orig interval configurable via /proc/net/batman-adv/orig_interval") ++Fixes: ea6f8d42a595 ("batman-adv: move /proc interface handling to /sys") ++Signed-off-by: Sven Eckelmann ++Signed-off-by: Simon Wunderlich ++ ++Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/d5db560de1352d3ec6933bca25b3aaad7ddd15e1 ++--- ++ net/batman-adv/bat_iv_ogm.c | 24 ++++++++++++++---------- ++ net/batman-adv/hard-interface.c | 9 +++++++-- ++ net/batman-adv/originator.c | 4 ++-- ++ net/batman-adv/originator.h | 4 ++-- ++ net/batman-adv/types.h | 11 ++++++----- ++ 5 files changed, 31 insertions(+), 21 deletions(-) ++ ++diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c ++index bdcfec618ad57fa77b7c239ffdf5d3ca37593cc5..13b7da10114d26bacc3cd7af05a73ebdf0145ce7 100644 ++--- a/net/batman-adv/bat_iv_ogm.c +++++ b/net/batman-adv/bat_iv_ogm.c ++@@ -149,7 +149,7 @@ static void batadv_iv_ogm_orig_free(struct batadv_orig_node *orig_node) ++ * Return: 0 on success, a negative error code otherwise. ++ */ ++ static int batadv_iv_ogm_orig_add_if(struct batadv_orig_node *orig_node, ++- int max_if_num) +++ unsigned int max_if_num) ++ { ++ void *data_ptr; ++ size_t old_size; ++@@ -193,7 +193,8 @@ static int batadv_iv_ogm_orig_add_if(struct batadv_orig_node *orig_node, ++ */ ++ static void ++ batadv_iv_ogm_drop_bcast_own_entry(struct batadv_orig_node *orig_node, ++- int max_if_num, int del_if_num) +++ unsigned int max_if_num, +++ unsigned int del_if_num) ++ { ++ size_t chunk_size; ++ size_t if_offset; ++@@ -231,7 +232,8 @@ batadv_iv_ogm_drop_bcast_own_entry(struct batadv_orig_node *orig_node, ++ */ ++ static void ++ batadv_iv_ogm_drop_bcast_own_sum_entry(struct batadv_orig_node *orig_node, ++- int max_if_num, int del_if_num) +++ unsigned int max_if_num, +++ unsigned int del_if_num) ++ { ++ size_t if_offset; ++ void *data_ptr; ++@@ -268,7 +270,8 @@ batadv_iv_ogm_drop_bcast_own_sum_entry(struct batadv_orig_node *orig_node, ++ * Return: 0 on success, a negative error code otherwise. ++ */ ++ static int batadv_iv_ogm_orig_del_if(struct batadv_orig_node *orig_node, ++- int max_if_num, int del_if_num) +++ unsigned int max_if_num, +++ unsigned int del_if_num) ++ { ++ spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock); ++ ++@@ -302,7 +305,8 @@ static struct batadv_orig_node * ++ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr) ++ { ++ struct batadv_orig_node *orig_node; ++- int size, hash_added; +++ int hash_added; +++ size_t size; ++ ++ orig_node = batadv_orig_hash_find(bat_priv, addr); ++ if (orig_node) ++@@ -884,7 +888,7 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface) ++ u32 i; ++ size_t word_index; ++ u8 *w; ++- int if_num; +++ unsigned int if_num; ++ ++ for (i = 0; i < hash->size; i++) { ++ head = &hash->table[i]; ++@@ -1014,7 +1018,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ++ struct batadv_neigh_node *tmp_neigh_node = NULL; ++ struct batadv_neigh_node *router = NULL; ++ struct batadv_orig_node *orig_node_tmp; ++- int if_num; +++ unsigned int if_num; ++ u8 sum_orig, sum_neigh; ++ u8 *neigh_addr; ++ u8 tq_avg; ++@@ -1173,7 +1177,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ++ u8 total_count; ++ u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; ++ unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; ++- int if_num; +++ unsigned int if_num; ++ unsigned int tq_asym_penalty, inv_asym_penalty; ++ unsigned int combined_tq; ++ unsigned int tq_iface_penalty; ++@@ -1692,9 +1696,9 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset, ++ ++ if (is_my_orig) { ++ unsigned long *word; ++- int offset; +++ size_t offset; ++ s32 bit_pos; ++- s16 if_num; +++ unsigned int if_num; ++ u8 *weight; ++ ++ orig_neigh_node = batadv_iv_ogm_orig_get(bat_priv, ++diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c ++index e348f76ea8c15c8901294598c02617028063bfd6..69f1704fcaa4e980dfadcbb943db43544763d469 100644 ++--- a/net/batman-adv/hard-interface.c +++++ b/net/batman-adv/hard-interface.c ++@@ -737,6 +737,11 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, ++ hard_iface->soft_iface = soft_iface; ++ bat_priv = netdev_priv(hard_iface->soft_iface); ++ +++ if (bat_priv->num_ifaces >= UINT_MAX) { +++ ret = -ENOSPC; +++ goto err_dev; +++ } +++ ++ ret = netdev_master_upper_dev_link(hard_iface->net_dev, ++ soft_iface, NULL, NULL); ++ if (ret) ++@@ -844,7 +849,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, ++ batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface); ++ ++ /* nobody uses this interface anymore */ ++- if (!bat_priv->num_ifaces) { +++ if (bat_priv->num_ifaces == 0) { ++ batadv_gw_check_client_stop(bat_priv); ++ ++ if (autodel == BATADV_IF_CLEANUP_AUTO) ++@@ -880,7 +885,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) ++ if (ret) ++ goto free_if; ++ ++- hard_iface->if_num = -1; +++ hard_iface->if_num = 0; ++ hard_iface->net_dev = net_dev; ++ hard_iface->soft_iface = NULL; ++ hard_iface->if_status = BATADV_IF_NOT_IN_USE; ++diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c ++index 8e2a4b205257929e9b64f157e8570972cf1383f9..653eaadcfefb4db23c73034c157e7c86fc1bcc06 100644 ++--- a/net/batman-adv/originator.c +++++ b/net/batman-adv/originator.c ++@@ -1500,7 +1500,7 @@ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb) ++ } ++ ++ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, ++- int max_if_num) +++ unsigned int max_if_num) ++ { ++ struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); ++ struct batadv_algo_ops *bao = bat_priv->algo_ops; ++@@ -1535,7 +1535,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, ++ } ++ ++ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, ++- int max_if_num) +++ unsigned int max_if_num) ++ { ++ struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); ++ struct batadv_hashtable *hash = bat_priv->orig_hash; ++diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h ++index d94220a6d21acf58d55fcf7a179151c67392b055..d6ca52220ec066d8e82096b7487d6f5e9dfd57dc 100644 ++--- a/net/batman-adv/originator.h +++++ b/net/batman-adv/originator.h ++@@ -78,9 +78,9 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); ++ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb); ++ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset); ++ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, ++- int max_if_num); +++ unsigned int max_if_num); ++ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, ++- int max_if_num); +++ unsigned int max_if_num); ++ struct batadv_orig_node_vlan * ++ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, ++ unsigned short vid); ++diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h ++index a62795868794103d7e712ba91def5997dc3a5779..bb776a842870815582ca428d010a437a2606b175 100644 ++--- a/net/batman-adv/types.h +++++ b/net/batman-adv/types.h ++@@ -155,7 +155,7 @@ enum batadv_hard_iface_wifi_flags { ++ */ ++ struct batadv_hard_iface { ++ struct list_head list; ++- s16 if_num; +++ unsigned int if_num; ++ char if_status; ++ u8 num_bcasts; ++ u32 wifi_flags; ++@@ -1079,7 +1079,7 @@ struct batadv_priv { ++ atomic_t bcast_seqno; ++ atomic_t bcast_queue_left; ++ atomic_t batman_queue_left; ++- char num_ifaces; +++ unsigned int num_ifaces; ++ struct kobject *mesh_obj; ++ struct dentry *debug_dir; ++ struct hlist_head forw_bat_list; ++@@ -1477,9 +1477,10 @@ struct batadv_algo_neigh_ops { ++ */ ++ struct batadv_algo_orig_ops { ++ void (*free)(struct batadv_orig_node *orig_node); ++- int (*add_if)(struct batadv_orig_node *orig_node, int max_if_num); ++- int (*del_if)(struct batadv_orig_node *orig_node, int max_if_num, ++- int del_if_num); +++ int (*add_if)(struct batadv_orig_node *orig_node, +++ unsigned int max_if_num); +++ int (*del_if)(struct batadv_orig_node *orig_node, +++ unsigned int max_if_num, unsigned int del_if_num); ++ #ifdef CONFIG_BATMAN_ADV_DEBUGFS ++ void (*print)(struct batadv_priv *priv, struct seq_file *seq, ++ struct batadv_hard_iface *hard_iface); diff --git a/patches/packages/routing/0004-batman-adv-Merge-bugfixes-from-2018.1.patch b/patches/packages/routing/0004-batman-adv-Merge-bugfixes-from-2018.1.patch new file mode 100644 index 00000000..5891cb6f --- /dev/null +++ b/patches/packages/routing/0004-batman-adv-Merge-bugfixes-from-2018.1.patch @@ -0,0 +1,456 @@ +From: Sven Eckelmann +Date: Wed, 25 Apr 2018 20:29:31 +0200 +Subject: batman-adv: Merge bugfixes from 2018.1 + +* Fix skbuff rcsum on packet reroute +* update data pointers after skb_cow() +* fix header size check in batadv_dbg_arp() +* Fix multicast packet loss with a single WANT_ALL_IPV4/6 flag +* fix multicast-via-unicast transmission with AP isolation +* fix packet loss for broadcasted DHCP packets to a server + +Signed-off-by: Sven Eckelmann + +Origin: backport, https://github.com/openwrt-routing/packages/commit/9b777e6b13a3f85ad0b6d2c872871b611ac5bf4f + +diff --git a/batman-adv/Makefile b/batman-adv/Makefile +index 3765c0273e7fc3923a6234514e0478f80277d2e5..8904a0cb1a430126c524b608f5d6a1466a07c04a 100644 +--- a/batman-adv/Makefile ++++ b/batman-adv/Makefile +@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk + PKG_NAME:=batman-adv + + PKG_VERSION:=2017.2 +-PKG_RELEASE:=3 ++PKG_RELEASE:=4 + PKG_MD5SUM:=937b5f1d0188e3522d67ad45ee0a4f5a + PKG_HASH:=d487974e21cb53d39f139e93a2cf297807df5b7bf63ba6d810bad6d91537394f + +diff --git a/batman-adv/patches/0013-batman-adv-Fix-multicast-packet-loss-with-a-single-W.patch b/batman-adv/patches/0013-batman-adv-Fix-multicast-packet-loss-with-a-single-W.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..4b28914e332622b46582a3143f251c6054db2f24 +--- /dev/null ++++ b/batman-adv/patches/0013-batman-adv-Fix-multicast-packet-loss-with-a-single-W.patch +@@ -0,0 +1,38 @@ ++From: Linus Lüssing ++Date: Sun, 4 Mar 2018 13:08:17 +0100 ++Subject: [PATCH] batman-adv: Fix multicast packet loss with a single WANT_ALL_IPV4/6 flag ++ ++As the kernel doc describes too the code is supposed to skip adding ++multicast TT entries if both the WANT_ALL_IPV4 and WANT_ALL_IPV6 flags ++are present. ++ ++Unfortunately, the current code even skips adding multicast TT entries ++if only either the WANT_ALL_IPV4 or WANT_ALL_IPV6 is present. ++ ++This could lead to IPv6 multicast packet loss if only an IGMP but not an ++MLD querier is present for instance or vice versa. ++ ++Fixes: 391b59cdb111 ("batman-adv: Add multicast optimization support for bridged setups") ++Signed-off-by: Linus Lüssing ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/edba00d56efb1d55cdd40957e010fba80580b5e2 ++--- ++ net/batman-adv/multicast.c | 4 ++-- ++ 1 file changed, 2 insertions(+), 2 deletions(-) ++ ++diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c ++index d327670641ac336a14f0ecc85dd848d4952e8e6e..df9e114d92d01ffe7fc3cf39a47e27074a85d189 100644 ++--- a/net/batman-adv/multicast.c +++++ b/net/batman-adv/multicast.c ++@@ -540,8 +540,8 @@ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv) ++ bat_priv->mcast.enabled = true; ++ } ++ ++- return !(mcast_data.flags & ++- (BATADV_MCAST_WANT_ALL_IPV4 | BATADV_MCAST_WANT_ALL_IPV6)); +++ return !(mcast_data.flags & BATADV_MCAST_WANT_ALL_IPV4 && +++ mcast_data.flags & BATADV_MCAST_WANT_ALL_IPV6); ++ } ++ ++ /** +diff --git a/batman-adv/patches/0014-batman-adv-update-data-pointers-after-skb_cow.patch b/batman-adv/patches/0014-batman-adv-update-data-pointers-after-skb_cow.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..993a27d95e57c602409f63e27c6afc46a248675b +--- /dev/null ++++ b/batman-adv/patches/0014-batman-adv-update-data-pointers-after-skb_cow.patch +@@ -0,0 +1,61 @@ ++From: Matthias Schiffer ++Date: Fri, 16 Mar 2018 11:29:09 +0100 ++Subject: [PATCH] batman-adv: update data pointers after skb_cow() ++ ++batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data ++must be (re)set after calling it. The ethhdr variable is dropped ++altogether. ++ ++Fixes: 78fc6bbe0aca ("batman-adv: add UNICAST_4ADDR packet type") ++Signed-off-by: Matthias Schiffer ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/64d22c76a207ed313b2496f0709b2567719452c4 ++--- ++ net/batman-adv/routing.c | 10 +++++----- ++ 1 file changed, 5 insertions(+), 5 deletions(-) ++ ++diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c ++index f10e3ff26f9dc8f565ecab012aaeb2b69d80d6ca..7740e08f7aa0e26ebc951b65b8d60049fc2ba658 100644 ++--- a/net/batman-adv/routing.c +++++ b/net/batman-adv/routing.c ++@@ -945,14 +945,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ++ struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL; ++ int check, hdr_size = sizeof(*unicast_packet); ++ enum batadv_subtype subtype; ++- struct ethhdr *ethhdr; ++ int ret = NET_RX_DROP; ++ bool is4addr, is_gw; ++ ++ unicast_packet = (struct batadv_unicast_packet *)skb->data; ++- unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; ++- ethhdr = eth_hdr(skb); ++- ++ is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR; ++ /* the caller function should have already pulled 2 bytes */ ++ if (is4addr) ++@@ -972,12 +968,14 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ++ if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size)) ++ goto free_skb; ++ +++ unicast_packet = (struct batadv_unicast_packet *)skb->data; +++ ++ /* packet for me */ ++ if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) { ++ /* If this is a unicast packet from another backgone gw, ++ * drop it. ++ */ ++- orig_addr_gw = ethhdr->h_source; +++ orig_addr_gw = eth_hdr(skb)->h_source; ++ orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw); ++ if (orig_node_gw) { ++ is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw, ++@@ -992,6 +990,8 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ++ } ++ ++ if (is4addr) { +++ unicast_4addr_packet = +++ (struct batadv_unicast_4addr_packet *)skb->data; ++ subtype = unicast_4addr_packet->subtype; ++ batadv_dat_inc_counter(bat_priv, subtype); ++ +diff --git a/batman-adv/patches/0015-batman-adv-fix-header-size-check-in-batadv_dbg_arp.patch b/batman-adv/patches/0015-batman-adv-fix-header-size-check-in-batadv_dbg_arp.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..e1d6c2ecb8e005435a117bfea0b8fda598b38cd0 +--- /dev/null ++++ b/batman-adv/patches/0015-batman-adv-fix-header-size-check-in-batadv_dbg_arp.patch +@@ -0,0 +1,30 @@ ++From: Matthias Schiffer ++Date: Fri, 16 Mar 2018 11:29:10 +0100 ++Subject: [PATCH] batman-adv: fix header size check in batadv_dbg_arp() ++ ++Checking for 0 is insufficient: when an SKB without a batadv header, but ++with a VLAN header is received, hdr_size will be 4, making the following ++code interpret the Ethernet header as a batadv header. ++ ++Fixes: 3e26722bc9f2 ("batman-adv: make the Distributed ARP Table vlan aware") ++Signed-off-by: Matthias Schiffer ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/7dfe729b169b1217f47744edbd1616f473340fda ++--- ++ net/batman-adv/distributed-arp-table.c | 2 +- ++ 1 file changed, 1 insertion(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c ++index b6cfa78e9381f5dca63e7a4a8d05f136d823c4db..4f0111bc6621e66c411bc929b3d18b3f543234cd 100644 ++--- a/net/batman-adv/distributed-arp-table.c +++++ b/net/batman-adv/distributed-arp-table.c ++@@ -391,7 +391,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, ++ batadv_arp_hw_src(skb, hdr_size), &ip_src, ++ batadv_arp_hw_dst(skb, hdr_size), &ip_dst); ++ ++- if (hdr_size == 0) +++ if (hdr_size < sizeof(struct batadv_unicast_packet)) ++ return; ++ ++ unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; +diff --git a/batman-adv/patches/0016-batman-adv-Fix-skbuff-rcsum-on-packet-reroute.patch b/batman-adv/patches/0016-batman-adv-Fix-skbuff-rcsum-on-packet-reroute.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..da18f796890b7948e96547573b8bd3d9512224d9 +--- /dev/null ++++ b/batman-adv/patches/0016-batman-adv-Fix-skbuff-rcsum-on-packet-reroute.patch +@@ -0,0 +1,139 @@ ++From: Sven Eckelmann ++Date: Sun, 18 Mar 2018 13:12:01 +0100 ++Subject: [PATCH] batman-adv: Fix skbuff rcsum on packet reroute ++ ++batadv_check_unicast_ttvn may redirect a packet to itself or another ++originator. This involves rewriting the ttvn and the destination address in ++the batadv unicast header. These field were not yet pulled (with skb rcsum ++update) and thus any change to them also requires a change in the receive ++checksum. ++ ++Reported-by: Matthias Schiffer ++Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism") ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/fb91b0ef84738102807e5dd7ec0b3565415aff56 ++--- ++ compat-include/linux/skbuff.h | 12 ++++++++++++ ++ compat-sources/net/core/skbuff.c | 17 ----------------- ++ net/batman-adv/routing.c | 15 ++++++++++----- ++ 3 files changed, 22 insertions(+), 22 deletions(-) ++ ++diff --git a/compat-include/linux/skbuff.h b/compat-include/linux/skbuff.h ++index 03765c62830683dad503578eaeaadac30d6d85cd..65486ca6aad1ec31533e0b4bfa0b52396c0e1ddf 100644 ++--- a/compat-include/linux/skbuff.h +++++ b/compat-include/linux/skbuff.h ++@@ -76,6 +76,18 @@ struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb, ++ ++ #endif /* < KERNEL_VERSION(4, 2, 0) */ ++ +++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) +++ +++static inline void skb_postpush_rcsum(struct sk_buff *skb, +++ const void *start, unsigned int len) +++{ +++ if (skb->ip_summed == CHECKSUM_COMPLETE) +++ skb->csum = csum_block_add(skb->csum, +++ csum_partial(start, len, 0), 0); +++} +++ +++#endif /* < KERNEL_VERSION(4, 5, 0) */ +++ ++ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) ++ ++ static inline void *batadv_skb_put(struct sk_buff *skb, unsigned int len) ++diff --git a/compat-sources/net/core/skbuff.c b/compat-sources/net/core/skbuff.c ++index 40c9e8b92e4c6eedcc2f73c5717d71dabf7590e2..f8d76c6c8d3d05d03d24060f90e72ad34d53bf21 100644 ++--- a/compat-sources/net/core/skbuff.c +++++ b/compat-sources/net/core/skbuff.c ++@@ -92,23 +92,6 @@ skb_checksum_validate(struct sk_buff *skb, int proto, ++ ++ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) ++ ++-static inline void skb_postpush_rcsum(struct sk_buff *skb, ++- const void *start, unsigned int len) ++-{ ++- /* For performing the reverse operation to skb_postpull_rcsum(), ++- * we can instead of ... ++- * ++- * skb->csum = csum_add(skb->csum, csum_partial(start, len, 0)); ++- * ++- * ... just use this equivalent version here to save a few ++- * instructions. Feeding csum of 0 in csum_partial() and later ++- * on adding skb->csum is equivalent to feed skb->csum in the ++- * first place. ++- */ ++- if (skb->ip_summed == CHECKSUM_COMPLETE) ++- skb->csum = csum_partial(start, len, skb->csum); ++-} ++- ++ /** ++ * skb_push_rcsum - push skb and update receive checksum ++ * @skb: buffer to update ++diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c ++index 7740e08f7aa0e26ebc951b65b8d60049fc2ba658..f59aac06733e1a7c45f9bb08b48fbf9c42eb740a 100644 ++--- a/net/batman-adv/routing.c +++++ b/net/batman-adv/routing.c ++@@ -743,6 +743,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, ++ /** ++ * batadv_reroute_unicast_packet - update the unicast header for re-routing ++ * @bat_priv: the bat priv with all the soft interface information +++ * @skb: unicast packet to process ++ * @unicast_packet: the unicast header to be updated ++ * @dst_addr: the payload destination ++ * @vid: VLAN identifier ++@@ -754,7 +755,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, ++ * Return: true if the packet header has been updated, false otherwise ++ */ ++ static bool ++-batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, +++batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, ++ struct batadv_unicast_packet *unicast_packet, ++ u8 *dst_addr, unsigned short vid) ++ { ++@@ -783,8 +784,10 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, ++ } ++ ++ /* update the packet header */ +++ skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ++ ether_addr_copy(unicast_packet->dest, orig_addr); ++ unicast_packet->ttvn = orig_ttvn; +++ skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ++ ++ ret = true; ++ out: ++@@ -825,7 +828,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ++ * the packet to ++ */ ++ if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) { ++- if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, +++ if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet, ++ ethhdr->h_dest, vid)) ++ batadv_dbg_ratelimited(BATADV_DBG_TT, ++ bat_priv, ++@@ -871,7 +874,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ++ * destination can possibly be updated and forwarded towards the new ++ * target host ++ */ ++- if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, +++ if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet, ++ ethhdr->h_dest, vid)) { ++ batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv, ++ "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", ++@@ -894,12 +897,14 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ++ if (!primary_if) ++ return false; ++ +++ /* update the packet header */ +++ skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ++ ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr); +++ unicast_packet->ttvn = curr_ttvn; +++ skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ++ ++ batadv_hardif_put(primary_if); ++ ++- unicast_packet->ttvn = curr_ttvn; ++- ++ return true; ++ } ++ +diff --git a/batman-adv/patches/0017-batman-adv-fix-multicast-via-unicast-transmission-wi.patch b/batman-adv/patches/0017-batman-adv-fix-multicast-via-unicast-transmission-wi.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..68c27ddade20ff586c8133d8104fa9caccd18e54 +--- /dev/null ++++ b/batman-adv/patches/0017-batman-adv-fix-multicast-via-unicast-transmission-wi.patch +@@ -0,0 +1,42 @@ ++From: Linus Lüssing ++Date: Tue, 20 Mar 2018 03:13:27 +0100 ++Subject: [PATCH] batman-adv: fix multicast-via-unicast transmission with AP isolation ++ ++For multicast frames AP isolation is only supposed to be checked on ++the receiving nodes and never on the originating one. ++ ++Furthermore, the isolation or wifi flag bits should only be intepreted ++as such for unicast and never multicast TT entries. ++ ++By injecting flags to the multicast TT entry claimed by a single ++target node it was verified in tests that this multicast address ++becomes unreachable, leading to packet loss. ++ ++Omitting the "src" parameter to the batadv_transtable_search() call ++successfully skipped the AP isolation check and made the target ++reachable again. ++ ++Fixes: 405cc1e5a81e ("batman-adv: Modified forwarding behaviour for multicast packets") ++Signed-off-by: Linus Lüssing ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/67a50c93bceb534937d6a188eded79272ff6d55d ++--- ++ net/batman-adv/multicast.c | 4 ++-- ++ 1 file changed, 2 insertions(+), 2 deletions(-) ++ ++diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c ++index df9e114d92d01ffe7fc3cf39a47e27074a85d189..fa02fb73367c9a7c505c08299b8079e01d42c680 100644 ++--- a/net/batman-adv/multicast.c +++++ b/net/batman-adv/multicast.c ++@@ -809,8 +809,8 @@ static struct batadv_orig_node * ++ batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv, ++ struct ethhdr *ethhdr) ++ { ++- return batadv_transtable_search(bat_priv, ethhdr->h_source, ++- ethhdr->h_dest, BATADV_NO_FLAGS); +++ return batadv_transtable_search(bat_priv, NULL, ethhdr->h_dest, +++ BATADV_NO_FLAGS); ++ } ++ ++ /** +diff --git a/batman-adv/patches/0018-batman-adv-fix-packet-loss-for-broadcasted-DHCP-pack.patch b/batman-adv/patches/0018-batman-adv-fix-packet-loss-for-broadcasted-DHCP-pack.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..7a135f119ad032a87de6fdb222f92ff521b4a318 +--- /dev/null ++++ b/batman-adv/patches/0018-batman-adv-fix-packet-loss-for-broadcasted-DHCP-pack.patch +@@ -0,0 +1,82 @@ ++From: Linus Lüssing ++Date: Thu, 22 Mar 2018 00:21:32 +0100 ++Subject: [PATCH] batman-adv: fix packet loss for broadcasted DHCP packets to a server ++ ++DHCP connectivity issues can currently occur if the following conditions ++are met: ++ ++1) A DHCP packet from a client to a server ++2) This packet has a multicast destination ++3) This destination has a matching entry in the translation table ++ (FF:FF:FF:FF:FF:FF for IPv4, 33:33:00:01:00:02/33:33:00:01:00:03 ++ for IPv6) ++4) The orig-node determined by TT for the multicast destination ++ does not match the orig-node determined by best-gateway-selection ++ ++In this case the DHCP packet will be dropped. ++ ++The "gateway-out-of-range" check is supposed to only be applied to ++unicasted DHCP packets to a specific DHCP server. ++ ++In that case dropping the the unicasted frame forces the client to ++retry via a broadcasted one, but now directed to the new best ++gateway. ++ ++A DHCP packet with broadcast/multicast destination is already ensured to ++always be delivered to the best gateway. Dropping a multicasted ++DHCP packet here will only prevent completing DHCP as there is no ++other fallback. ++ ++So far, it seems the unicast check was implicitly performed by ++expecting the batadv_transtable_search() to return NULL for multicast ++destinations. However, a multicast address could have always ended up in ++the translation table and in fact is now common. ++ ++To fix this potential loss of a DHCP client-to-server packet to a ++multicast address this patch adds an explicit multicast destination ++check to reliably bail out of the gateway-out-of-range check for such ++destinations. ++ ++The issue and fix were tested in the following three node setup: ++ ++- Line topology, A-B-C ++- A: gateway client, DHCP client ++- B: gateway server, hop-penalty increased: 30->60, DHCP server ++- C: gateway server, code modifications to announce FF:FF:FF:FF:FF:FF ++ ++Without this patch, A would never transmit its DHCP Discover packet ++due to an always "out-of-range" condition. With this patch, ++a full DHCP handshake between A and B was possible again. ++ ++Fixes: afae4e42aae6 ("batman-adv: refactoring gateway handling code") ++Signed-off-by: Linus Lüssing ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/49b2132f0fe2753a3b46103db9719898c5cd44aa ++--- ++ net/batman-adv/gateway_client.c | 5 ++++- ++ 1 file changed, 4 insertions(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c ++index de9955d5224d258cdbd20c14a1758bf7b4af19f9..06276ae9f7529cbc19f870148bb205961143d4a6 100644 ++--- a/net/batman-adv/gateway_client.c +++++ b/net/batman-adv/gateway_client.c ++@@ -705,7 +705,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ++ { ++ struct batadv_neigh_node *neigh_curr = NULL; ++ struct batadv_neigh_node *neigh_old = NULL; ++- struct batadv_orig_node *orig_dst_node; +++ struct batadv_orig_node *orig_dst_node = NULL; ++ struct batadv_gw_node *gw_node = NULL; ++ struct batadv_gw_node *curr_gw = NULL; ++ struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo; ++@@ -716,6 +716,9 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ++ ++ vid = batadv_get_vid(skb, 0); ++ +++ if (is_multicast_ether_addr(ethhdr->h_dest)) +++ goto out; +++ ++ orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source, ++ ethhdr->h_dest, vid); ++ if (!orig_dst_node) diff --git a/patches/packages/routing/0005-batman-adv-Merge-bugfixes-from-2018.1-maint-2018-06-03.patch b/patches/packages/routing/0005-batman-adv-Merge-bugfixes-from-2018.1-maint-2018-06-03.patch new file mode 100644 index 00000000..19d7d7b3 --- /dev/null +++ b/patches/packages/routing/0005-batman-adv-Merge-bugfixes-from-2018.1-maint-2018-06-03.patch @@ -0,0 +1,779 @@ +From: Sven Eckelmann +Date: Sun, 3 Jun 2018 15:52:30 +0200 +Subject: batman-adv: Merge bugfixes from 2018.1-maint 2018-06-03 + +* Avoid race in TT TVLV allocator helper +* Fix TT sync flags for intermediate TT responses +* prevent TT request storms by not sending inconsistent TT TLVLs +* Fix bat_ogm_iv best gw refcnt after netlink dump +* Fix bat_v best gw refcnt after netlink dump +* Fix debugfs path for renamed hardif +* Fix debugfs path for renamed softif + +Signed-off-by: Sven Eckelmann + +Origin: backport, https://github.com/openwrt-routing/packages/commit/ea1e2c9c4ca0e4ef7b7d0e5c8d0ff135dd9a763c + +diff --git a/batman-adv/Makefile b/batman-adv/Makefile +index 8904a0cb1a430126c524b608f5d6a1466a07c04a..2ad3634a9f0eaecef1a7ef1d763a63c90de4464a 100644 +--- a/batman-adv/Makefile ++++ b/batman-adv/Makefile +@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk + PKG_NAME:=batman-adv + + PKG_VERSION:=2017.2 +-PKG_RELEASE:=4 ++PKG_RELEASE:=5 + PKG_MD5SUM:=937b5f1d0188e3522d67ad45ee0a4f5a + PKG_HASH:=d487974e21cb53d39f139e93a2cf297807df5b7bf63ba6d810bad6d91537394f + +diff --git a/batman-adv/patches/0019-batman-adv-Avoid-race-in-TT-TVLV-allocator-helper.patch b/batman-adv/patches/0019-batman-adv-Avoid-race-in-TT-TVLV-allocator-helper.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..24cfcf606396d610be9d8dc5bdc4808b9ebe91e6 +--- /dev/null ++++ b/batman-adv/patches/0019-batman-adv-Avoid-race-in-TT-TVLV-allocator-helper.patch +@@ -0,0 +1,75 @@ ++From: Sven Eckelmann ++Date: Wed, 9 May 2018 21:07:40 +0200 ++Subject: [PATCH] batman-adv: Avoid race in TT TVLV allocator helper ++ ++The functions batadv_tt_prepare_tvlv_local_data and ++batadv_tt_prepare_tvlv_global_data are responsible for preparing a buffer ++which can be used to store the TVLV container for TT and add the VLAN ++information to it. ++ ++This will be done in three phases: ++ ++1. count the number of VLANs and their entries ++2. allocate the buffer using the counters from the previous step and limits ++ from the caller (parameter tt_len) ++3. insert the VLAN information to the buffer ++ ++The step 1 and 3 operate on a list which contains the VLANs. The access to ++these lists must be protected with an appropriate lock or otherwise they ++might operate on on different entries. This could for example happen when ++another context is adding VLAN entries to this list. ++ ++This could lead to a buffer overflow in these functions when enough entries ++were added between step 1 and 3 to the VLAN lists that the buffer room for ++the entries (*tt_change) is smaller then the now required extra buffer for ++new VLAN entries. ++ ++Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific") ++Signed-off-by: Sven Eckelmann ++Acked-by: Antonio Quartulli ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/286be89a33497ba9000aa5c2960f1f4114953522 ++--- ++ net/batman-adv/translation-table.c | 8 ++++---- ++ 1 file changed, 4 insertions(+), 4 deletions(-) ++ ++diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c ++index 8a3ce79b1307b7f260ce2f64e96bdacfb9a322f0..131716b7cb9146112e04fc1b7b7919952b0fc5d5 100644 ++--- a/net/batman-adv/translation-table.c +++++ b/net/batman-adv/translation-table.c ++@@ -860,7 +860,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, ++ struct batadv_orig_node_vlan *vlan; ++ u8 *tt_change_ptr; ++ ++- rcu_read_lock(); +++ spin_lock_bh(&orig_node->vlan_list_lock); ++ hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { ++ num_vlan++; ++ num_entries += atomic_read(&vlan->tt.num_entries); ++@@ -898,7 +898,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, ++ *tt_change = (struct batadv_tvlv_tt_change *)tt_change_ptr; ++ ++ out: ++- rcu_read_unlock(); +++ spin_unlock_bh(&orig_node->vlan_list_lock); ++ return tvlv_len; ++ } ++ ++@@ -934,7 +934,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, ++ u8 *tt_change_ptr; ++ int change_offset; ++ ++- rcu_read_lock(); +++ spin_lock_bh(&bat_priv->softif_vlan_list_lock); ++ hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { ++ num_vlan++; ++ num_entries += atomic_read(&vlan->tt.num_entries); ++@@ -972,7 +972,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, ++ *tt_change = (struct batadv_tvlv_tt_change *)tt_change_ptr; ++ ++ out: ++- rcu_read_unlock(); +++ spin_unlock_bh(&bat_priv->softif_vlan_list_lock); ++ return tvlv_len; ++ } ++ +diff --git a/batman-adv/patches/0020-batman-adv-Fix-TT-sync-flags-for-intermediate-TT-res.patch b/batman-adv/patches/0020-batman-adv-Fix-TT-sync-flags-for-intermediate-TT-res.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..32a3718b096ceef2691364182196bd6ab16e96b7 +--- /dev/null ++++ b/batman-adv/patches/0020-batman-adv-Fix-TT-sync-flags-for-intermediate-TT-res.patch +@@ -0,0 +1,180 @@ ++From: Linus Lüssing ++Date: Thu, 10 May 2018 19:44:28 +0200 ++Subject: [PATCH] batman-adv: Fix TT sync flags for intermediate TT responses ++ ++The previous TT sync fix so far only fixed TT responses issued by the ++target node directly. So far, TT responses issued by intermediate nodes ++still lead to the wrong flags being added, leading to CRC mismatches. ++ ++This behaviour was observed at Freifunk Hannover in a 800 nodes setup ++where a considerable amount of nodes were still infected with 'WI' ++TT flags even with (most) nodes having the previous TT sync fix applied. ++ ++I was able to reproduce the issue with intermediate TT responses in a ++four node test setup and this patch fixes this issue by ensuring to ++use the per originator instead of the summarized, OR'd ones. ++ ++Fixes: fa614fd04692 ("batman-adv: fix tt_global_entries flags update") ++Signed-off-by: Linus Lüssing ++Signed-off-by: Sven Eckelmann ++ ++Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/d65daee8617b29c1ddcc949ce3a5ec24f7a1e1af ++--- ++ net/batman-adv/translation-table.c | 61 +++++++++++++++++++++++++----- ++ 1 file changed, 51 insertions(+), 10 deletions(-) ++ ++diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c ++index 131716b7cb9146112e04fc1b7b7919952b0fc5d5..af1bb290d22079fb55590c118de72a45b57a67ab 100644 ++--- a/net/batman-adv/translation-table.c +++++ b/net/batman-adv/translation-table.c ++@@ -1528,6 +1528,8 @@ batadv_tt_global_orig_entry_find(const struct batadv_tt_global_entry *entry, ++ * by a given originator ++ * @entry: the TT global entry to check ++ * @orig_node: the originator to search in the list +++ * @flags: a pointer to store TT flags for the given @entry received +++ * from @orig_node ++ * ++ * find out if an orig_node is already in the list of a tt_global_entry. ++ * ++@@ -1535,7 +1537,8 @@ batadv_tt_global_orig_entry_find(const struct batadv_tt_global_entry *entry, ++ */ ++ static bool ++ batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry, ++- const struct batadv_orig_node *orig_node) +++ const struct batadv_orig_node *orig_node, +++ u8 *flags) ++ { ++ struct batadv_tt_orig_list_entry *orig_entry; ++ bool found = false; ++@@ -1543,6 +1546,10 @@ batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry, ++ orig_entry = batadv_tt_global_orig_entry_find(entry, orig_node); ++ if (orig_entry) { ++ found = true; +++ +++ if (flags) +++ *flags = orig_entry->flags; +++ ++ batadv_tt_orig_list_entry_put(orig_entry); ++ } ++ ++@@ -1721,7 +1728,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, ++ if (!(common->flags & BATADV_TT_CLIENT_TEMP)) ++ goto out; ++ if (batadv_tt_global_entry_has_orig(tt_global_entry, ++- orig_node)) +++ orig_node, NULL)) ++ goto out_remove; ++ batadv_tt_global_del_orig_list(tt_global_entry); ++ goto add_orig_entry; ++@@ -2863,23 +2870,46 @@ batadv_tt_req_node_new(struct batadv_priv *bat_priv, ++ } ++ ++ /** ++- * batadv_tt_local_valid - verify that given tt entry is a valid one +++ * batadv_tt_local_valid() - verify local tt entry and get flags ++ * @entry_ptr: to be checked local tt entry ++ * @data_ptr: not used but definition required to satisfy the callback prototype +++ * @flags: a pointer to store TT flags for this client to +++ * +++ * Checks the validity of the given local TT entry. If it is, then the provided +++ * flags pointer is updated. ++ * ++ * Return: true if the entry is a valid, false otherwise. ++ */ ++-static bool batadv_tt_local_valid(const void *entry_ptr, const void *data_ptr) +++static bool batadv_tt_local_valid(const void *entry_ptr, +++ const void *data_ptr, +++ u8 *flags) ++ { ++ const struct batadv_tt_common_entry *tt_common_entry = entry_ptr; ++ ++ if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW) ++ return false; +++ +++ if (flags) +++ *flags = tt_common_entry->flags; +++ ++ return true; ++ } ++ +++/** +++ * batadv_tt_global_valid() - verify global tt entry and get flags +++ * @entry_ptr: to be checked global tt entry +++ * @data_ptr: an orig_node object (may be NULL) +++ * @flags: a pointer to store TT flags for this client to +++ * +++ * Checks the validity of the given global TT entry. If it is, then the provided +++ * flags pointer is updated either with the common (summed) TT flags if data_ptr +++ * is NULL or the specific, per originator TT flags otherwise. +++ * +++ * Return: true if the entry is a valid, false otherwise. +++ */ ++ static bool batadv_tt_global_valid(const void *entry_ptr, ++- const void *data_ptr) +++ const void *data_ptr, +++ u8 *flags) ++ { ++ const struct batadv_tt_common_entry *tt_common_entry = entry_ptr; ++ const struct batadv_tt_global_entry *tt_global_entry; ++@@ -2893,7 +2923,8 @@ static bool batadv_tt_global_valid(const void *entry_ptr, ++ struct batadv_tt_global_entry, ++ common); ++ ++- return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node); +++ return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node, +++ flags); ++ } ++ ++ /** ++@@ -2903,25 +2934,34 @@ static bool batadv_tt_global_valid(const void *entry_ptr, ++ * @hash: hash table containing the tt entries ++ * @tt_len: expected tvlv tt data buffer length in number of bytes ++ * @tvlv_buff: pointer to the buffer to fill with the TT data ++- * @valid_cb: function to filter tt change entries +++ * @valid_cb: function to filter tt change entries and to return TT flags ++ * @cb_data: data passed to the filter function as argument +++ * +++ * Fills the tvlv buff with the tt entries from the specified hash. If valid_cb +++ * is not provided then this becomes a no-op. ++ */ ++ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv, ++ struct batadv_hashtable *hash, ++ void *tvlv_buff, u16 tt_len, ++ bool (*valid_cb)(const void *, ++- const void *), +++ const void *, +++ u8 *flags), ++ void *cb_data) ++ { ++ struct batadv_tt_common_entry *tt_common_entry; ++ struct batadv_tvlv_tt_change *tt_change; ++ struct hlist_head *head; ++ u16 tt_tot, tt_num_entries = 0; +++ u8 flags; +++ bool ret; ++ u32 i; ++ ++ tt_tot = batadv_tt_entries(tt_len); ++ tt_change = (struct batadv_tvlv_tt_change *)tvlv_buff; ++ +++ if (!valid_cb) +++ return; +++ ++ rcu_read_lock(); ++ for (i = 0; i < hash->size; i++) { ++ head = &hash->table[i]; ++@@ -2931,11 +2971,12 @@ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv, ++ if (tt_tot == tt_num_entries) ++ break; ++ ++- if ((valid_cb) && (!valid_cb(tt_common_entry, cb_data))) +++ ret = valid_cb(tt_common_entry, cb_data, &flags); +++ if (!ret) ++ continue; ++ ++ ether_addr_copy(tt_change->addr, tt_common_entry->addr); ++- tt_change->flags = tt_common_entry->flags; +++ tt_change->flags = flags; ++ tt_change->vid = htons(tt_common_entry->vid); ++ memset(tt_change->reserved, 0, ++ sizeof(tt_change->reserved)); +diff --git a/batman-adv/patches/0021-batman-adv-prevent-TT-request-storms-by-not-sending-.patch b/batman-adv/patches/0021-batman-adv-prevent-TT-request-storms-by-not-sending-.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..c2a2c1fa0bcc84b76957891c535759725db92141 +--- /dev/null ++++ b/batman-adv/patches/0021-batman-adv-prevent-TT-request-storms-by-not-sending-.patch +@@ -0,0 +1,76 @@ ++From: Marek Lindner ++Date: Sat, 12 May 2018 00:23:07 +0800 ++Subject: [PATCH] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs ++ ++A translation table TVLV changset sent with an OGM consists ++of a number of headers (one per VLAN) plus the changeset ++itself (addition and/or deletion of entries). ++ ++The per-VLAN headers are used by OGM recipients for consistency ++checks. Said consistency check might determine that a full ++translation table request is needed to restore consistency. If ++the TT sender adds per-VLAN headers of empty VLANs into the OGM, ++recipients are led to believe to have reached an inconsistent ++state and thus request a full table update. The full table does ++not contain empty VLANs (due to missing entries) the cycle ++restarts when the next OGM is issued. ++ ++Consequently, when the translation table TVLV headers are ++composed, empty VLANs are to be excluded. ++ ++Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific") ++Signed-off-by: Marek Lindner ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/e4687b4be274da6180fc15b327419851fb681ec9 ++--- ++ net/batman-adv/translation-table.c | 15 ++++++++++++--- ++ 1 file changed, 12 insertions(+), 3 deletions(-) ++ ++diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c ++index af1bb290d22079fb55590c118de72a45b57a67ab..dc6a8912e0b0521f1510c5fd6f2579a39201f370 100644 ++--- a/net/batman-adv/translation-table.c +++++ b/net/batman-adv/translation-table.c ++@@ -929,15 +929,20 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, ++ struct batadv_tvlv_tt_vlan_data *tt_vlan; ++ struct batadv_softif_vlan *vlan; ++ u16 num_vlan = 0; ++- u16 num_entries = 0; +++ u16 vlan_entries = 0; +++ u16 total_entries = 0; ++ u16 tvlv_len; ++ u8 *tt_change_ptr; ++ int change_offset; ++ ++ spin_lock_bh(&bat_priv->softif_vlan_list_lock); ++ hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { +++ vlan_entries = atomic_read(&vlan->tt.num_entries); +++ if (vlan_entries < 1) +++ continue; +++ ++ num_vlan++; ++- num_entries += atomic_read(&vlan->tt.num_entries); +++ total_entries += vlan_entries; ++ } ++ ++ change_offset = sizeof(**tt_data); ++@@ -945,7 +950,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, ++ ++ /* if tt_len is negative, allocate the space needed by the full table */ ++ if (*tt_len < 0) ++- *tt_len = batadv_tt_len(num_entries); +++ *tt_len = batadv_tt_len(total_entries); ++ ++ tvlv_len = *tt_len; ++ tvlv_len += change_offset; ++@@ -962,6 +967,10 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, ++ ++ tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); ++ hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { +++ vlan_entries = atomic_read(&vlan->tt.num_entries); +++ if (vlan_entries < 1) +++ continue; +++ ++ tt_vlan->vid = htons(vlan->vid); ++ tt_vlan->crc = htonl(vlan->tt.crc); ++ +diff --git a/batman-adv/patches/0022-batman-adv-don-t-implement-skb_postpush_rcsum-for-li.patch b/batman-adv/patches/0022-batman-adv-don-t-implement-skb_postpush_rcsum-for-li.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..277ca7cbdd1eebfe690f2ba9aa439bf0abd07876 +--- /dev/null ++++ b/batman-adv/patches/0022-batman-adv-don-t-implement-skb_postpush_rcsum-for-li.patch +@@ -0,0 +1,29 @@ ++From: Antonio Quartulli ++Date: Sat, 12 May 2018 03:02:44 +0800 ++Subject: [PATCH] batman-adv: don't implement skb_postpush_rcsum() for linux >=4.4.47 ++ ++skb_postpush_rcsum() has been implemented in 4.4.47 therefore ++our compat code has to be changed to prevent this function to ++be implemented when using those kernels. ++ ++Signed-off-by: Antonio Quartulli ++Signed-off-by: Sven Eckelmann ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/b4693d107e0869bf11956fd2d3be4fd0a8671b46 ++--- ++ compat-include/linux/skbuff.h | 2 +- ++ 1 file changed, 1 insertion(+), 1 deletion(-) ++ ++diff --git a/compat-include/linux/skbuff.h b/compat-include/linux/skbuff.h ++index 65486ca6aad1ec31533e0b4bfa0b52396c0e1ddf..2938e8931ed7e094f509a77c29ccf309c3a02457 100644 ++--- a/compat-include/linux/skbuff.h +++++ b/compat-include/linux/skbuff.h ++@@ -76,7 +76,7 @@ struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb, ++ ++ #endif /* < KERNEL_VERSION(4, 2, 0) */ ++ ++-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) +++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 47) ++ ++ static inline void skb_postpush_rcsum(struct sk_buff *skb, ++ const void *start, unsigned int len) +diff --git a/batman-adv/patches/0023-batman-adv-Fix-bat_ogm_iv-best-gw-refcnt-after-netli.patch b/batman-adv/patches/0023-batman-adv-Fix-bat_ogm_iv-best-gw-refcnt-after-netli.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..821c53acc086d1f1fb7151b8726d14a795e39b8b +--- /dev/null ++++ b/batman-adv/patches/0023-batman-adv-Fix-bat_ogm_iv-best-gw-refcnt-after-netli.patch +@@ -0,0 +1,47 @@ ++From: Sven Eckelmann ++Date: Sat, 2 Jun 2018 17:26:34 +0200 ++Subject: [PATCH] batman-adv: Fix bat_ogm_iv best gw refcnt after netlink dump ++ ++A reference for the best gateway is taken when the list of gateways in the ++mesh is sent via netlink. This is necessary to check whether the currently ++dumped entry is the currently selected gateway or not. This information is ++then transferred as flag BATADV_ATTR_FLAG_BEST. ++ ++After the comparison of the current entry is done, ++batadv_iv_gw_dump_entry() has to decrease the reference counter again. ++Otherwise the reference will be held and thus prevents a proper shutdown of ++the batman-adv interfaces (and some of the interfaces enslaved in it). ++ ++Fixes: fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations") ++Reported-by: Andreas Ziegler ++Tested-by: Andreas Ziegler ++Signed-off-by: Sven Eckelmann ++Acked-by: Marek Lindner ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/46360d203c627e71a27d1f8f551c819c7f2353fd ++--- ++ net/batman-adv/bat_iv_ogm.c | 4 +++- ++ 1 file changed, 3 insertions(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c ++index 13b7da10114d26bacc3cd7af05a73ebdf0145ce7..81931a3bead9b1645b0a4234f5b489738e742995 100644 ++--- a/net/batman-adv/bat_iv_ogm.c +++++ b/net/batman-adv/bat_iv_ogm.c ++@@ -2722,7 +2722,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ++ { ++ struct batadv_neigh_ifinfo *router_ifinfo = NULL; ++ struct batadv_neigh_node *router; ++- struct batadv_gw_node *curr_gw; +++ struct batadv_gw_node *curr_gw = NULL; ++ int ret = 0; ++ void *hdr; ++ ++@@ -2770,6 +2770,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ++ ret = 0; ++ ++ out: +++ if (curr_gw) +++ batadv_gw_node_put(curr_gw); ++ if (router_ifinfo) ++ batadv_neigh_ifinfo_put(router_ifinfo); ++ if (router) +diff --git a/batman-adv/patches/0024-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch b/batman-adv/patches/0024-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..37a17b14628b7367cdf27ec48764fe76d4a50a7f +--- /dev/null ++++ b/batman-adv/patches/0024-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch +@@ -0,0 +1,45 @@ ++From: Sven Eckelmann ++Date: Sat, 2 Jun 2018 17:26:35 +0200 ++Subject: [PATCH] batman-adv: Fix bat_v best gw refcnt after netlink dump ++ ++A reference for the best gateway is taken when the list of gateways in the ++mesh is sent via netlink. This is necessary to check whether the currently ++dumped entry is the currently selected gateway or not. This information is ++then transferred as flag BATADV_ATTR_FLAG_BEST. ++ ++After the comparison of the current entry is done, ++batadv_v_gw_dump_entry() has to decrease the reference counter again. ++Otherwise the reference will be held and thus prevents a proper shutdown of ++the batman-adv interfaces (and some of the interfaces enslaved in it). ++ ++Fixes: 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations") ++Signed-off-by: Sven Eckelmann ++Acked-by: Marek Lindner ++ ++Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/2b422b5808183d1084b450b89d9a085a13dd6d2c ++--- ++ net/batman-adv/bat_v.c | 4 +++- ++ 1 file changed, 3 insertions(+), 1 deletion(-) ++ ++diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c ++index 73954b8be5dca6c72f34b3be236cac89562b3b74..2aa28ddd332ab7a45241579ff5c772bdcb1014c4 100644 ++--- a/net/batman-adv/bat_v.c +++++ b/net/batman-adv/bat_v.c ++@@ -929,7 +929,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ++ { ++ struct batadv_neigh_ifinfo *router_ifinfo = NULL; ++ struct batadv_neigh_node *router; ++- struct batadv_gw_node *curr_gw; +++ struct batadv_gw_node *curr_gw = NULL; ++ int ret = 0; ++ void *hdr; ++ ++@@ -997,6 +997,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ++ ret = 0; ++ ++ out: +++ if (curr_gw) +++ batadv_gw_node_put(curr_gw); ++ if (router_ifinfo) ++ batadv_neigh_ifinfo_put(router_ifinfo); ++ if (router) +diff --git a/batman-adv/patches/0025-batman-adv-Fix-debugfs-path-for-renamed-hardif.patch b/batman-adv/patches/0025-batman-adv-Fix-debugfs-path-for-renamed-hardif.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..55a5ff62186b16146408fbac96e020e75ecccf1c +--- /dev/null ++++ b/batman-adv/patches/0025-batman-adv-Fix-debugfs-path-for-renamed-hardif.patch +@@ -0,0 +1,111 @@ ++From: Sven Eckelmann ++Date: Fri, 1 Jun 2018 19:24:23 +0200 ++Subject: [PATCH] batman-adv: Fix debugfs path for renamed hardif ++ ++batman-adv is creating special debugfs directories in the init ++net_namespace for each valid hard-interface (net_device). But it is ++possible to rename a net_device to a completely different name then the ++original one. ++ ++It can therefore happen that a user registers a new net_device which gets ++the name "wlan0" assigned by default. batman-adv is also adding a new ++directory under $debugfs/batman-adv/ with the name "wlan0". ++ ++The user then decides to rename this device to "wl_pri" and registers a ++different device. The kernel may now decide to use the name "wlan0" again ++for this new device. batman-adv will detect it as a valid net_device and ++tries to create a directory with the name "wlan0" under ++$debugfs/batman-adv/. But there already exists one with this name under ++this path and thus this fails. batman-adv will detect a problem and ++rollback the registering of this device. ++ ++batman-adv must therefore take care of renaming the debugfs directories ++for hard-interfaces whenever it detects such a net_device rename. ++ ++Fixes: 3c926a01c8e8 ("batman-adv: add debugfs structure for information per interface") ++Reported-by: John Soros ++Signed-off-by: Sven Eckelmann ++ ++Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/127086f503f6495518b95455efebee33d328f335 ++--- ++ net/batman-adv/debugfs.c | 20 ++++++++++++++++++++ ++ net/batman-adv/debugfs.h | 6 ++++++ ++ net/batman-adv/hard-interface.c | 3 +++ ++ 3 files changed, 29 insertions(+) ++ ++diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c ++index e32ad47c6efdf17914aad1e89029020d15801150..002028887286203ed60efb05770ecf7bf8ac5772 100644 ++--- a/net/batman-adv/debugfs.c +++++ b/net/batman-adv/debugfs.c ++@@ -18,6 +18,7 @@ ++ #include "debugfs.h" ++ #include "main.h" ++ +++#include ++ #include ++ #include ++ #include ++@@ -337,6 +338,25 @@ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface) ++ return -ENOMEM; ++ } ++ +++/** +++ * batadv_debugfs_rename_hardif() - Fix debugfs path for renamed hardif +++ * @hard_iface: hard interface which was renamed +++ */ +++void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface) +++{ +++ const char *name = hard_iface->net_dev->name; +++ struct dentry *dir; +++ struct dentry *d; +++ +++ dir = hard_iface->debug_dir; +++ if (!dir) +++ return; +++ +++ d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name); +++ if (!d) +++ pr_err("Can't rename debugfs dir to %s\n", name); +++} +++ ++ /** ++ * batadv_debugfs_del_hardif - delete the base directory for a hard interface ++ * in debugfs. ++diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h ++index 9c5d4a65b98c35239709d9258bb889a61ffef8c2..295e1114681800b31f3975a7e3a747e4976fedbe 100644 ++--- a/net/batman-adv/debugfs.h +++++ b/net/batman-adv/debugfs.h ++@@ -31,6 +31,7 @@ void batadv_debugfs_destroy(void); ++ int batadv_debugfs_add_meshif(struct net_device *dev); ++ void batadv_debugfs_del_meshif(struct net_device *dev); ++ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface); +++void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface); ++ void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface); ++ ++ #else ++@@ -58,6 +59,11 @@ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface) ++ return 0; ++ } ++ +++static inline +++void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface) +++{ +++} +++ ++ static inline ++ void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface) ++ { ++diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c ++index 69f1704fcaa4e980dfadcbb943db43544763d469..bab747ad49cacb6d3eb328fcd359970960b61965 100644 ++--- a/net/batman-adv/hard-interface.c +++++ b/net/batman-adv/hard-interface.c ++@@ -1016,6 +1016,9 @@ static int batadv_hard_if_event(struct notifier_block *this, ++ if (batadv_is_wifi_hardif(hard_iface)) ++ hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; ++ break; +++ case NETDEV_CHANGENAME: +++ batadv_debugfs_rename_hardif(hard_iface); +++ break; ++ default: ++ break; ++ } +diff --git a/batman-adv/patches/0026-batman-adv-Fix-debugfs-path-for-renamed-softif.patch b/batman-adv/patches/0026-batman-adv-Fix-debugfs-path-for-renamed-softif.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..0fba8a04b0d86541d31afa3d9a32377d4823e89d +--- /dev/null ++++ b/batman-adv/patches/0026-batman-adv-Fix-debugfs-path-for-renamed-softif.patch +@@ -0,0 +1,139 @@ ++From: Sven Eckelmann ++Date: Fri, 1 Jun 2018 19:24:24 +0200 ++Subject: [PATCH] batman-adv: Fix debugfs path for renamed softif ++ ++batman-adv is creating special debugfs directories in the init ++net_namespace for each created soft-interface (batadv net_device). But it ++is possible to rename a net_device to a completely different name then the ++original one. ++ ++It can therefore happen that a user registers a new batadv net_device with ++the name "bat0". batman-adv is then also adding a new directory under ++$debugfs/batman-adv/ with the name "wlan0". ++ ++The user then decides to rename this device to "bat1" and registers a ++different batadv device with the name "bat0". batman-adv will then try to ++create a directory with the name "bat0" under $debugfs/batman-adv/ again. ++But there already exists one with this name under this path and thus this ++fails. batman-adv will detect a problem and rollback the registering of ++this device. ++ ++batman-adv must therefore take care of renaming the debugfs directories for ++soft-interfaces whenever it detects such a net_device rename. ++ ++Fixes: 230202d4b530 ("batman-adv: Move device for icmp injection to debugfs") ++Signed-off-by: Sven Eckelmann ++ ++Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/3f2237bb191cd17654a4d5a5badfd6e7379c4b37 ++--- ++ net/batman-adv/debugfs.c | 20 +++++++++++++++++++ ++ net/batman-adv/debugfs.h | 5 +++++ ++ net/batman-adv/hard-interface.c | 34 +++++++++++++++++++++++++++------ ++ 3 files changed, 53 insertions(+), 6 deletions(-) ++ ++diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c ++index 002028887286203ed60efb05770ecf7bf8ac5772..44d3a3ecc4aa589f2207c6234cdd6ed495c146cc 100644 ++--- a/net/batman-adv/debugfs.c +++++ b/net/batman-adv/debugfs.c ++@@ -421,6 +421,26 @@ int batadv_debugfs_add_meshif(struct net_device *dev) ++ return -ENOMEM; ++ } ++ +++/** +++ * batadv_debugfs_rename_meshif() - Fix debugfs path for renamed softif +++ * @dev: net_device which was renamed +++ */ +++void batadv_debugfs_rename_meshif(struct net_device *dev) +++{ +++ struct batadv_priv *bat_priv = netdev_priv(dev); +++ const char *name = dev->name; +++ struct dentry *dir; +++ struct dentry *d; +++ +++ dir = bat_priv->debug_dir; +++ if (!dir) +++ return; +++ +++ d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name); +++ if (!d) +++ pr_err("Can't rename debugfs dir to %s\n", name); +++} +++ ++ void batadv_debugfs_del_meshif(struct net_device *dev) ++ { ++ struct batadv_priv *bat_priv = netdev_priv(dev); ++diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h ++index 295e1114681800b31f3975a7e3a747e4976fedbe..901bbc357bf42e5c471e50ee5cd4cf42df7e26dc 100644 ++--- a/net/batman-adv/debugfs.h +++++ b/net/batman-adv/debugfs.h ++@@ -29,6 +29,7 @@ struct net_device; ++ void batadv_debugfs_init(void); ++ void batadv_debugfs_destroy(void); ++ int batadv_debugfs_add_meshif(struct net_device *dev); +++void batadv_debugfs_rename_meshif(struct net_device *dev); ++ void batadv_debugfs_del_meshif(struct net_device *dev); ++ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface); ++ void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface); ++@@ -49,6 +50,10 @@ static inline int batadv_debugfs_add_meshif(struct net_device *dev) ++ return 0; ++ } ++ +++static inline void batadv_debugfs_rename_meshif(struct net_device *dev) +++{ +++} +++ ++ static inline void batadv_debugfs_del_meshif(struct net_device *dev) ++ { ++ } ++diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c ++index bab747ad49cacb6d3eb328fcd359970960b61965..51a75d9e3b7ac9bdbdddeaed45ce620517b8a588 100644 ++--- a/net/batman-adv/hard-interface.c +++++ b/net/batman-adv/hard-interface.c ++@@ -954,6 +954,32 @@ void batadv_hardif_remove_interfaces(void) ++ rtnl_unlock(); ++ } ++ +++/** +++ * batadv_hard_if_event_softif() - Handle events for soft interfaces +++ * @event: NETDEV_* event to handle +++ * @net_dev: net_device which generated an event +++ * +++ * Return: NOTIFY_* result +++ */ +++static int batadv_hard_if_event_softif(unsigned long event, +++ struct net_device *net_dev) +++{ +++ struct batadv_priv *bat_priv; +++ +++ switch (event) { +++ case NETDEV_REGISTER: +++ batadv_sysfs_add_meshif(net_dev); +++ bat_priv = netdev_priv(net_dev); +++ batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS); +++ break; +++ case NETDEV_CHANGENAME: +++ batadv_debugfs_rename_meshif(net_dev); +++ break; +++ } +++ +++ return NOTIFY_DONE; +++} +++ ++ static int batadv_hard_if_event(struct notifier_block *this, ++ unsigned long event, void *ptr) ++ { ++@@ -962,12 +988,8 @@ static int batadv_hard_if_event(struct notifier_block *this, ++ struct batadv_hard_iface *primary_if = NULL; ++ struct batadv_priv *bat_priv; ++ ++- if (batadv_softif_is_valid(net_dev) && event == NETDEV_REGISTER) { ++- batadv_sysfs_add_meshif(net_dev); ++- bat_priv = netdev_priv(net_dev); ++- batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS); ++- return NOTIFY_DONE; ++- } +++ if (batadv_softif_is_valid(net_dev)) +++ return batadv_hard_if_event_softif(event, net_dev); ++ ++ hard_iface = batadv_hardif_get_by_netdev(net_dev); ++ if (!hard_iface && (event == NETDEV_REGISTER ||