public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] C++ style coding does not compile
@ 2009-10-01 23:09 Smith, Stan
  2009-10-04  0:15 ` Sasha Khapyorsky
       [not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Smith, Stan @ 2009-10-01 23:09 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: ofw@lists.openfabrics.org, linux-rdma


Move C++ in-stream var declarations to top of {} block as in C style; Var assignments left in place.
MSFT compiler errors out with Missing ';' before 'type', 'Illegal use of this type osm_prefix_route_t as an expression'?


Signed-off-by: stan smith <stan.smith@intel.com>

diff --git a/opensm/opensm/osm_sa_path_record.c b/opensm/opensm/osm_sa_path_record.c
index 2247ebe..1166def 100644
--- a/opensm/opensm/osm_sa_path_record.c
+++ b/opensm/opensm/osm_sa_path_record.c
@@ -1214,6 +1214,10 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa,
                        if (!ib_gid_is_multicast(&p_pr->dgid) &&
                            ib_gid_get_subnet_prefix(&p_pr->dgid) !=
                            sa->p_subn->opt.subnet_prefix) {
+
+                               osm_prefix_route_t *route;
+                               osm_prefix_route_t *r;
+
                                OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
                                        "Non local DGID subnet prefix 0x%016"
                                        PRIx64 "\n",
@@ -1221,11 +1225,9 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa,

                                /* 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);
-
+                               route = NULL;
+                               r = (osm_prefix_route_t *) cl_qlist_head(
+                                       &sa->p_subn->prefix_routes_list);
                                while (r != (osm_prefix_route_t *)
                                       cl_qlist_end(&sa->p_subn->
                                                    prefix_routes_list)) {

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] C++ style coding does not compile
  2009-10-01 23:09 [PATCH] C++ style coding does not compile Smith, Stan
@ 2009-10-04  0:15 ` Sasha Khapyorsky
       [not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Sasha Khapyorsky @ 2009-10-04  0:15 UTC (permalink / raw)
  To: Smith, Stan; +Cc: ofw@lists.openfabrics.org, linux-rdma

On 16:09 Thu 01 Oct     , Smith, Stan wrote:
> 
> Move C++ in-stream var declarations to top of {} block as in C style; Var assignments left in place.
> MSFT compiler errors out with Missing ';' before 'type', 'Illegal use of this type osm_prefix_route_t as an expression'?
> 
> 
> Signed-off-by: stan smith <stan.smith@intel.com>

In this patch whitespace characters are mangled.

Applied by hands. Thanks.

Sasha

> 
> diff --git a/opensm/opensm/osm_sa_path_record.c b/opensm/opensm/osm_sa_path_record.c
> index 2247ebe..1166def 100644
> --- a/opensm/opensm/osm_sa_path_record.c
> +++ b/opensm/opensm/osm_sa_path_record.c
> @@ -1214,6 +1214,10 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa,
>                         if (!ib_gid_is_multicast(&p_pr->dgid) &&
>                             ib_gid_get_subnet_prefix(&p_pr->dgid) !=
>                             sa->p_subn->opt.subnet_prefix) {
> +
> +                               osm_prefix_route_t *route;
> +                               osm_prefix_route_t *r;
> +
>                                 OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
>                                         "Non local DGID subnet prefix 0x%016"
>                                         PRIx64 "\n",
> @@ -1221,11 +1225,9 @@ static ib_net16_t pr_rcv_get_end_points(IN osm_sa_t * sa,
> 
>                                 /* 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);
> -
> +                               route = NULL;
> +                               r = (osm_prefix_route_t *) cl_qlist_head(
> +                                       &sa->p_subn->prefix_routes_list);
>                                 while (r != (osm_prefix_route_t *)
>                                        cl_qlist_end(&sa->p_subn->
>                                                     prefix_routes_list)) {
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code
       [not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2009-10-04  0:19   ` Sasha Khapyorsky
  2009-10-05 13:43     ` Hal Rosenstock
  2009-10-05 18:38     ` [PATCH] " Rolf Manderscheid
  0 siblings, 2 replies; 8+ messages in thread
From: Sasha Khapyorsky @ 2009-10-04  0:19 UTC (permalink / raw)
  To: linux-rdma; +Cc: Rolf Manderscheid, Smith, Stan


Move off subnet destination (router address) resolution code to separate
function to improve readability.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 opensm/opensm/osm_sa_path_record.c |  122 +++++++++++++++--------------------
 1 files changed, 52 insertions(+), 70 deletions(-)

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) {
-- 
1.6.5.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code
  2009-10-04  0:19   ` [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code Sasha Khapyorsky
@ 2009-10-05 13:43     ` Hal Rosenstock
       [not found]       ` <f0e08f230910050643j63ce8e81s6d6c9bb35f2fcea5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2009-10-05 18:38     ` [PATCH] " Rolf Manderscheid
  1 sibling, 1 reply; 8+ messages in thread
From: Hal Rosenstock @ 2009-10-05 13:43 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: linux-rdma, Rolf Manderscheid, Smith, Stan

On Sat, Oct 3, 2009 at 8:19 PM, Sasha Khapyorsky <sashak@voltaire.com> wrote:
>
> Move off subnet destination (router address) resolution code to separate
> function to improve readability.
>
> Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>
> ---
>  opensm/opensm/osm_sa_path_record.c |  122 +++++++++++++++--------------------
>  1 files changed, 52 insertions(+), 70 deletions(-)
>
> 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;

This makes the client error (bad GID) log an error now. Do we want to
preserve the original behavior ?

-- Hal

> +
> +       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) {
> --
> 1.6.5.rc1
>
> --
> 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
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code
  2009-10-04  0:19   ` [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code Sasha Khapyorsky
  2009-10-05 13:43     ` Hal Rosenstock
@ 2009-10-05 18:38     ` Rolf Manderscheid
       [not found]       ` <4ACA3D10.5010909-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Rolf Manderscheid @ 2009-10-05 18:38 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: linux-rdma, Smith, Stan

Sasha Khapyorsky wrote:
> Move off subnet destination (router address) resolution code to separate
> function to improve readability.
>  ...
> +static ib_net64_t find_router(osm_sa_t *sa, ib_net64_t prefix)

Much better.  The *sa argument to find_router() can even be const.

    Rolf
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code
       [not found]       ` <f0e08f230910050643j63ce8e81s6d6c9bb35f2fcea5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-10-12 16:25         ` Sasha Khapyorsky
  2009-10-12 16:54           ` [PATCH v2] " Sasha Khapyorsky
  0 siblings, 1 reply; 8+ messages in thread
From: Sasha Khapyorsky @ 2009-10-12 16:25 UTC (permalink / raw)
  To: Hal Rosenstock; +Cc: linux-rdma, Rolf Manderscheid, Smith, Stan

On 09:43 Mon 05 Oct     , Hal Rosenstock wrote:
> On Sat, Oct 3, 2009 at 8:19 PM, Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org> wrote:
> >
> > Move off subnet destination (router address) resolution code to separate
> > function to improve readability.
> >
> > Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
> > ---
> >  opensm/opensm/osm_sa_path_record.c |  122 +++++++++++++++--------------------
> >  1 files changed, 52 insertions(+), 70 deletions(-)
> >
> > 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;
> 
> This makes the client error (bad GID) log an error now. Do we want to
> preserve the original behavior ?

I agree that logging verbosity can be reduced to warning level for such
client's error cases.

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code
       [not found]       ` <4ACA3D10.5010909-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2009-10-12 16:49         ` Sasha Khapyorsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sasha Khapyorsky @ 2009-10-12 16:49 UTC (permalink / raw)
  To: Rolf Manderscheid; +Cc: linux-rdma, Smith, Stan

On 12:38 Mon 05 Oct     , Rolf Manderscheid wrote:
> Sasha Khapyorsky wrote:
> > Move off subnet destination (router address) resolution code to separate
> > function to improve readability.
> >  ...
> > +static ib_net64_t find_router(osm_sa_t *sa, ib_net64_t prefix)
> 
> Much better.  The *sa argument to find_router() can even be const.

Ok. This cannot hurt.

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] opensm/osm_sa_path_record.c: separate router guid resolution code
  2009-10-12 16:25         ` Sasha Khapyorsky
@ 2009-10-12 16:54           ` Sasha Khapyorsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sasha Khapyorsky @ 2009-10-12 16:54 UTC (permalink / raw)
  To: Hal Rosenstock; +Cc: linux-rdma, Rolf Manderscheid, Smith, Stan


Move off subnet destination (router address) resolution code to separate
function to improve readability.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
v2 changes:
- log router guid resolution failure on VERBOSE level - it is client's
  failure
- make *sa parameter const for find_router() function

 opensm/opensm/osm_sa_path_record.c |  120 +++++++++++++++---------------------
 1 files changed, 51 insertions(+), 69 deletions(-)

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) {
-- 
1.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-12 16:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-01 23:09 [PATCH] C++ style coding does not compile Smith, Stan
2009-10-04  0:15 ` Sasha Khapyorsky
     [not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C86E8BA3-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-10-04  0:19   ` [PATCH] opensm/osm_sa_path_record.c: separate router guid resolution code Sasha Khapyorsky
2009-10-05 13:43     ` Hal Rosenstock
     [not found]       ` <f0e08f230910050643j63ce8e81s6d6c9bb35f2fcea5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-10-12 16:25         ` Sasha Khapyorsky
2009-10-12 16:54           ` [PATCH v2] " Sasha Khapyorsky
2009-10-05 18:38     ` [PATCH] " Rolf Manderscheid
     [not found]       ` <4ACA3D10.5010909-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-12 16:49         ` Sasha Khapyorsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox