From patchwork Fri Nov 1 13:17:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3124771 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 49687BEEB2 for ; Fri, 1 Nov 2013 13:18:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49BAD2047C for ; Fri, 1 Nov 2013 13:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0853220318 for ; Fri, 1 Nov 2013 13:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751272Ab3KANSD (ORCPT ); Fri, 1 Nov 2013 09:18:03 -0400 Received: from mail-ea0-f169.google.com ([209.85.215.169]:46768 "EHLO mail-ea0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225Ab3KANSB (ORCPT ); Fri, 1 Nov 2013 09:18:01 -0400 Received: by mail-ea0-f169.google.com with SMTP id k11so2074001eaj.0 for ; Fri, 01 Nov 2013 06:17:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=zxGFTye7hMyFIA89SLIZAu0Ywc69f3gXIFRvKLi0ax8=; b=HB0b1QB7InN/XPVq3HEFe3FVyy7L/gb6eyqQnQCnJyzCcxuHUqZp9W9McwEV1mqW3y 6gNAn0X9R3K1qkZK6WewX9/c1FVz1PX7He65Uor3XPCpco836acw1iyRG0TXS+k/uPYp UhjsdxdnqAiznIfI8tJNwLb+aNyZQmkKIN3m3htFFF7lSt8oEMK9zV9wDL6uab4/ylYh ON9kGwHSIA2tFvfdDnasgE1+UefziOO0F/Q80YWIINGm6BA9Opv1L8howsCBDVxYu9sH cdPu9BVItt9xRswA1j/WVf8ulID3rTDn2LtWzysR6dCrc/gLFCKlYBpHQ18qHfhPMSZR A1Dg== X-Gm-Message-State: ALoCoQkTso++JJfucl2SR71i5JB0CPViu2WiVZPz4SDFcu/L6lLvLHOQbZqZoAcPlXI4IjLVKdbz X-Received: by 10.14.201.9 with SMTP id a9mr3233751eeo.28.1383311879799; Fri, 01 Nov 2013 06:17:59 -0700 (PDT) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id s3sm7710759eeo.3.2013.11.01.06.17.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Nov 2013 06:17:59 -0700 (PDT) Message-ID: <5273AA05.8090409@dev.mellanox.co.il> Date: Fri, 01 Nov 2013 09:17:57 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Dan Ben-Yosef , Jim Mott Subject: [PATCH opensm] Fix possible use of lid 0 when sending set PortInfo after failure of the first PortInfo set Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Ben Yosef Signed-off-by: Dan Ben Yosef Signed-off-by: Hal Rosenstock --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/opensm/osm_port.h b/include/opensm/osm_port.h index 8e34b84..f1edcf9 100644 --- a/include/opensm/osm_port.h +++ b/include/opensm/osm_port.h @@ -1166,6 +1166,7 @@ typedef struct osm_port { unsigned int cc_timeout_count; int cc_unavailable_flag; void *priv; + ib_net16_t lid; } osm_port_t; /* * FIELDS diff --git a/opensm/osm_lid_mgr.c b/opensm/osm_lid_mgr.c index ae8d234..99080d7 100644 --- a/opensm/osm_lid_mgr.c +++ b/opensm/osm_lid_mgr.c @@ -879,6 +879,7 @@ static int lid_mgr_set_physp_pi(IN osm_lid_mgr_t * p_mgr, sizeof(p_pi->subnet_prefix))) send_set = TRUE; + p_port->lid = lid; p_pi->base_lid = lid; if (memcmp(&p_pi->base_lid, &p_old_pi->base_lid, sizeof(p_pi->base_lid))) diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c index e0f0fff..2420e4f 100644 --- a/opensm/osm_link_mgr.c +++ b/opensm/osm_link_mgr.c @@ -107,6 +107,7 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, ib_net32_t attr_mod, cap_mask; boolean_t update_mkey = FALSE; ib_net64_t m_key = 0; + osm_port_t *p_port; OSM_LOG_ENTER(sm->p_log); @@ -116,6 +117,24 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, port_num = osm_physp_get_port_num(p_physp); + memcpy(payload, p_old_pi, sizeof(ib_port_info_t)); + + if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH || + port_num == 0) { + /* Need to make sure LID and SMLID fields in PortInfo are not 0 */ + if (!p_pi->base_lid) { + p_port = osm_get_port_by_guid(sm->p_subn, + osm_physp_get_port_guid(p_physp)); + p_pi->base_lid = p_port->lid; + send_set = TRUE; + } + + /* we are initializing the ports with our local sm_base_lid */ + p_pi->master_sm_base_lid = sm->p_subn->sm_base_lid; + if (p_pi->master_sm_base_lid != p_old_pi->master_sm_base_lid) + send_set = TRUE; + } + if (port_num == 0) { /* CAs don't have a port 0, and for switch port 0, @@ -143,7 +162,8 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, PRIx64 "\n", smsl, cl_ntoh64(osm_physp_get_port_guid (p_physp))); - } else { + /* Enter if base lid and master_sm_lid didn't change */ + } else if (send_set == FALSE) { /* This means the switch doesn't support enhanced port 0 and we don't need to change SMSL. Can skip it. */ @@ -158,8 +178,6 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, esp0 = TRUE; } - memcpy(payload, p_old_pi, sizeof(ib_port_info_t)); - /* Should never write back a value that is bigger then 3 in the PortPhysicalState field - so can not simply copy! @@ -208,18 +226,6 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, sizeof(p_pi->subnet_prefix))) send_set = TRUE; - p_pi->base_lid = osm_physp_get_base_lid(p_physp); - if (memcmp(&p_pi->base_lid, &p_old_pi->base_lid, - sizeof(p_pi->base_lid))) - send_set = TRUE; - - /* we are initializing the ports with our local sm_base_lid */ - p_pi->master_sm_base_lid = sm->p_subn->sm_base_lid; - if (memcmp(&p_pi->master_sm_base_lid, - &p_old_pi->master_sm_base_lid, - sizeof(p_pi->master_sm_base_lid))) - send_set = TRUE; - smsl = link_mgr_get_smsl(sm, p_physp); if (smsl != ib_port_info_get_master_smsl(p_old_pi)) { diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c index 9b1d271..bfeb203 100644 --- a/opensm/osm_trap_rcv.c +++ b/opensm/osm_trap_rcv.c @@ -217,6 +217,7 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p) osm_madw_context_t context; ib_port_info_t *pi = (ib_port_info_t *)payload; osm_physp_t *physp0; + osm_port_t *p_port; ib_net64_t m_key; ib_api_status_t status; @@ -247,6 +248,15 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p) } else m_key = ib_port_info_get_m_key(&p->port_info); + if (osm_node_get_type(p->p_node) != IB_NODE_TYPE_SWITCH) { + if (!pi->base_lid) { + p_port = osm_get_port_by_guid(sm->p_subn, + osm_physp_get_port_guid(p)); + pi->base_lid = p_port->lid; + } + pi->master_sm_base_lid = sm->p_subn->sm_base_lid; + } + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p), payload, sizeof(payload), IB_MAD_ATTR_PORT_INFO,