From: "Linus Lüssing" <linus.luessing@c0d3.blue>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: elp: skb network header API instead of skb->data access
Date: Sun, 21 Aug 2016 05:25:33 +0200 [thread overview]
Message-ID: <20160821032534.11074-2-linus.luessing@c0d3.blue> (raw)
In-Reply-To: <20160821032534.11074-1-linus.luessing@c0d3.blue>
Instead of playing with skb attributes directly, let's use the
appropriate, more descriptive API instead.
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
net/batman-adv/bat_v_elp.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index ea463bf..af414b0 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -263,7 +263,7 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
if (!skb)
goto restart_timer;
- elp_packet = (struct batadv_elp_packet *)skb->data;
+ elp_packet = (struct batadv_elp_packet *)skb_network_header(skb);
elp_packet->seqno = htonl(atomic_read(&hard_iface->bat_v.elp_seqno));
elp_interval = atomic_read(&hard_iface->bat_v.elp_interval);
elp_packet->elp_interval = htonl(elp_interval);
@@ -323,19 +323,23 @@ out:
int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
{
struct batadv_elp_packet *elp_packet;
+ struct sk_buff *skb;
u32 random_seqno;
size_t size;
int res = -ENOMEM;
size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN;
- hard_iface->bat_v.elp_skb = dev_alloc_skb(size);
- if (!hard_iface->bat_v.elp_skb)
+ skb = dev_alloc_skb(size);
+ hard_iface->bat_v.elp_skb = skb;
+
+ if (!skb)
goto out;
skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
+ skb_reset_network_header(skb);
skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
- elp_packet = (struct batadv_elp_packet *)
- hard_iface->bat_v.elp_skb->data;
+
+ elp_packet = (struct batadv_elp_packet *)skb_network_header(skb);
memset(elp_packet, 0, BATADV_ELP_HLEN);
elp_packet->packet_type = BATADV_ELP;
@@ -392,7 +396,7 @@ void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface,
return;
skb = hard_iface->bat_v.elp_skb;
- elp_packet = (struct batadv_elp_packet *)skb->data;
+ elp_packet = (struct batadv_elp_packet *)skb_network_header(skb);
ether_addr_copy(elp_packet->orig,
primary_iface->net_dev->dev_addr);
}
@@ -506,7 +510,7 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb,
if (strcmp(bat_priv->bat_algo_ops->name, "BATMAN_V") != 0)
return NET_RX_DROP;
- elp_packet = (struct batadv_elp_packet *)skb->data;
+ elp_packet = (struct batadv_elp_packet *)skb_network_header(skb);
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Received ELP packet from %pM seqno %u ORIG: %pM\n",
--
2.1.4
next prev parent reply other threads:[~2016-08-21 3:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Linus Lüssing [this message]
2016-08-21 3:35 ` [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-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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160821032534.11074-2-linus.luessing@c0d3.blue \
--to=linus.luessing@c0d3.blue \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).