From patchwork Thu Sep 13 16:18:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 2292 Return-Path: Received: from cora.hrz.tu-chemnitz.de (cora.hrz.tu-chemnitz.de [134.109.228.40]) by open-mesh.org (Postfix) with ESMTPS id 5E8F2601114 for ; Thu, 13 Sep 2012 18:18:35 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass reason="1024-bit key; insecure key" header.i=@tu-chemnitz.de header.b=xnwAPLDf; dkim-adsp=none (insecure policy); dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=Message-Id:Date:Subject:Cc:To:From; bh=W0xnl1r5Pj7G7TgCYzONMAUe4pk5dLke/67Akg5GB8E=; b=xnwAPLDfAjFiEpjgR4L4iyEWSCVEOkgBKw1uPfkcl/LVi/kBAhGWc2GpJSU1Ncx2GKLQoXhcDlYPHcPLt3a3uoYGIDgu4bn4m1xDa4DG0b69dmtmkDacw72bWToplzUpT6AXBw8AIHlLHkvv4sRsVpzyrXQn7smgZjqCr8pjuAc=; Received: from p57aa15c3.dip0.t-ipconnect.de ([87.170.21.195] helo=pandem0nium) by cora.hrz.tu-chemnitz.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.80) (envelope-from ) id 1TCC7e-0007ya-FB; Thu, 13 Sep 2012 18:18:35 +0200 Received: from dotslash by pandem0nium with local (Exim 4.72) (envelope-from ) id 1TCC7s-0003bL-Eq; Thu, 13 Sep 2012 18:18:48 +0200 From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 13 Sep 2012 18:18:46 +0200 Message-Id: <1347553126-13816-1-git-send-email-siwu@hrz.tu-chemnitz.de> X-Mailer: git-send-email 1.7.2.5 X-purgate: clean X-purgate-type: clean X-purgate-ID: 154106::1347553114-0000023A-DD1BD914/0-0/0-0 X-Scan-AV: cora.hrz.tu-chemnitz.de; 2012-09-13 18:18:34; 59bf13ba662273e0a87abe7e89f297ad X-Scan-SA: cora.hrz.tu-chemnitz.de; 2012-09-13 18:18:35; 0065d836fe0c0ebf8182157653c32d67 X-Spam-Score: -1.0 (-) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (-1.0 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP --- Ende Textanalyse Cc: Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: wait multiple periods before activating bla X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 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, 13 Sep 2012 16:18:35 -0000 For some reasons (bridge forward delay, network device setup order, etc) the initial bridge loop avoidance announcement packets may be lost. This may lead to problems in finding other backbone gws, and therfore create loops in the startup time. Fix this by extending the waiting periods to 3 (define can be changed) before allowing broadcast traffic. Signed-off-by: Simon Wunderlich --- bridge_loop_avoidance.c | 9 ++++++++- main.h | 1 + types.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index db046d8..93cf799 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -386,6 +386,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, entry->crc = BATADV_BLA_CRC_INIT; entry->bat_priv = bat_priv; atomic_set(&entry->request_sent, 0); + atomic_set(&entry->wait_periods, 0); memcpy(entry->orig, orig, ETH_ALEN); /* one for the hash, one for returning */ @@ -415,6 +416,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, /* this will be decreased in the worker thread */ atomic_inc(&entry->request_sent); + atomic_set(&entry->wait_periods, BATADV_BLA_WAIT_PERIODS); atomic_inc(&bat_priv->bla.num_requests); } @@ -1156,12 +1158,17 @@ static void batadv_bla_periodic_work(struct work_struct *work) * problems when we are not yet known as backbone gw * in the backbone. * - * We can reset this now and allow traffic again. + * We can reset this now after we waited some periods + * to give bridge forward delays and bla group forming + * some grace time. */ if (atomic_read(&backbone_gw->request_sent) == 0) continue; + if (!atomic_dec_and_test(&backbone_gw->wait_periods)) + continue; + atomic_dec(&backbone_gw->bat_priv->bla.num_requests); atomic_set(&backbone_gw->request_sent, 0); } diff --git a/main.h b/main.h index e828755..b45d5ad 100644 --- a/main.h +++ b/main.h @@ -89,6 +89,7 @@ #define BATADV_BLA_PERIOD_LENGTH 10000 /* 10 seconds */ #define BATADV_BLA_BACKBONE_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 3) #define BATADV_BLA_CLAIM_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 10) +#define BATADV_BLA_WAIT_PERIODS 3 #define BATADV_DUPLIST_SIZE 16 #define BATADV_DUPLIST_TIMEOUT 500 /* 500 ms */ diff --git a/types.h b/types.h index dc126e7..b425dde 100644 --- a/types.h +++ b/types.h @@ -326,6 +326,7 @@ struct batadv_backbone_gw { struct hlist_node hash_entry; struct batadv_priv *bat_priv; unsigned long lasttime; /* last time we heard of this backbone gw */ + atomic_t wait_periods; atomic_t request_sent; atomic_t refcount; struct rcu_head rcu;