From patchwork Tue Jul 31 16:04:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Netes X-Patchwork-Id: 1261051 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CC56ADF26F for ; Tue, 31 Jul 2012 16:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755475Ab2GaQJm (ORCPT ); Tue, 31 Jul 2012 12:09:42 -0400 Received: from mail-vb0-f46.google.com ([209.85.212.46]:54893 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755054Ab2GaQJl (ORCPT ); Tue, 31 Jul 2012 12:09:41 -0400 Received: by mail-vb0-f46.google.com with SMTP id ff1so5920363vbb.19 for ; Tue, 31 Jul 2012 09:09:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=96vKFvbspzYpD4Eya6inwTzEPFUep1JYm+xc37Kp8UQ=; b=Oxa7iQDDu6NwYzOyP7Pa+D0XM4ec9oadPZdfAMJc5LceAzl+iC1sfuvKuhWefkKkTj gtfyMocqFGTWkrSpC+mJQFh6BGieDOaNrGrgGbM57P39iWb7fJFiLVQ7cCSM0fEOmmtk Deg8wmd8p/6uGPnEu/NK8I/YialQThz+wk4jMWTNJL5fNdFckk6ue1DTHMPRkV+a0ZmX Wu1TlKumFVzjlYo2TF2dRqI5baNw9ANZU3mmwQ4rIeoePOcT4IpfyK1O3FtHkVP0ULzk jgsSxWe9HgQ6otMuBRUL/x2vnn1LH+YkXwo6nCxuVpva7uADKtTMmu/KPti2KERG4wpZ Ds4A== Received: by 10.58.106.197 with SMTP id gw5mr2994575veb.37.1343750981351; Tue, 31 Jul 2012 09:09:41 -0700 (PDT) Received: from localhost ([193.47.165.251]) by mx.google.com with ESMTPS id k4sm430662vdi.6.2012.07.31.09.09.40 (version=SSLv3 cipher=OTHER); Tue, 31 Jul 2012 09:09:40 -0700 (PDT) From: Alex Netes To: linux-rdma@vger.kernel.org Cc: Yevgeny Kliteynik , Hal Rosenstock , Vladimir Koushnir , Alex Netes Subject: [PATCH 26/27] opensm: Fix crash found with ucast cache Date: Tue, 31 Jul 2012 19:04:54 +0300 Message-Id: <1343750695-28063-26-git-send-email-alexne@mellanox.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1343750695-28063-1-git-send-email-alexne@mellanox.com> References: <1343750695-28063-1-git-send-email-alexne@mellanox.com> X-Gm-Message-State: ALoCoQmi+HxuhJsVqaNQpnH/InRTznlnKvhktZySR3r8eIStkWRCX1FRrxnDeiBsH9G9o90hliGP Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Yevgeny Kliteynik OpenSM crashes in case of ucast_cache usage, but the bug itself is in discovery logic. Consider the following scenario: - SM is running - SM gets some trap (let's say link state change) - SM starts heavy sweep - switch X discovered: setting p_sw->need_update to 2 - while still in heavy sweep, more traps received - heavy sweep done (note: just the heavy sweep, w/o other stages, such as ucast manager) - there were traps, hence new heavy sweep started immediately - p_sw->need_update field of all switches is reset to default value of 1, which is also done for switch X - heavy sweep completed - proceeding to next stages ... As a result, we get newly discovered switch X w/o configuration of LFT or other fields, but also w/o indication that this is a new switch, because p_sw->need_update field was reset. Signed-off-by: Yevgeny Kliteynik Signed-off-by: Hal Rosenstock Signed-off-by: Vladimir Koushnir Signed-off-by: Alex Netes --- opensm/osm_state_mgr.c | 3 ++- opensm/osm_ucast_mgr.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/opensm/osm_state_mgr.c b/opensm/osm_state_mgr.c index 00e9c72..183be36 100644 --- a/opensm/osm_state_mgr.c +++ b/opensm/osm_state_mgr.c @@ -111,7 +111,8 @@ static void state_mgr_reset_switch_count(IN cl_map_item_t * p_map_item, { osm_switch_t *p_sw = (osm_switch_t *) p_map_item; - p_sw->need_update = 1; + if (p_sw->max_lid_ho != 0) + p_sw->need_update = 1; } static void state_mgr_get_sw_info(IN cl_map_item_t * p_object, IN void *context) diff --git a/opensm/osm_ucast_mgr.c b/opensm/osm_ucast_mgr.c index f33cc4c..b4cf0f2 100644 --- a/opensm/osm_ucast_mgr.c +++ b/opensm/osm_ucast_mgr.c @@ -907,7 +907,7 @@ static void ucast_mgr_set_fwd_top(IN cl_map_item_t * p_map_item, OSM_LOG_ENTER(p_mgr->p_log); - CL_ASSERT(p_sw); + CL_ASSERT(p_sw && p_sw->max_lid_ho); p_node = p_sw->p_node;