From patchwork Mon Oct 12 16:54:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 53174 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9CH0YBe008255 for ; Mon, 12 Oct 2009 17:00:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932815AbZJLQwn (ORCPT ); Mon, 12 Oct 2009 12:52:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932845AbZJLQwn (ORCPT ); Mon, 12 Oct 2009 12:52:43 -0400 Received: from mail-fx0-f227.google.com ([209.85.220.227]:35998 "EHLO mail-fx0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932815AbZJLQwm (ORCPT ); Mon, 12 Oct 2009 12:52:42 -0400 Received: by fxm27 with SMTP id 27so9402894fxm.17 for ; Mon, 12 Oct 2009 09:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=JdIDOGT0WBF/3k+qXJAVn3v2gNYGNYStY3SbvEjrsGM=; b=O7FDSAG5pEvN1nfjoU+u+ypuXRBvAajdJsYlp8ZaMPJnfemsuETpU+UsAbJU16mHub KFvYlDOS+Stw0OZYqwN6fbfVQRImg5hzedNFtucqOm98aqvnewSDRXVfKRR1ipTxHbGF jcSwY4xQruY7J8P5NcSwrJ4JgadQi+oZ3goHI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=o2JgNGwzPiCMNTMAXoEajQzhQ9RrRxo9q3FwFcOB0rkCYW7r0nILyDZsRtQRG7b05n PiEEmymfmq8gkz4aJy2q1pqe1TWZ8nPsAXGxupRETVMTuY4bEumXtMOYtBBRXYbipsUZ diATHDkTWfjjJoJp4DTZTFgIGQo9kq1pYSTl4= Received: by 10.103.37.33 with SMTP id p33mr2506798muj.132.1255366324509; Mon, 12 Oct 2009 09:52:04 -0700 (PDT) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id s10sm199184muh.54.2009.10.12.09.52.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 12 Oct 2009 09:52:03 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 638FD12563; Mon, 12 Oct 2009 18:54:03 +0200 (IST) Date: Mon, 12 Oct 2009 18:54:03 +0200 From: Sasha Khapyorsky To: Hal Rosenstock Cc: linux-rdma , Rolf Manderscheid , "Smith, Stan" Subject: [PATCH v2] opensm/osm_sa_path_record.c: separate router guid resolution code Message-ID: <20091012165403.GC31774@me> References: <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3@orsmsx501.amr.corp.intel.com> <20091004001942.GM17846@me> <20091012162509.GA31774@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091012162509.GA31774@me> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/opensm/osm_sa_path_record.c b/opensm/opensm/osm_sa_path_record.c index b9c6055..f36eb46 100644 --- a/opensm/opensm/osm_sa_path_record.c +++ b/opensm/opensm/osm_sa_path_record.c @@ -1115,6 +1115,39 @@ Exit: /********************************************************************** **********************************************************************/ +/* Find the router port that is configured to handle this prefix, if any */ +static ib_net64_t find_router(const osm_sa_t *sa, ib_net64_t prefix) +{ + osm_prefix_route_t *route = NULL; + osm_router_t *rtr; + cl_qlist_t *l = &sa->p_subn->prefix_routes_list; + cl_list_item_t *i; + + OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, "Non local DGID subnet prefix " + "0x%016" PRIx64 "\n", cl_ntoh64(prefix)); + + for (i = cl_qlist_head(l); i != cl_qlist_end(l); i = cl_qlist_next(i)) { + osm_prefix_route_t *r = (osm_prefix_route_t *)i; + if (!r->prefix || r->prefix == prefix) { + route = r; + break; + } + } + if (!route) + return 0; + + if (route->guid == 0) /* first router */ + rtr = (osm_router_t *) cl_qmap_head(&sa->p_subn->rtr_guid_tbl); + else + rtr = (osm_router_t *) cl_qmap_get(&sa->p_subn->rtr_guid_tbl, + route->guid); + + if (rtr == (osm_router_t *) cl_qmap_end(&sa->p_subn->rtr_guid_tbl)) + return 0; + + return osm_port_get_guid(osm_router_get_port_ptr(rtr)); +} + static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa, IN const osm_madw_t * p_madw, OUT const osm_port_t ** pp_src_port, @@ -1127,8 +1160,6 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa, ib_net64_t dest_guid; ib_api_status_t status; ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS; - osm_router_t *p_rtr; - osm_port_t *p_rtr_port; OSM_LOG_ENTER(sa->p_log); @@ -1209,75 +1240,23 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa, memset(p_dgid, 0, sizeof(*p_dgid)); if (comp_mask & IB_PR_COMPMASK_DGID) { - dest_guid = p_pr->dgid.unicast.interface_id; - if (!ib_gid_is_link_local(&p_pr->dgid)) { - if (!ib_gid_is_multicast(&p_pr->dgid) && - ib_gid_get_subnet_prefix(&p_pr->dgid) != - sa->p_subn->opt.subnet_prefix) { - /* Find the router port that is configured to - handle this prefix, if any */ - osm_prefix_route_t *route = NULL; - osm_prefix_route_t *r = (osm_prefix_route_t *) - cl_qlist_head(&sa->p_subn-> - prefix_routes_list); - + if (!ib_gid_is_link_local(&p_pr->dgid) && + !ib_gid_is_multicast(&p_pr->dgid) && + ib_gid_get_subnet_prefix(&p_pr->dgid) != + sa->p_subn->opt.subnet_prefix) { + dest_guid = find_router(sa, p_pr->dgid.unicast.prefix); + if (!dest_guid) { + char gid_str[INET6_ADDRSTRLEN]; OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, - "Non local DGID subnet prefix 0x%016" - PRIx64 "\n", - cl_ntoh64(p_pr->dgid.unicast.prefix)); - - while (r != (osm_prefix_route_t *) - cl_qlist_end(&sa->p_subn-> - prefix_routes_list)) { - if (r->prefix == - p_pr->dgid.unicast.prefix - || r->prefix == 0) { - route = r; - break; - } - r = (osm_prefix_route_t *) - cl_qlist_next(&r->list_item); - } - - if (!route) { - /* - This 'error' is the client's fault (bad gid) so - don't enter it as an error in our own log. - Return an error response to the client. - */ - sa_status = - IB_SA_MAD_STATUS_INVALID_GID; - goto Exit; - } else if (route->guid == 0) { - /* first router */ - p_rtr = (osm_router_t *) - cl_qmap_head(&sa-> - p_subn->rtr_guid_tbl); - } else { - p_rtr = (osm_router_t *) - cl_qmap_get(&sa->p_subn-> - rtr_guid_tbl, - route->guid); - } - - if (p_rtr == - (osm_router_t *) cl_qmap_end(&sa->p_subn-> - rtr_guid_tbl)) - { - OSM_LOG(sa->p_log, OSM_LOG_ERROR, - "ERR 1F22: " - "Off subnet DGID but router not found\n"); - sa_status = - IB_SA_MAD_STATUS_INVALID_GID; - goto Exit; - } - - p_rtr_port = osm_router_get_port_ptr(p_rtr); - dest_guid = osm_port_get_guid(p_rtr_port); - if (p_dgid) - *p_dgid = p_pr->dgid; + "Off subnet DGID %s, but router not " + "found\n", + inet_ntop(AF_INET6, p_pr->dgid.raw, + gid_str, sizeof(gid_str))); + sa_status = IB_SA_MAD_STATUS_INVALID_GID; + goto Exit; } - } + } else + dest_guid = p_pr->dgid.unicast.interface_id; *pp_dest_port = osm_get_port_by_guid(sa->p_subn, dest_guid); if (!*pp_dest_port) { @@ -1293,6 +1272,9 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa, sa_status = IB_SA_MAD_STATUS_INVALID_GID; goto Exit; } + + if (p_dgid) + *p_dgid = p_pr->dgid; } else { *pp_dest_port = 0; if (comp_mask & IB_PR_COMPMASK_DLID) {