From patchwork Wed Dec 7 05:42:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 129896 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B6D751007D2 for ; Wed, 7 Dec 2011 16:42:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266Ab1LGFmv (ORCPT ); Wed, 7 Dec 2011 00:42:51 -0500 Received: from nm6-vm0.bullet.mail.ukl.yahoo.com ([217.146.183.234]:29214 "HELO nm6-vm0.bullet.mail.ukl.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751077Ab1LGFmv (ORCPT ); Wed, 7 Dec 2011 00:42:51 -0500 Received: from [217.146.183.183] by nm6.bullet.mail.ukl.yahoo.com with NNFMP; 07 Dec 2011 05:42:50 -0000 Received: from [77.238.184.69] by tm14.bullet.mail.ukl.yahoo.com with NNFMP; 07 Dec 2011 05:42:50 -0000 Received: from [127.0.0.1] by smtp138.mail.ukl.yahoo.com with NNFMP; 07 Dec 2011 05:42:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1323236570; bh=aBpmgxBrVO3LflikFzOn7kO7hptlDl3qBWbh1k6it7o=; 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:In-Reply-To:References; b=BnrCVp39okh6IJDbeubQ6M3Za6f80JXefzGDyS3bMIgtRn4hvQLzAMSlC0SL9V0uq7yGzDEMxM086PC9YvIDlJ+KDWfllwLwE+4hPS3vdvci6du/U12Mf2DzvZgrfigZ1gLFWUuditUC+6j4YFuLNkLLsPci010M4FPu4MgIMKE= X-Yahoo-Newman-Id: 75619.75024.bm@smtp138.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Y7dK_ycVM1nWRTQCmKDOkyNtokXFJqqKu08xMq0Q_BYvYK1 j2Kc2HlLnWjRsPBSdGE8gR0fiYFZGHz44v7KlmpiV7JorU_0Y_qpX0x8MiPT iCUAEqUPgRHcmRc9aZOAxRe.uFMJNfa.kKBMX_o6j_FmXHcsDihSzi4LBdo6 TvdDrnqIOYPLoAn83pUchBDCGam__PDJjFhnpa3cjvwZkoeCp2eHPtQSOAiR MscFyQm4UngSQTJpsVb.1wDPzldvDapTBuOwyQwsiv16ap0M903xt71TiQex v9E5tRnpcUeNA5jOC9MRMcAifodJu090fW1KLnp5LDD1UQnWiqriKJ4FOisb erYrGthsVwVs67WOe7axEZD2lPYTGtfx_Ccx.D_8ppiYmieewC4Knsw-- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@210.177.7.38 with plain) by smtp138.mail.ukl.yahoo.com with SMTP; 07 Dec 2011 05:42:48 +0000 GMT From: Marek Lindner To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Antonio Quartulli Subject: [PATCH 2/2] batman-adv: delete global entry in case of roaming Date: Wed, 7 Dec 2011 13:42:41 +0800 Message-Id: <1323236561-25262-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323236203-24711-1-git-send-email-lindner_marek@yahoo.de> References: <1323236203-24711-1-git-send-email-lindner_marek@yahoo.de> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Antonio Quartulli When receiving a DEL change for a client due to a roaming event (change is marked with TT_CLIENT_ROAM), each node has to check if the client roamed to itself or somewhere else. In the latter case the global entry is kept to avoid having no route at all otherwise we can safely delete the global entry Signed-off-by: Antonio Quartulli --- net/batman-adv/translation-table.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index c46b140..5f09a57 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -696,6 +696,7 @@ void tt_global_del(struct bat_priv *bat_priv, const char *message, bool roaming) { struct tt_global_entry *tt_global_entry = NULL; + struct tt_local_entry *tt_local_entry = NULL; tt_global_entry = tt_global_hash_find(bat_priv, addr); if (!tt_global_entry) @@ -703,15 +704,29 @@ void tt_global_del(struct bat_priv *bat_priv, if (tt_global_entry->orig_node == orig_node) { if (roaming) { - tt_global_entry->flags |= TT_CLIENT_ROAM; - tt_global_entry->roam_at = jiffies; - goto out; + /* 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->addr); + if (!tt_local_entry) { + tt_global_entry->flags |= TT_CLIENT_ROAM; + tt_global_entry->roam_at = jiffies; + goto out; + } } _tt_global_del(bat_priv, tt_global_entry, message); } out: if (tt_global_entry) tt_global_entry_free_ref(tt_global_entry); + if (tt_local_entry) + tt_local_entry_free_ref(tt_local_entry); } void tt_global_del_orig(struct bat_priv *bat_priv,