From patchwork Fri Jul 6 18:10:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Maloy X-Patchwork-Id: 940665 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="eRnSvEBl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41MjTQ4hwSz9s4b for ; Sat, 7 Jul 2018 04:11:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934316AbeGFSLE (ORCPT ); Fri, 6 Jul 2018 14:11:04 -0400 Received: from sessmg22.ericsson.net ([193.180.251.58]:61765 "EHLO sessmg22.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934202AbeGFSLC (ORCPT ); Fri, 6 Jul 2018 14:11:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530900660; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3qUoUZOtsUfyxz7GvWllM9fPqvaliaeyHsApazYXifU=; b=eRnSvEBl9olGQ68+PnxRyNvf9QK/SK0puUA1mH19pZOVzGKm23BWUWPU1rQ2zMdc Dw01/qfGTYewtx3yqm2ulHqUg+F/uRnzElTIkt39WoeERFfRfjUZ84H/GI3qbC8W /5+PU41pP3rxMRJ6Rzs+LA54fswpYP9YDIj6ADQR2RQ=; X-AuditID: c1b4fb3a-dcb6e9c0000079c1-05-5b3fb0b44b6c Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id A6.BD.31169.4B0BF3B5; Fri, 6 Jul 2018 20:11:00 +0200 (CEST) Received: from ESESBMB501.ericsson.se (153.88.183.168) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 6 Jul 2018 20:10:15 +0200 Received: from ESESSHC011.ericsson.se (153.88.183.51) by ESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256) id 15.1.1466.3 via Frontend Transport; Fri, 6 Jul 2018 20:10:15 +0200 Received: from daly.lab.linux.ericsson.se (10.35.28.123) by ESESSHC011.ericsson.se (153.88.183.51) with Microsoft SMTP Server (TLS) id 14.3.382.0; Fri, 6 Jul 2018 20:10:15 +0200 From: Jon Maloy To: , CC: , , , , , , Subject: [net 3/4] tipc: fix correct setting of message type in second discoverer Date: Fri, 6 Jul 2018 20:10:05 +0200 Message-ID: <1530900606-24429-4-git-send-email-jon.maloy@ericsson.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1530900606-24429-1-git-send-email-jon.maloy@ericsson.com> References: <1530900606-24429-1-git-send-email-jon.maloy@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [10.35.28.123] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsUyM2J7ue6WDfbRBofmMFncaOhhtphzvoXF YsXuSawWb1/NYrc4tkDMYsv5LIsr7WfZLR5fv87swOGxZeVNJo93V9g8di/4zOTxeZOcx/ot W5kCWKO4bFJSczLLUov07RK4MibsWcBacIuv4lrHQfYGxlaeLkZODgkBE4lLl9cwdzFycQgJ HGWU2Pd0IiNIQkjgK6PEjRlGEIkOJolja7uZIJytjBITpj9nA6liE9CQeDmtA6xDRMBY4tXK TrAiZoHHjBJf7q8CKxIWCJQ4uWolO4jNIqAiMXX3FNYuRg4OXgE3ie47UGfISZw//pMZxOYU cJdYP2EuE8QVbhIt79vBWnkFBCVOznzCAmIzC0hIHHzxghmiRlli7odpTBBzFCQ+zFrGNoFR aBaSlllIWhYwMq1iFC1OLS7OTTcy0kstykwuLs7P08tLLdnECIyCg1t+W+1gPPjc8RCjAAej Eg/voTX20UKsiWXFlbmHGCU4mJVEeLXqgUK8KYmVValF+fFFpTmpxYcYpTlYlMR5ndIsooQE 0hNLUrNTUwtSi2CyTBycUg2MRpNSI463rEiRMdBnjV20lUdd9IlewJxLTSuPLne1erpu/SbF qTJHP4m/K4mPLWYK23rg7dPfaSIm96K1XJMzrmi/tuu75rTB80yuutHl1xEZs569ZHp+Y3bU vNwCffeP31sqpfXqDE92uD1YkrNXRjzbTldrhuaDK2duflvRKvohsFc1cdYlJZbijERDLeai 4kQARnoo/34CAAA= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The duplicate address discovery protocol is not safe against two discoverers running in parallel. The one executing first after the trial period is over will set the node address and change its own message type to DSC_REQ_MSG. The one executing last may find that the node address is already set, and never change message type, with the result that its links may never be established. In this commmit we ensure that the message type always is set correctly after the trial period is over. Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values") Signed-off-by: Jon Maloy --- net/tipc/discover.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/tipc/discover.c b/net/tipc/discover.c index dcadc10..2830709 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c @@ -287,7 +287,6 @@ static void tipc_disc_timeout(struct timer_list *t) { struct tipc_discoverer *d = from_timer(d, t, timer); struct tipc_net *tn = tipc_net(d->net); - u32 self = tipc_own_addr(d->net); struct tipc_media_addr maddr; struct sk_buff *skb = NULL; struct net *net = d->net; @@ -301,12 +300,14 @@ static void tipc_disc_timeout(struct timer_list *t) goto exit; } - /* Did we just leave the address trial period ? */ - if (!self && !time_before(jiffies, tn->addr_trial_end)) { - self = tn->trial_addr; - tipc_net_finalize(net, self); - msg_set_prevnode(buf_msg(d->skb), self); + /* Trial period over ? */ + if (!time_before(jiffies, tn->addr_trial_end)) { + /* Did we just leave it ? */ + if (!tipc_own_addr(net)) + tipc_net_finalize(net, tn->trial_addr); + msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); + msg_set_prevnode(buf_msg(d->skb), tipc_own_addr(net)); } /* Adjust timeout interval according to discovery phase */