public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH (maint?) 1/3] batamn-adv: fix elp packet data reservation
@ 2016-08-21  3:25 Linus Lüssing
  2016-08-21  3:25 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: elp: skb network header API instead of skb->data access Linus Lüssing
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Linus Lüssing @ 2016-08-21  3:25 UTC (permalink / raw)
  To: b.a.t.m.a.n

The skb_reserve() call only reserved headroom for the mac header, but
not the elp packet header itself.

Fixing this by using skb_put()'ing towards the skb tail instead of
skb_push()'ing towards the skb head.

Fixes: a4b88af77e28 ("batman-adv: ELP - adding basic infrastructure")
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>

---

Looking at some tests today, we might have been lucky so far:
dev_alloc_skb(size = 32) seems to actually round the head- and tailroom
reservation to 64 bytes. So there actually is enough headroom for the
skb_push(). Not sure whether this is always the case though, so
unsure whether this should go to maint/stable.

Also switching skb_push() with skb_pull() instead of simply increasing
skb_reserve() by ELP_HLEN, because of the next patch in this series.
---
 net/batman-adv/bat_v_elp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index df42eb1..ea463bf 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -323,7 +323,6 @@ out:
 int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
 {
 	struct batadv_elp_packet *elp_packet;
-	unsigned char *elp_buff;
 	u32 random_seqno;
 	size_t size;
 	int res = -ENOMEM;
@@ -334,8 +333,9 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
 		goto out;
 
 	skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
-	elp_buff = skb_push(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
-	elp_packet = (struct batadv_elp_packet *)elp_buff;
+	skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
+	elp_packet = (struct batadv_elp_packet *)
+			hard_iface->bat_v.elp_skb->data;
 	memset(elp_packet, 0, BATADV_ELP_HLEN);
 
 	elp_packet->packet_type = BATADV_ELP;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-08-23  1:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-21  3:25 [B.A.T.M.A.N.] [PATCH (maint?) 1/3] batamn-adv: fix elp packet data reservation Linus Lüssing
2016-08-21  3:25 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: elp: skb network header API instead of skb->data access Linus Lüssing
2016-08-21  3:35   ` Linus Lüssing
2016-08-23  1:17   ` Linus Lüssing
2016-08-21  3:25 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: fix batadv_forw_packet kerneldoc for list attribute Linus Lüssing
2016-08-21  3:51   ` Linus Lüssing
2016-08-21  6:22   ` Sven Eckelmann
2016-08-21  6:47 ` [B.A.T.M.A.N.] [PATCH (maint?) 1/3] batamn-adv: fix elp packet data reservation Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox