From patchwork Fri Mar 16 10:52:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1637 Return-Path: Received: from latitanza.investici.org (latitanza.investici.org [82.94.249.234]) by open-mesh.org (Postfix) with ESMTPS id 9B3DC6007A4 for ; Fri, 16 Mar 2012 11:52:37 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [82.94.249.234] (latitanza [82.94.249.234]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 9B9A4983BF; Fri, 16 Mar 2012 10:52:36 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 latitanza.investici.org 9B9A4983BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1331895156; bh=DBbCGj7VUNlFz+H+vH9BbN60QaoMpUtNdKSWOOwlIRc=; h=From:To:Cc:Subject:Date:Message-Id; b=MHcKrEhhFulSxa3eAhdHSaad/t6SCU7oooCAJs/42fd/3cEV95xewHiI7fS5pNNiJ HfVpRS1JhO/wEj/4Gh87YKDjz2wOlnp6R5vr67pkPCv6osyvZGOjsfGs+sbRMXxztj Gaz6t7d6k/wiGJD9ljdVzlI+59VYrVkL7y1HBROA= From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 16 Mar 2012 11:52:31 +0100 Message-Id: <1331895151-22510-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: avoid skb_linearise() if not needed X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2012 10:52:37 -0000 Whenever we want to access headers only, we do not need to linearise the whole packet. Instead we can use pskb_may_pull() Signed-off-by: Antonio Quartulli --- routing.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/routing.c b/routing.c index 962a315..576ffb1 100644 --- a/routing.c +++ b/routing.c @@ -915,8 +915,9 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, /* Check whether I have to reroute the packet */ if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) { - /* Linearize the skb before accessing it */ - if (skb_linearize(skb) < 0) + /* check if there is enough data before accessing it */ + if (pskb_may_pull(skb, sizeof(struct unicast_packet) + + ETH_HLEN) < 0) return 0; ethhdr = (struct ethhdr *)(skb->data +