From patchwork Sun Jun 26 19:22:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1184 Return-Path: Received: from nm13.bullet.mail.ukl.yahoo.com (nm13.bullet.mail.ukl.yahoo.com [217.146.183.187]) by open-mesh.org (Postfix) with SMTP id B0DAA1542DB for ; Sun, 26 Jun 2011 21:22:33 +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 nm13.bullet.mail.ukl.yahoo.com with NNFMP; 26 Jun 2011 19:22:29 -0000 Received: from [217.146.183.63] by tm11.bullet.mail.ukl.yahoo.com with NNFMP; 26 Jun 2011 19:22:29 -0000 Received: from [127.0.0.1] by omp1032.mail.ukl.yahoo.com with NNFMP; 26 Jun 2011 19:22:29 -0000 X-Yahoo-Newman-Id: 477436.77851.bm@omp1032.mail.ukl.yahoo.com Received: (qmail 45237 invoked from network); 26 Jun 2011 19:22:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=qiCpAhILhz6jP0i8+rLMgE+Mq0DhP1LVuWOlC9fsXiPLWAZE6wv/5uRnO6SRw07S1SDv+CRKQiNXoBa8DKb2XVV0DWmhQksc6rcsvFykNC/5ML7Z9v9QelB/n0uO//nD5SDb2+/mSkscXYtSNidAGnKiuLlWMNhh8uFYeYgohzo= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1309116149; bh=bYeOGQYQh5SOPbNetb0L2uJy5Uo69Id27q+LqKJfldQ=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=1f3Hjbtyiqt1bMZDKR0zgCUr/PkAtY2s7r9NcdM4h2vZexPd1/QmyNT05ZqTG9gfIX2JZVeiDH6+4cjpjE21o7JokafXCOwxrUZxKA0jQ9gVDwHRrR5iL6415EwYdRBkZRIRMcSIPgQf4tbcJ1ujbYCHoqv8gF3wd3csIQGkaUo= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Kz9audwVM1mXfhUlTgKt7QulUyNvnzIwPKv7miTESpHuz38 y3uDkrMv5kkxJ5mgsLTisbVgiWWf4U5C1pmMhqGie2mTEJPI4O.DbU3JHESG weftY_4UKFlVTLt.1zuIpgv4HLChbiieoHXSdTUR1AHwy50ivGHoe1dzhQtQ J11v9ZWqND0yjA9xNrzo_BOuIvCUspto6UlGexKs2Sfu_V0vNQ4zKOgpNDja fELi.KxE3smhihbmovrFKeW8ZZhaYy5DGqDlbxKt5.xCIcIKYmCcYLi8iOHX WDPwNQdgSf3iUMaC2KDcn.UJ06s2k9mvLc.LsSjZbu8XmQk1eST.eZDYimkW FtXzWNXBHjdwDIabdrCmYXXNDFO4L42NO68JlvcMF682Nw7.qekAjYXY- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@90.61.150.39 with plain) by smtp126.mail.ukl.yahoo.com with SMTP; 26 Jun 2011 19:22:28 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 26 Jun 2011 21:22:19 +0200 Message-Id: <1309116139-14238-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.3 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH] 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: Sun, 26 Jun 2011 19:22:34 -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 --- aggregation.c | 25 ++++++++++++++++++++----- 1 files changed, 20 insertions(+), 5 deletions(-) diff --git a/aggregation.c b/aggregation.c index c583e04..69467fe 100644 --- a/aggregation.c +++ b/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,