From patchwork Tue Jul 5 13:43:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1200 Return-Path: Received: from nm9.bullet.mail.ukl.yahoo.com (nm9.bullet.mail.ukl.yahoo.com [217.146.182.250]) by open-mesh.org (Postfix) with SMTP id 4AADD1544AA for ; Tue, 5 Jul 2011 15:44:25 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.180] by nm9.bullet.mail.ukl.yahoo.com with NNFMP; 05 Jul 2011 13:44:24 -0000 Received: from [77.238.184.62] by tm11.bullet.mail.ukl.yahoo.com with NNFMP; 05 Jul 2011 13:44:24 -0000 Received: from [127.0.0.1] by smtp131.mail.ukl.yahoo.com with NNFMP; 05 Jul 2011 13:44:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1309873464; bh=lcj/vJECSH/J9fh2rjRMW1LDW6kWwo35lS4bm9hwn+Y=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=rVcnoFFIWgn/Dw5HkizC6m30mtlhC+S6GJfs0c5pEf6102IvY3OkYtSxVGGV+VThXx8ZSZeEDphiHZ7amXKUAv2o8Xjgt9h58ZE4W0bz+fzXY/9sKdXvXMDQy4Fvh3g+DQC+jx2aQRiO5YDk7TKp8zQBhEMU4iVhVGMTCl5e0zY= X-Yahoo-Newman-Id: 752999.80521.bm@smtp131.mail.ukl.yahoo.com Received: from localhost (lindner_marek@90.35.97.9 with plain) by smtp131.mail.ukl.yahoo.com with SMTP; 05 Jul 2011 13:44:24 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: cc0o.zcVM1nlKDOMZcGiTa2q19bgTzXfcR5Ihrftg5cJJnq BotxzCCDTw7jKoWD6XLk2AtdAC5npxpxVQ2uNj4h6Zyotnr_yx3BTBcZbSlJ qqS5_7QaNBx56rFZ.lKmoG1.Q_aWybd_mDmoGPL3BzC8hMaZ1XwTSj24AaZx nwxsiewB00HfdK_pCrT8UEPnr0GHKvhod_Fn2wzo0mvqv6tFiFzxVnstaxYK M_adXn6glucyuDrzsJVtCfrFowBRb2ZDTm8G0pQAWc8oROyWoaxwQgPePMs. qu6M0cRs2gvM3CGQw2oZaqq0f1ng1HkxDxpqqzPAgXnR3dZKPDwLCdR63svK PbhSKYLw8KkSNCEPeCcw.80gBMu2GeeEdCxRHH.8WYzj5X7HLLVl32Kw- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: davem@davemloft.net Date: Tue, 5 Jul 2011 15:43:59 +0200 Message-Id: <1309873440-11704-6-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1309873440-11704-1-git-send-email-lindner_marek@yahoo.de> References: <1309873440-11704-1-git-send-email-lindner_marek@yahoo.de> Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 5/6] batman-adv: aggregation checks should use the primary_if pointer 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: Tue, 05 Jul 2011 13:44:25 -0000 The packet aggregation needs to ensure that only compatible packets are aggregated. Some of the checks are based on the interface number while assuming that the first interface also is the primary interface which is not always the case. This patch addresses the issue by using the primary_if pointer. Reported-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/aggregation.c | 25 ++++++++++++++++++++----- 1 files changed, 20 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/aggregation.c b/net/batman-adv/aggregation.c index c583e04..69467fe 100644 --- a/net/batman-adv/aggregation.c +++ b/net/batman-adv/aggregation.c @@ -28,6 +28,7 @@ /* return true if new_packet can be aggregated with forw_packet */ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, + struct bat_priv *bat_priv, int packet_len, unsigned long send_time, bool directlink, @@ -37,6 +38,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, struct batman_packet *batman_packet = (struct batman_packet *)forw_packet->skb->data; int aggregated_bytes = forw_packet->packet_len + packet_len; + struct hard_iface *primary_if = NULL; + bool res = false; /** * we can aggregate the current packet to this aggregated packet @@ -61,6 +64,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, * packet */ + primary_if = primary_if_get_selected(bat_priv); + if (!primary_if) + goto out; + /* packets without direct link flag and high TTL * are flooded through the net */ if ((!directlink) && @@ -70,8 +77,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, /* own packets originating non-primary * interfaces leave only that interface */ ((!forw_packet->own) || - (forw_packet->if_incoming->if_num == 0))) - return true; + (forw_packet->if_incoming == primary_if))) { + res = true; + goto out; + } /* if the incoming packet is sent via this one * interface only - we still can aggregate */ @@ -84,11 +93,16 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, * (= secondary interface packets in general) */ (batman_packet->flags & DIRECTLINK || (forw_packet->own && - forw_packet->if_incoming->if_num != 0))) - return true; + forw_packet->if_incoming != primary_if))) { + res = true; + goto out; + } } - return false; +out: + if (primary_if) + hardif_free_ref(primary_if); + return res; } /* create a new aggregated packet and add this packet to it */ @@ -210,6 +224,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv, hlist_for_each_entry(forw_packet_pos, tmp_node, &bat_priv->forw_bat_list, list) { if (can_aggregate_with(batman_packet, + bat_priv, packet_len, send_time, direct_link,