From patchwork Sat Mar 20 03:31:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 87 Return-Path: Received: from fmmailgate03.web.de (fmmailgate03.web.de [217.72.192.234]) by open-mesh.net (Postfix) with ESMTP id BE4E91542F5 for ; Sat, 20 Mar 2010 04:34:25 +0100 (CET) Received: from smtp08.web.de (fmsmtp08.dlan.cinetic.de [172.20.5.216]) by fmmailgate03.web.de (Postfix) with ESMTP id 21B351461A917; Sat, 20 Mar 2010 04:31:55 +0100 (CET) Received: from [78.54.12.205] (helo=localhost) by smtp08.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #4) id 1NspPm-0003hJ-00; Sat, 20 Mar 2010 04:31:54 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 20 Mar 2010 04:31:47 +0100 Message-Id: <1269055908-20369-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.7.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX18i+u4ttp+SiQDQ7bviI3VCj3okw/i0Reo3UaYA cb9BjgxHfTChSCHSDsMKOq0OzkiyX4251IgrBDYNy43qWWbia4 8wggN1OXmgUs0Ze4YUgg== Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: fix aggregation timing bug X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 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: Sat, 20 Mar 2010 03:34:25 -0000 From: Marek Lindner batman-adv aggregates routing packets to reduce the number of packets in the air. Every outgoing packet is compared with other packets in the buffer to determine whether it can be aggregated or not. Packets sent at a lower interval can be held back longer to maximize the aggregation. Due to insufficient checking batman-adv held back all packets for a certain time depending on its own lowest interval rate which slowed down all other nodes. Reported-by: Linus Luessing Signed-off-by: Marek Lindner --- aggregation.c | 12 ++++++++++++ send.c | 10 +--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/batman-adv-kernelland/aggregation.c b/batman-adv-kernelland/aggregation.c index a829814..0635b5a 100644 --- a/batman-adv-kernelland/aggregation.c +++ b/batman-adv-kernelland/aggregation.c @@ -52,6 +52,8 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet, */ if (time_before(send_time, forw_packet->send_time) && + time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS), + forw_packet->send_time) && (aggregated_bytes <= MAX_AGGREGATION_BYTES)) { /** @@ -196,6 +198,16 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, if (forw_packet_aggr == NULL) { /* the following section can run without the lock */ spin_unlock_irqrestore(&forw_bat_list_lock, flags); + + /** + * if we could not aggregate this packet with one of the others + * we hold it back for a while, so that it might be aggregated + * later on + */ + if ((!own_packet) && + (atomic_read(&bat_priv->aggregation_enabled))) + send_time += msecs_to_jiffies(MAX_AGGREGATION_MS); + new_aggregated_packet(packet_buff, packet_len, send_time, direct_link, if_incoming, own_packet); diff --git a/batman-adv-kernelland/send.c b/batman-adv-kernelland/send.c index 1c82f43..4320855 100644 --- a/batman-adv-kernelland/send.c +++ b/batman-adv-kernelland/send.c @@ -49,15 +49,7 @@ static unsigned long own_send_time(void) /* when do we schedule a forwarded packet to be sent */ static unsigned long forward_send_time(struct bat_priv *bat_priv) { - unsigned long send_time = jiffies; /* Starting now plus... */ - - if (atomic_read(&bat_priv->aggregation_enabled)) - send_time += (((MAX_AGGREGATION_MS - (JITTER/2) + - (random32() % JITTER)) * HZ) / 1000); - else - send_time += (((random32() % (JITTER/2)) * HZ) / 1000); - - return send_time; + return jiffies + (((random32() % (JITTER/2)) * HZ) / 1000); } /* send out an already prepared packet to the given address via the