Skip to content

Commit 135075a

Browse files
ecsvgregkh
authored andcommitted
batman-adv: Use explicit tvlv padding for ELP packets
commit f4156f9 upstream. The announcement messages of batman-adv COMPAT_VERSION 15 have the possibility to announce additional information via a dynamic TVLV part. This part is optional for the ELP packets and currently not parsed by the Linux implementation. Still out-of-tree versions are using it to transport things like neighbor hashes to optimize the rebroadcast behavior. Since the ELP broadcast packets are smaller than the minimal ethernet packet, it often has to be padded. This is often done (as specified in RFC894) with octets of zero and thus work perfectly fine with the TVLV part (making it a zero length and thus empty). But not all ethernet compatible hardware seems to follow this advice. To avoid ambiguous situations when parsing the TVLV header, just force the 4 bytes (TVLV length + padding) after the required ELP header to zero. Fixes: d6f94d9 ("batman-adv: ELP - adding basic infrastructure") Reported-by: Linus Lüssing <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 34673c2 commit 135075a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/batman-adv/bat_v_elp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,23 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
335335
*/
336336
int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
337337
{
338+
static const size_t tvlv_padding = sizeof(__be32);
338339
struct batadv_elp_packet *elp_packet;
339340
unsigned char *elp_buff;
340341
u32 random_seqno;
341342
size_t size;
342343
int res = -ENOMEM;
343344

344-
size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN;
345+
size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN + tvlv_padding;
345346
hard_iface->bat_v.elp_skb = dev_alloc_skb(size);
346347
if (!hard_iface->bat_v.elp_skb)
347348
goto out;
348349

349350
skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
350-
elp_buff = skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
351+
elp_buff = skb_put(hard_iface->bat_v.elp_skb,
352+
BATADV_ELP_HLEN + tvlv_padding);
351353
elp_packet = (struct batadv_elp_packet *)elp_buff;
352-
memset(elp_packet, 0, BATADV_ELP_HLEN);
354+
memset(elp_packet, 0, BATADV_ELP_HLEN + tvlv_padding);
353355

354356
elp_packet->packet_type = BATADV_ELP;
355357
elp_packet->version = BATADV_COMPAT_VERSION;

0 commit comments

Comments
 (0)