batman-adv: Merge bugfixes from 2018.4
[feed/routing.git] / batman-adv / patches / 0022-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: upstream, https://git.open-mesh.org/batman-adv.git/commit/974337ee9773c4bd0a2d5c322306cf2bea445e11
24 ---
25 net/batman-adv/bat_v_elp.c | 6 ++++--
26 1 file changed, 4 insertions(+), 2 deletions(-)
27
28 diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
29 index 83b46654449df72ceda6ca3177f72e7faf0603ab..9aa3c7b2e9bad6c50b2939b6dbf5a9a2e713b93b 100644
30 --- a/net/batman-adv/bat_v_elp.c
31 +++ b/net/batman-adv/bat_v_elp.c
32 @@ -339,19 +339,21 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
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_zero(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
51 + elp_buff = skb_put_zero(hard_iface->bat_v.elp_skb,
52 + BATADV_ELP_HLEN + tvlv_padding);
53 elp_packet = (struct batadv_elp_packet *)elp_buff;
54
55 elp_packet->packet_type = BATADV_ELP;