From patchwork Sun Oct 4 00:19:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 51563 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 n940IpAb007628 for ; Sun, 4 Oct 2009 00:18:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752731AbZJDASa (ORCPT ); Sat, 3 Oct 2009 20:18:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753529AbZJDASa (ORCPT ); Sat, 3 Oct 2009 20:18:30 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:56384 "EHLO mail-ew0-f211.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752731AbZJDAS3 (ORCPT ); Sat, 3 Oct 2009 20:18:29 -0400 Received: by ewy7 with SMTP id 7so2436722ewy.17 for ; Sat, 03 Oct 2009 17:17:52 -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=DqM1syh47eZ72Dox/VqD54h594t86UGSCq/rA41fTAI=; b=e/OwPQPdJpTH0VPPX+wiDOB/reg9zBbTni61ubtkO0SQGmfSczh7akiwt6AGaGnJ7V RWU2D3zXuRwXXu6XFqFnnkU8MmwJy9eRs4qTCaPUp+2whJV3YVkzs0GEIuPVoABHynKf 0baggLFr22Ku5A83jKNUTXmyetAHkbW/R2Id0= 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=tcRJXftEcYfMAxAqDukCq4ZZtQRHrWmgoH5WZbNcAxnHbS9N9ELNpAVYtnpqUSg6Pv 4Rw47eliFGdPtlO98gFgZgr/mzkrtFXzzs9Rqeg4dTUobTZ6fEx9C0zxqeO5BFmrbpVm 5MqQQ/s3wCEP1wkCDBitFxD5IIB9/C43zj/60= Received: by 10.211.158.8 with SMTP id k8mr5264155ebo.38.1254615472357; Sat, 03 Oct 2009 17:17:52 -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 28sm1957574eyg.28.2009.10.03.17.17.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 03 Oct 2009 17:17:51 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 4BF67429E0; Sun, 4 Oct 2009 02:19:42 +0200 (IST) Date: Sun, 4 Oct 2009 02:19:42 +0200 From: Sasha Khapyorsky To: linux-rdma Cc: Rolf Manderscheid , "Smith, Stan" Subject: [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code Message-ID: <20091004001942.GM17846@me> References: <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3@orsmsx501.amr.corp.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3@orsmsx501.amr.corp.intel.com> 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..c91c7a2 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(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); - - 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; + 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_ERROR, "ERR 1F22: " + "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) {