[commits] [batman-adv] next: batman-adv: dirty hack to recompute mac_len in the rx path (a6ad857)

postmaster at open-mesh.org postmaster at open-mesh.org
Sun Oct 14 20:53:06 CEST 2012


Repository : ssh://git@open-mesh.org/batman-adv

On branch  : next

>---------------------------------------------------------------

commit a6ad8574ea13f3463bae39324d093e6c31682cc8
Author: Simon Wunderlich <simon.wunderlich at s2003.tu-chemnitz.de>
Date:   Sun Oct 14 14:46:57 2012 +0200

    batman-adv: dirty hack to recompute mac_len in the rx path
    
    It is possible that the mac_len is not properly exported because of
    strange device configuration (this behaviour has been observed when
    using batman-adv on top of a vlan interface). Therefore it is needed to
    explicitly recompute it at the very beginning of the rx path.
    
    This is done by appending the recompute function to the skb_share_mac()
    function, hence the "dirty hack" in the subject. We expect this problem to
    be fixed in linux 3.8 and above.
    
    Reported-by: Antonio Quartulli <ordex at autistici.org>
    Signed-off-by: Simon Wunderlich <siwu at hrz.tu-chemnitz.de>
    Signed-off-by: Marek Lindner <lindner_marek at yahoo.de>


>---------------------------------------------------------------

a6ad8574ea13f3463bae39324d093e6c31682cc8
 compat.h |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/compat.h b/compat.h
index 13253dd..081bef5 100644
--- a/compat.h
+++ b/compat.h
@@ -145,6 +145,11 @@ void batadv_free_rcu_neigh_node(struct rcu_head *rcu);
 void batadv_free_rcu_tt_local_entry(struct rcu_head *rcu);
 void batadv_free_rcu_backbone_gw(struct rcu_head *rcu);
 
+static inline void skb_reset_mac_len(struct sk_buff *skb)
+{
+	skb->mac_len = skb->network_header - skb->mac_header;
+}
+
 #endif /* < KERNEL_VERSION(3, 0, 0) */
 
 
@@ -157,4 +162,23 @@ static inline void eth_hw_addr_random(struct net_device *dev)
 
 #endif /* < KERNEL_VERSION(3, 4, 0) */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
+
+/* hack for not correctly set mac_len. This may happen for some special
+ * configurations like batman-adv on VLANs.
+ *
+ * This is pretty dirty, but we only use skb_share_check() in main.c right
+ * before mac_len is checked, and the recomputation shouldn't hurt too much.
+ */
+#define skb_share_check(skb, b) \
+	({ \
+		struct sk_buff *_t_skb; \
+		_t_skb = skb_share_check(skb, b); \
+		if (_t_skb) \
+			skb_reset_mac_len(_t_skb); \
+		_t_skb; \
+	})
+
+#endif /* < KERNEL_VERSION(3, 8, 0) */
+
 #endif /* _NET_BATMAN_ADV_COMPAT_H_ */



More information about the commits mailing list