Skip to contentSkip to conversation

batman-adv: properly push NET_IP_ALIGN bytes more

PATCH In review Antonio Quartulli 1 participant 2 messages Apr 2, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: properly push NET_IP_ALIGN bytes more

From: Antonio Quartulli <[email protected]>

every batman-adv encapsulated packet is supposed to begin with an Ethernet header plus 2 bytes for correct alignment on 4 bytes boundary.

However, even if allocations are made correctly, the final encapsulation is not made properly since the encapsulating function does not push NET_IP_ALIGN bytes other than ETH_HLEN.

Fix it by pushing the correct amount of bytes.

Introduced by 7f91790974c258e71a62f6dee8cb1dbe5dff36c3 ("batman-adv: Reserve extra bytes in skb for better alignment")

---

Please review this patch as I am not 100% sure this is correct. What I understood is that any batman-adv should have this shape:

+--------------+
| ETH_HEADER   |
|              |
+--------------+
| NET_IP_ALIGN |
+--------------+
| BATADV_HEADER|
+--------------+
| ...          |

but by pushing ETH_HLEN only, we end up in a shorter packet, because the head pointer is not moved up enough to contain the NET_IP_ALIGN bytes too (so we are back to the situation where our headers are not properly placed in memory).

Cheers,

 send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
send.c +1 -1
index a67cffd..a338093 100644
@@ -54,7 +54,7 @@ int batadv_send_skb_packet(struct sk_buff *skb,
 	}
 
 	/* push to the ethernet header. */
-	if (batadv_skb_head_push(skb, ETH_HLEN) < 0)
+	if (batadv_skb_head_push(skb, ETH_HLEN + NET_IP_ALIGN) < 0)
 		goto send_skb_err;
 
 	skb_reset_mac_header(skb);
Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 11 lines · Antonio Quartulli

From: Antonio Quartulli <[email protected]>

every batman-adv encapsulated packet is supposed to begin with an Ethernet header plus 2 bytes for correct alignment on 4 bytes boundary.

However, even if allocations are made correctly, the final encapsulation is not made properly since the encapsulating function does not push NET_IP_ALIGN bytes other than ETH_HLEN.

Quoted 6 lines

Fix it by pushing the correct amount of bytes.

Introduced by 7f91790974c258e71a62f6dee8cb1dbe5dff36c3 ("batman-adv: Reserve extra bytes in skb for better alignment")

This patch can be dropped.
We don't want to send those two extra bytes, we use them only for local memory alignment.

Sorry about that.

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara