From patchwork Fri Jul 6 18:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Maloy X-Patchwork-Id: 940664 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="WxRKGkfM"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41MjTN5q4Mz9s4b for ; Sat, 7 Jul 2018 04:11:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934311AbeGFSLC (ORCPT ); Fri, 6 Jul 2018 14:11:02 -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 S934125AbeGFSLB (ORCPT ); Fri, 6 Jul 2018 14:11:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530900659; 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=tlLRoe5K3cfgeIUbXg9NHAJ5ukulabH2bo0o5VeHv+U=; b=WxRKGkfMT6lDuL3ke6ukc/fRIRIbARr4mv2GgjK/9CUHHjhnKfA/I7CshSDLJCC7 5r+Y0JLf1ENyaxo6/dMBLarGP42ixWJ3IUekNSrGGdrJFJ7jahLOj0dBcGLKuE2m /oX5D960iGJefEoQHMXIHBXdewOGDZFErwzXdj29ErU=; X-AuditID: c1b4fb3a-dcb6e9c0000079c1-03-5b3fb0b3619c Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id C5.BD.31169.3B0BF3B5; Fri, 6 Jul 2018 20:10:59 +0200 (CEST) Received: from ESESSMB505.ericsson.se (153.88.183.166) 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 ESESSMB505.ericsson.se (153.88.183.166) 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:14 +0200 From: Jon Maloy To: , CC: , , , , , , Subject: [net 1/4] tipc: fix wrong return value from function tipc_node_try_addr() Date: Fri, 6 Jul 2018 20:10:03 +0200 Message-ID: <1530900606-24429-2-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+NgFnrDLMWRmVeSWpSXmKPExsUyM2J7ue7mDfbRBgsum1rcaOhhtphzvoXF YsXuSawWb1/NYrc4tkDMYsv5LIsr7WfZLR5fv87swOGxZeVNJo93V9g8di/4zOTxeZOcx/ot W5kCWKO4bFJSczLLUov07RK4Mi68bGQsuMddsXzPcrYGxg2cXYycHBICJhIv1u5h6mLk4hAS OMoo0bb3JxtIQkjgK6PE10cFEIkOJokJuycwQjhbGSU+zTrFDlLFJqAh8XJaByOILSJgLPFq ZSfYKGaBx4wSX+6vAhslLBAkceFdN1gRi4CKxPl/d5lAbF4BN4mHHffYIe6Qkzh//CcziM0p 4C6xfsJcJogz3CRa3rezQ9QLSpyc+YQFxGYWkJA4+OIFM0SNssTcD9OYIOYoSHyYtYxtAqPQ LCQts5C0LGBkWsUoWpxaXJybbmSkl1qUmVxcnJ+nl5dasokRGAcHt/y22sF48LnjIUYBDkYl Ht5Da+yjhVgTy4orcw8xSnAwK4nwatUDhXhTEiurUovy44tKc1KLDzFKc7AoifM6pVlECQmk J5akZqemFqQWwWSZODilGhgZfeVff0tr7f5ndSVimcCVxfvOq7F4nY5qO6Nz/myq9vJi++4+ v9Tt/46vSlTbLr/nzFwNxtcJ5mXxa6UD635OUc0peBZtLCkS+X1P17ekNmFptsmz3wsl+f9M S0gJtHDNvXnWoup1ygy251qXBOQdgv+UT838YBtcmHAucMlnk0sn77fuua/EUpyRaKjFXFSc CADZMeT7fwIAAA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The function for checking if there is an node address conflict is supposed to return a suggestion for a new address if it finds a conflict, and zero otherwise. But in case the peer being checked is previously unknown it does instead return a "suggestion" for the checked address itself. This results in a DSC_TRIAL_FAIL_MSG being sent unecessarily to the peer, and sometimes makes the trial period starting over again. Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values") Signed-off-by: Jon Maloy --- net/tipc/node.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 6a44eb8..0453bd4 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -797,6 +797,7 @@ static u32 tipc_node_suggest_addr(struct net *net, u32 addr) } /* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not + * Returns suggested address if any, otherwise 0 */ u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr) { @@ -819,12 +820,14 @@ u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr) if (n) { addr = n->addr; tipc_node_put(n); + return addr; } - /* Even this node may be in trial phase */ + + /* Even this node may be in conflict */ if (tn->trial_addr == addr) return tipc_node_suggest_addr(net, addr); - return addr; + return 0; } void tipc_node_check_dest(struct net *net, u32 addr, From patchwork Fri Jul 6 18:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Maloy X-Patchwork-Id: 940663 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="YyHoGIgq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41MjSZ44kPz9s1B for ; Sat, 7 Jul 2018 04:10:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934287AbeGFSKT (ORCPT ); Fri, 6 Jul 2018 14:10:19 -0400 Received: from sesbmg23.ericsson.net ([193.180.251.37]:53421 "EHLO sesbmg23.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934016AbeGFSKR (ORCPT ); Fri, 6 Jul 2018 14:10:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530900615; 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=xdO6lwuRm+XeMptfpzDhdXmVOR2x5UbUGHeKfvOGL4M=; b=YyHoGIgq0mqpx/k8CILLrUTDKfnFLrtaeJg402xsgyQxbdVZbc2FWX5o9ZwbB3yZ h8e1WVLlYmLJeBwm4Uew7JYOGZPM6g8NBd2bBm1MmvBZaqiIlShB7/jss7XbHsZM YaHqzqeuRn28GriY+m/UNESilp3NIraWof5SUqEjFS4=; X-AuditID: c1b4fb25-e23ff70000006310-92-5b3fb0873200 Received: from ESESBMB501.ericsson.se (Unknown_Domain [153.88.183.114]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id 0E.DF.25360.780BF3B5; Fri, 6 Jul 2018 20:10:15 +0200 (CEST) Received: from ESESSMB503.ericsson.se (153.88.183.164) by ESESBMB501.ericsson.se (153.88.183.168) 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 ESESSMB503.ericsson.se (153.88.183.164) 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:14 +0200 From: Jon Maloy To: , CC: , , , , , , Subject: [net 2/4] tipc: correct discovery message handling during address trial period Date: Fri, 6 Jul 2018 20:10:04 +0200 Message-ID: <1530900606-24429-3-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+NgFnrDLMWRmVeSWpSXmKPExsUyM2J7kW77Bvtog6U3LSxuNPQwW8w538Ji sWL3JFaLt69msVscWyBmseV8lsWV9rPsFo+vX2d24PDYsvImk8e7K2weuxd8ZvL4vEnOY/2W rUwBrFFcNimpOZllqUX6dglcGfMeNjMVbOepeHrpMVsD40SuLkYODgkBE4l1X4K7GLk4hASO Mko0nJzLDuF8ZZSYu/0gK4TTwSTxZtsXZghnK6PEp1mngMo4OdgENCReTutgBLFFBIwlXq3s ZAIpYhZ4zCjx5f4qNpCEsEC4xP/jV8BsFgEViXvnd4M18wq4Say5+gusWUJATuL88Z/MIDan gLvE+glzmUBsIaCalvftUPWCEidnPmEBsZkFJCQOvnjBDFGjLDH3wzQmiDkKEh9mLWObwCg0 C0nLLCQtCxiZVjGKFqcWJ+WmGxnrpRZlJhcX5+fp5aWWbGIExsHBLb9VdzBefuN4iFGAg1GJ h7d7rX20EGtiWXFl7iFGCQ5mJRFerXqgEG9KYmVValF+fFFpTmrxIUZpDhYlcd6H5pujhATS E0tSs1NTC1KLYLJMHJxSDYztnodPM3HP+V9VLK2v+V9g0XUR3/93V872dm518zM5+DspdY9M wbWw5irpv9dKVy69pmhdGFL71fzi0ul7TPsPnLCTmbI4ZFWSWxTDgqjgk2W8i7Z92Ji+xXN5 cc5/xx8pRsFcH/0tCoNeyNS0KdQfvr6rJX3F0uAd7Qye4mZXpELO+GRV31FiKc5INNRiLipO BAAHRzgDfwIAAA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With the duplicate address discovery protocol for tipc nodes addresses we introduced a one second trial period before a node is allocated a hash number to use as address. Unfortunately, we miss to handle the case when a regular LINK REQUEST/ RESPONSE arrives from a cluster node during the trial period. Such messages are not ignored as they should be, leading to links setup attempts while the node still has no address. Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values") Signed-off-by: Jon Maloy --- net/tipc/discover.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 9f666e0..dcadc10 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c @@ -133,6 +133,8 @@ static void disc_dupl_alert(struct tipc_bearer *b, u32 node_addr, } /* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer + * Returns true if message should be dropped by caller, i.e., if it is a + * trial message or we are inside trial period. Otherwise false. */ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, struct tipc_media_addr *maddr, @@ -168,8 +170,9 @@ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); } + /* Accept regular link requests/responses only after trial period */ if (mtyp != DSC_TRIAL_MSG) - return false; + return trial; sugg_addr = tipc_node_try_addr(net, peer_id, src); if (sugg_addr) 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 */ From patchwork Fri Jul 6 18:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Maloy X-Patchwork-Id: 940667 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="PBQVQ7ul"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41MjTZ1HQXz9s4c for ; Sat, 7 Jul 2018 04:11:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933806AbeGFSLK (ORCPT ); Fri, 6 Jul 2018 14:11:10 -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 S934125AbeGFSLD (ORCPT ); Fri, 6 Jul 2018 14:11:03 -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=s2wPyFkf6xCxmuDC6knXLef+5y9yX+xaWT/pHuP4X7Y=; b=PBQVQ7ulPXJ0rAI1AX+CY3NSm8LKQlgttU3dvhfe/MZKGGa4Pcc2mLSuP5tjHTDx SmaKxTB1rZ0OENqKiIvl0xM4fxIg9Kw15eQNBmkrAvhuoODOXz5Z1xROuVtJ04fX Xby+HdhfCHYCBKCj4LBfw8JHpLK778NYa96ao/W2y5c=; X-AuditID: c1b4fb3a-dcb6e9c0000079c1-0a-5b3fb0b4bcc2 Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 69.BD.31169.4B0BF3B5; Fri, 6 Jul 2018 20:11:00 +0200 (CEST) Received: from ESESSMB502.ericsson.se (153.88.183.163) 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:16 +0200 Received: from ESESSHC011.ericsson.se (153.88.183.51) by ESESSMB502.ericsson.se (153.88.183.163) 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:16 +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 4/4] tipc: make function tipc_net_finalize() thread safe Date: Fri, 6 Jul 2018 20:10:06 +0200 Message-ID: <1530900606-24429-5-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+NgFnrDLMWRmVeSWpSXmKPExsUyM2J7ue6WDfbRBk9WCVvcaOhhtphzvoXF YsXuSawWb1/NYrc4tkDMYsv5LIsr7WfZLR5fv87swOGxZeVNJo93V9g8di/4zOTxeZOcx/ot W5kCWKO4bFJSczLLUov07RK4MrpfPmUv6OaqWHvyGFMD4yqOLkZODgkBE4m/HYtYQGwhgaOM EpvfWHQxcgHZXxkl7h7tZ4NwOpgknsx8zAjhbGWUmDD9ORtIC5uAhsTLaR2MILaIgLHEq5Wd TCBFzAKPGSW+3F8FViQs4CYxtXsOE4jNIqAicej7IbA4L1B897o7TBB3yEmcP/6TGcTmFHCX WD9hLhPETW4SLe/b2SHqBSVOznwCdiuzgITEwRcvmCFqlCXmfpgGNUdB4sOsZWwTGIVmIWmZ haRlASPTKkbR4tTi4tx0IyO91KLM5OLi/Dy9vNSSTYzAODi45bfVDsaDzx0PMQpwMCrx8B5a Yx8txJpYVlyZe4hRgoNZSYRXqx4oxJuSWFmVWpQfX1Sak1p8iFGag0VJnNcpzSJKSCA9sSQ1 OzW1ILUIJsvEwSnVwGjtM9OLI6BZ5+G1+KqLTVlHskMvKnbfb1R+tuedyr+pvdGd2tzcf1Zd FwnY/6hx5uI5/L7LGD9vzpfc2Hjc+pD8w6YLZvI1e4PETZYeObyN137Pggf5fzb8CE9W8Tsj cL/TMeCvDA9Ho+PacF3paGe/xF6xSTqLolgOce/RtM1b9GjO4idyR5RYijMSDbWYi4oTAflr Y9Z/AgAA Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The setting of the node address is not thread safe, meaning that two discoverers may decide to set it simultanously, with a duplicate entry in the name table as result. We fix that with this commit. Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values") Signed-off-by: Jon Maloy --- net/tipc/net.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/net/tipc/net.c b/net/tipc/net.c index 4fbaa04..a7f6964 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr) void tipc_net_finalize(struct net *net, u32 addr) { - tipc_set_node_addr(net, addr); - smp_mb(); - tipc_named_reinit(net); - tipc_sk_reinit(net); - tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, - TIPC_CLUSTER_SCOPE, 0, addr); + struct tipc_net *tn = tipc_net(net); + + spin_lock_bh(&tn->node_list_lock); + if (!tipc_own_addr(net)) { + tipc_set_node_addr(net, addr); + tipc_named_reinit(net); + tipc_sk_reinit(net); + tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, + TIPC_CLUSTER_SCOPE, 0, addr); + } + spin_unlock_bh(&tn->node_list_lock); } void tipc_net_stop(struct net *net)