From patchwork Sun Aug 21 03:25:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 16640 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id CF0F982DFE; Sun, 21 Aug 2016 05:25:58 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=c0d3.blue Received-SPF: None (no SPF record) identity=mailfrom; client-ip=138.201.29.205; helo=mail.aperture-lab.de; envelope-from=linus.luessing@c0d3.blue; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=c0d3.blue Received: from mail.aperture-lab.de (mail.aperture-lab.de [138.201.29.205]) by open-mesh.org (Postfix) with ESMTPS id F2BC280395 for ; Sun, 21 Aug 2016 05:25:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.aperture-lab.de (Postfix) with ESMTP id B6C95E07A0; Sun, 21 Aug 2016 05:25:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aperture-lab.de Received: from mail.aperture-lab.de ([127.0.0.1]) by localhost (mail.aperture-lab.de [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id VXvx8iByjXCT; Sun, 21 Aug 2016 05:25:47 +0200 (CEST) Received: from localhost (unknown [IPv6:2001:67c:2d50:0:c85:8cff:fe0f:63fe]) (Authenticated sender: linus.luessing@c0d3.blue) by mail.aperture-lab.de (Postfix) with ESMTPSA; Sun, 21 Aug 2016 05:25:47 +0200 (CEST) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 21 Aug 2016 05:25:33 +0200 Message-Id: <20160821032534.11074-2-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160821032534.11074-1-linus.luessing@c0d3.blue> References: <20160821032534.11074-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Subject: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: elp: skb network header API instead of skb->data access X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" Instead of playing with skb attributes directly, let's use the appropriate, more descriptive API instead. Signed-off-by: Linus Lüssing --- 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",