Merge pull request #443 from ecsv/batadv-17.01
[feed/routing.git] / batman-adv / patches / 0056-batman-adv-Use-explicit-tvlv-padding-for-ELP-packets.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Tue, 30 Oct 2018 12:17:10 +0100
3 Subject: [PATCH] batman-adv: Use explicit tvlv padding for ELP packets
4
5 The announcement messages of batman-adv COMPAT_VERSION 15 have the
6 possibility to announce additional information via a dynamic TVLV part.
7 This part is optional for the ELP packets and currently not parsed by the
8 Linux implementation. Still out-of-tree versions are using it to transport
9 things like neighbor hashes to optimize the rebroadcast behavior.
10
11 Since the ELP broadcast packets are smaller than the minimal ethernet
12 packet, it often has to be padded. This is often done (as specified in
13 RFC894) with octets of zero and thus work perfectly fine with the TVLV
14 part (making it a zero length and thus empty). But not all ethernet
15 compatible hardware seems to follow this advice. To avoid ambiguous
16 situations when parsing the TVLV header, just force the 4 bytes (TVLV
17 length + padding) after the required ELP header to zero.
18
19 Fixes: a4b88af77e28 ("batman-adv: ELP - adding basic infrastructure")
20 Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
21 Signed-off-by: Sven Eckelmann <sven@narfation.org>
22
23 Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/974337ee9773c4bd0a2d5c322306cf2bea445e11
24 ---
25 net/batman-adv/bat_v_elp.c | 8 +++++---
26 1 file changed, 5 insertions(+), 3 deletions(-)
27
28 diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
29 index 2ec0ecab0493ff88fdc01e55c8557de5b772e8bf..08c0809fca7de1fe51727652a2e870ddfa74dc13 100644
30 --- a/net/batman-adv/bat_v_elp.c
31 +++ b/net/batman-adv/bat_v_elp.c
32 @@ -338,21 +338,23 @@ out:
33 */
34 int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
35 {
36 + static const size_t tvlv_padding = sizeof(__be32);
37 struct batadv_elp_packet *elp_packet;
38 unsigned char *elp_buff;
39 u32 random_seqno;
40 size_t size;
41 int res = -ENOMEM;
42
43 - size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN;
44 + size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN + tvlv_padding;
45 hard_iface->bat_v.elp_skb = dev_alloc_skb(size);
46 if (!hard_iface->bat_v.elp_skb)
47 goto out;
48
49 skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
50 - elp_buff = skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
51 + elp_buff = skb_put(hard_iface->bat_v.elp_skb,
52 + BATADV_ELP_HLEN + tvlv_padding);
53 elp_packet = (struct batadv_elp_packet *)elp_buff;
54 - memset(elp_packet, 0, BATADV_ELP_HLEN);
55 + memset(elp_packet, 0, BATADV_ELP_HLEN + tvlv_padding);
56
57 elp_packet->packet_type = BATADV_ELP;
58 elp_packet->version = BATADV_COMPAT_VERSION;