From patchwork Thu Dec 22 12:33:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1484 Return-Path: Received: from nm25-vm5.bullet.mail.ukl.yahoo.com (nm25-vm5.bullet.mail.ukl.yahoo.com [217.146.177.125]) by open-mesh.org (Postfix) with SMTP id 2A1D160085C for ; Thu, 22 Dec 2011 13:33:49 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.215] by nm25.bullet.mail.ukl.yahoo.com with NNFMP; 22 Dec 2011 12:33:48 -0000 Received: from [77.238.184.61] by tm8.bullet.mail.ukl.yahoo.com with NNFMP; 22 Dec 2011 12:33:48 -0000 Received: from [127.0.0.1] by smtp130.mail.ukl.yahoo.com with NNFMP; 22 Dec 2011 12:33:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1324557228; bh=lCf/8VQH4uG4OOjZnOBakO8zGcyXQPnNh879PquZZnc=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=iuhH8bx/MV1jcQ68u6tJQbeJ7u4xd3zPUs6pU0zJw0EFSdP6kgtnvG3hmF3THu23aMQveeCP/98kVB+kbm6idDr4ZI3oSv/J3trZIDZCG3ry0lxZ3/2aUNCraD3+6fY/flmfskqWToJuXXvWlk9qgN3qh9+a3rbM4f+P1YA6G1A= X-Yahoo-Newman-Id: 503948.43574.bm@smtp130.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: X4T7LQ8VM1kVoAR7OSjn6eOMj5rjqCkbWXFhAiSdkxAvyup _MuQe6HtWBeENTGKHGS3f.kNjtgXThY1d3pHcLHE0a8bi8Io1HvL5W6PZUlH C1KNWicVran2adW5FDLpxnFe4GXlgrJeQOlqmAqd1NrATyS3ug9KOGZUrCoa gwVvMug.PsLc7Q.FSjUf113q6h_ofFRmXn99jbbkl3NsmdYRiDM83iezQefj 2DIXobj2uCvo3ybX3shx_Sk60KtbwICNo_RV_jebaE.QM2PJiqpNq.UpOXfy pKrtS8m4drFJY_m8AKqFluFhQQ0A0N9tcElxvXbFpgXdh_sTA8sX2aqSPksJ F9v9oNiy8v927PuzavdRSg5yNeB.y.rD.utqS6frJYHEBVw_z X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@79.205.247.35 with plain) by smtp130.mail.ukl.yahoo.com with SMTP; 22 Dec 2011 12:33:48 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 22 Dec 2011 20:33:42 +0800 Message-Id: <1324557222-7005-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.4 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: refactor tt_global_del() to avoid misalignment 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: Thu, 22 Dec 2011 12:33:49 -0000 From: Sven Eckelmann Signed-off-by: Sven Eckelmann Acked-by: Antonio Quartulli --- translation-table.c | 42 ++++++++++++++++++++++-------------------- 1 files changed, 22 insertions(+), 20 deletions(-) diff --git a/translation-table.c b/translation-table.c index d542b9d..a1be7ef 100644 --- a/translation-table.c +++ b/translation-table.c @@ -657,29 +657,31 @@ void tt_global_del(struct bat_priv *bat_priv, struct tt_local_entry *tt_local_entry = NULL; tt_global_entry = tt_global_hash_find(bat_priv, addr); - if (!tt_global_entry) + if (!tt_global_entry || tt_global_entry->orig_node != orig_node) goto out; - if (tt_global_entry->orig_node == orig_node) { - if (roaming) { - /* if we are deleting a global entry due to a roam - * event, there are two possibilities: - * 1) the client roamed from node A to node B => we mark - * it with TT_CLIENT_ROAM, we start a timer and we - * wait for node B to claim it. In case of timeout - * the entry is purged. - * 2) the client roamed to us => we can directly delete - * the global entry, since it is useless now. */ - tt_local_entry = tt_local_hash_find(bat_priv, - tt_global_entry->common.addr); - if (!tt_local_entry) { - tt_global_entry->common.flags |= TT_CLIENT_ROAM; - tt_global_entry->roam_at = jiffies; - goto out; - } - } - _tt_global_del(bat_priv, tt_global_entry, message); + if (!roaming) + goto out_del; + + /* if we are deleting a global entry due to a roam + * event, there are two possibilities: + * 1) the client roamed from node A to node B => we mark + * it with TT_CLIENT_ROAM, we start a timer and we + * wait for node B to claim it. In case of timeout + * the entry is purged. + * 2) the client roamed to us => we can directly delete + * the global entry, since it is useless now. */ + tt_local_entry = tt_local_hash_find(bat_priv, + tt_global_entry->common.addr); + if (!tt_local_entry) { + tt_global_entry->common.flags |= TT_CLIENT_ROAM; + tt_global_entry->roam_at = jiffies; + goto out; } + +out_del: + _tt_global_del(bat_priv, tt_global_entry, message); + out: if (tt_global_entry) tt_global_entry_free_ref(tt_global_entry);