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 <mschiffer(a)universe-factory.net>
Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
Cc: Matthias Schiffer <mschiffer(a)universe-factory.net>
This is an alternative fix for the problem reported by Matthias and his
patch https://patchwork.open-mesh.org/patch/17305/. I've prepared it
because I don't feel good about fixing one thing and at the same time add
regression to another thing (even when it is only the debug output for arp
packets) - at least not when this patch should end up at
stable(a)vger.kernel.org
This patch was not actually tested. But it should help to see a different
approach. Other code in the kernel which does something similar is:
* seg6_do_srh_inline
* set_eth_addr (openvswitch)
* set_nsh (openvswitch)
I would still like to merge the cleanup patches from Matthias - just not
for net.git/stable(a)vger.kernel.org. Maybe Simon can decide about the maint
patch - at least he will be the one who forwards them to DaveM.
Btw. in theory, only ttl+ttvn+dest have to be read to update the checksum
correctly - but this patch also reads packet_type+version to keep the
change simple.
---
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 1983dbeb..6f739464 100644
--- a/compat-include/linux/skbuff.h
+++ b/compat-include/linux/skbuff.h
@@ -77,6 +77,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 3827f5c7..30fbfbfb 100644
--- a/compat-sources/net/core/skbuff.c
+++ b/compat-sources/net/core/skbuff.c
@@ -93,23 +93,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 0f10c565..cc3ed93a 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -759,6 +759,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
@@ -770,7 +771,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)
{
@@ -799,8 +800,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:
@@ -841,7 +844,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,
@@ -887,7 +890,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",
@@ -910,12 +913,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;
}
--
2.16.2
This patchset adds netlink support for dumping DAT cache and multicast
flags tables.
Changes in v3:
==============
- renamed netlink attributes:
- BATADV_ATTR_DC_ADDRESS -> BATADV_ATTR_DAT_CACHE_IP4ADDRESS
- BATADV_ATTR_DC_HWADDRESS -> BATADV_ATTR_DAT_CACHE_HWADDRESS
- BATADV_ATTR_DC_VID -> BATADV_ATTR_DAT_CACHE_VID
Changes in v2:
==============
- Removed htonl() conversion for BATADV_ATTR_DC_ADDRESS as batman-adv
now provides it in network byte order (via nla_put_in_addr() )
- Increased BATADV_ATTR_MCAST_FLAGS and BATADV_ATTR_MCAST_FLAGS_PRIV
size from 8 to 32 bits to enhance extensibility
- Changed mcast_flags error value from -EINVAL to -ENOTSUPP to allow
a fallback to and retry via debugfs, for compatibility with older
batman-adv versions
This patchset adds netlink support for dumping DAT cache and multicast
flags tables.
Changes in v3:
==============
- renamed netlink attributes:
- BATADV_ATTR_DC_ADDRESS -> BATADV_ATTR_DAT_CACHE_IP4ADDRESS
- BATADV_ATTR_DC_HWADDRESS -> BATADV_ATTR_DAT_CACHE_HWADDRESS
- BATADV_ATTR_DC_VID -> BATADV_ATTR_DAT_CACHE_VID
Changes in v2:
==============
- Added missing includes, "#include <linux/netlink.h>" and
"#include <uapi/linux/batman_adv.h>", to distributed-arp-table.c
- Added missing forward declaration for "struct netlink_callback" to
distributed-arp-table.h
- Changed nla_put_u32() to nla_put_in_addr() for BATADV_ATTR_DC_ADDRESS,
removed the then obsolete ntohl() conversion
- Added missing include, "#include <linux/netlink.h>", to multicast.c
- Changed nla_put_u8() to nla_put_u32() for BATADV_ATTR_MCAST_FLAGS and
BATADV_ATTR_MCAST_FLAGS_PRIV to enhance extensibility
This patchset adds netlink support for dumping DAT cache and multicast
flags tables.
Changes in v2:
==============
- Added missing includes, "#include <linux/netlink.h>" and
"#include <uapi/linux/batman_adv.h>", to distributed-arp-table.c
- Added missing forward declaration for "struct netlink_callback" to
distributed-arp-table.h
- Changed nla_put_u32() to nla_put_in_addr() for BATADV_ATTR_DC_ADDRESS,
removed the then obsolete ntohl() conversion
- Added missing include, "#include <linux/netlink.h>", to multicast.c
- Changed nla_put_u8() to nla_put_u32() for BATADV_ATTR_MCAST_FLAGS and
BATADV_ATTR_MCAST_FLAGS_PRIV to enhance extensibility
Let's meet in Berlin in May :)
---------- Forwarded Message ----------
Subject: [Battlemesh] Mesh is in the air! - 7th-13th of May 2018, Berlin,
Germany
Date: Friday, March 9, 2018, 10:13:56 PM CET
From: Monic Meisel <monic(a)monic.de>
To: Battle of the Mesh Mailing List <battlemesh(a)ml.ninux.org>
Dear fellow Battlemesh enthusiasts,
The Wireless Battle of the Mesh v11 (#WBMv11) and the Wireless Community
Weekend 2018 (#FFWCW18) will be meshed up and co-located in Berlin from May 07
to May 13, 2018.
Since it is the 15th anniversary of the WCW, friends and fellows from across
the globe celebrate together wireless mesh network technologies and ideas of
community networking.
You can expect to meet with tech experts in mesh technologies, policy
discussions, talks, hands on workshops, late night hacking sessions,
measurement campaigns and an ongoing barbeque at the riverside. If you are a
mesh networking enthusiast, community activist, or simply have an interest in
wifi or dynamic routing protocols, you can't miss this event!
So check out our continuously updated information about the event at https://
www.wireless-meshup.org
Location
=======
We are meeting at the c-base space station, 3 minutes from public transport S
+U Jannowitzbrücke in the heart of Berlin.
There you will find the main hall with the bar for presentations, discussions
and hacking, a seminar room for up to 15 for workshops, two spaces for a
smaller groups in the basement and upper floor and not at least the fully
equipped riverside with powersockets, light close to the grill station. For
the weekend we booked another room for presentations at European Theater
Institute right next door to the seminar room.
You will find yourself at Berlins most famous hackspace, where you can use
repair and assembling shops as well as meeting with berlins net activists and
hacker scene. freifunk.net is available, since the roof top node is part of
the BerlinBackBone.
Taking part and Registration
=====================
It helps the organizers, if you add yourself early to the wiki page under
https://www.wireless-meshup.org/ and provide your meal prefernces and t-shirt
size, in case you want one. Start preparing your presentation, lightening
talk, workshop, idea, announcement or open space you want to run. The event is
*free of charge*, but contributions are very welcome, so please have a look at
the supporters page as well, thanks in advance.
Accommodation Offering
===================
For those of you who are looking for a convenient accommodation option: we
have made block reservation for 50 beds in a nice hostel 15 min walking
distance or one station by public transport. The packages include 7 nights in
a three or four-bed room incl. breakfast - for 33,00 EUR p.P/Night incl.
Breakfast
Valid for:
07.05.2018 - 13.05.2018
50 Beds are reserved until 23.03.2018
25 Beds are reserved until 05.04.2018
Payment at checkin - using cash or creditcard
IMPORTANT: Booking with this special price is only possible by mail
ap(a)meininger-hotels.com or phone +493031879767
Stating that you want to stay at “EastSideGallery” mention the Keyword: MESH
Booked Rooms will be held until 6pm on arrival day - please let them know when
you arrive later.
Catering and Social Events
=====================
There will be catering at dinner time and free coffee the whole time.
Beverages can be bought at the bar, closeby kiosk or brought with you.
Some jaunts and social events are in planning, but will be announced later.
Spread the Word
=============
Please help us spreading the word by forwarding this to all lists and people
that might be interested. Blogging about it is also very appreciated, and if
you do so, please add a ping-back to the wiki page: https://www.wireless-meshup.org
We will also start the endorsements process within some weeks. If your
community/organization would like to help and support us, please check
supporters page.
Organizers Team Contact
====================
The local core team consists of Monic, Andi, Cven and others from freifunk and
c-base community.
The mentors team consists of Claudio, Filipe and Paul.
You can reach us under organizers(a)wireless-meshup.org
Hope to see you soon!
Best wishes from the org-team
-----------------------------------------
This patchset adds netlink support for dumping DAT cache and multicast
flags tables.
Changes in v2:
==============
- Removed htonl() conversion for BATADV_ATTR_DC_ADDRESS as batman-adv
now provides it in network byte order (via nla_put_in_addr() )
- Increased BATADV_ATTR_MCAST_FLAGS and BATADV_ATTR_MCAST_FLAGS_PRIV
size from 8 to 32 bits to enhance extensibility
- Changed mcast_flags error value from -EINVAL to -ENOTSUPP to allow
a fallback to and retry via debugfs, for compatibility with older
batman-adv versions
Hello Sven Eckelmann,
The patch 011c935fceae: "batman-adv: Ignore invalid batadv_v_gw
during netlink send" from Feb 19, 2018, leads to the following static
checker warning:
net/batman-adv/bat_iv_ogm.c:2745 batadv_iv_gw_dump_entry()
warn: missing error code here? 'batadv_neigh_ifinfo_get()' failed. 'ret' = '0'
net/batman-adv/bat_iv_ogm.c
2719 /**
2720 * batadv_iv_gw_dump_entry() - Dump a gateway into a message
2721 * @msg: Netlink message to dump into
2722 * @portid: Port making netlink request
2723 * @seq: Sequence number of netlink message
2724 * @bat_priv: The bat priv with all the soft interface information
2725 * @gw_node: Gateway to be dumped
2726 *
2727 * Return: Error code, or 0 on success
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is sort of out of date.
2728 */
2729 static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
2730 struct batadv_priv *bat_priv,
2731 struct batadv_gw_node *gw_node)
2732 {
2733 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
2734 struct batadv_neigh_node *router;
2735 struct batadv_gw_node *curr_gw;
2736 int ret = 0;
2737 void *hdr;
2738
2739 router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT);
2740 if (!router)
2741 goto out;
^^^^^^^^
2742
2743 router_ifinfo = batadv_neigh_ifinfo_get(router, BATADV_IF_DEFAULT);
2744 if (!router_ifinfo)
2745 goto out;
^^^^^^^^
These two were obviously changed from -EINVAL to 0 intentionally, but it
causes a static checker warning. What really helps me when I'm
reviewing error codes is if they're explicit:
if (!router_ifinfo) {
ret = 0;
goto out;
}
2746
2747 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
2748
2749 hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family,
2750 NLM_F_MULTI, BATADV_CMD_GET_GATEWAYS);
2751 if (!hdr) {
2752 ret = -ENOBUFS;
^^^^^^^^^^^^^^
The commit message sort of implies that only -EMSGSIZE and 0 are valid
returns but -ENOBUFS is also valid.
2753 goto out;
2754 }
2755
2756 ret = -EMSGSIZE;
^^^^^^^^^^^^^^^
2757
2758 if (curr_gw == gw_node)
2759 if (nla_put_flag(msg, BATADV_ATTR_FLAG_BEST)) {
2760 genlmsg_cancel(msg, hdr);
2761 goto out;
2762 }
2763
Anyway, the code seems fine and I've marked it as a false positive so
it doesn't really require any action from you. I just wanted you to
know my thinking here.
regards,
dan carpenter
[Please try to not contact me directly when it is about B.A.T.M.A.N. related
things and at least Cc the official mailing list]
On Montag, 5. März 2018 19:04:29 CET Paul Becue wrote:
> We are working on a device with a mesh network. We are doing tests with
> WiFi ad-hoc networks, and we tested last week BATMAN-adv and also babeld
> on a Raspberry Pi 3 with a Ralink dongle attached to it. The results
> were very good.
[..]
> Could you give me some hints where I have to look for hardware and what
> kind of hardware I have to look for? I have the impression that there is
> something that I don't see in the whole story. I hope ad-hoc WiFi is
> still a technology that is up to date. Or is there a technology that
> replaces it?
Yes, IBSS is becoming a problem at the moment. You can try QCA ath10k hardware
with Ben Greears firmware [1] or Mediathek with the mt76 driver [2] when you
want up-to-date HW. There is still some ath9k based stuff around when 802.11n
is enough.
Otherwise you might try to replace IBSS with meshpoint interfaces. Just setup
it like 802.11s but with forwarding disabled [3]. This works at least with
ath10k based HW and the official QCA ath10k firmware.
But HW which uses ath10k and other things which uses special firmware which
prevents you from using your "own" rate control algorith are a no-go when
you want to use throughput based metrics (as in B.A.T.M.A.N. V or olsrd2).
Then you should stick either with ath9k or mt76 compatible HW.
Btw. my tests of mt76 showed performance and stability problems in the past.
This may have changed by recent fixes in the driver but I don't know the
current state.
Kind regards,
Sven
[1] https://www.candelatech.com/ath10k.php
[2] https://github.com/openwrt/mt76
[3] http://openwrt-devel.openwrt.narkive.com/Bieu1aRR/ath10k-mesh-with-openwrt-…