Whamcloud - gitweb
LU-2934 lnet: Add LNet Router Priority parameter
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index 8721253..ed5eba9 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -125,34 +125,16 @@ lnet_get_networks (void)
 {
         static char       default_networks[256];
         char             *networks = getenv ("LNET_NETWORKS");
-        char             *ip2nets  = getenv ("LNET_IP2NETS");
         char             *str;
         char             *sep;
         int               len;
         int               nob;
-        int               rc;
         cfs_list_t       *tmp;
 
-#ifdef NOT_YET
-        if (networks != NULL && ip2nets != NULL) {
-                LCONSOLE_ERROR_MSG(0x103, "Please set EITHER 'LNET_NETWORKS' or"
-                                   " 'LNET_IP2NETS' but not both at once\n");
-                return NULL;
-        }
-
-        if (ip2nets != NULL) {
-                rc = lnet_parse_ip2nets(&networks, ip2nets);
-                return (rc == 0) ? networks : NULL;
-        }
-#else
-        SET_BUT_UNUSED(ip2nets);
-        SET_BUT_UNUSED(rc);
-#endif
         if (networks != NULL)
                 return networks;
 
         /* In userland, the default 'networks=' is the list of known net types */
-
         len = sizeof(default_networks);
         str = default_networks;
         *str = 0;
@@ -163,13 +145,12 @@ lnet_get_networks (void)
 
                 nob = snprintf(str, len, "%s%s", sep,
                                libcfs_lnd2str(lnd->lnd_type));
+               if (nob >= len) {
+                       /* overflowed the string; leave it where it was */
+                       *str = 0;
+                       break;
+               }
                 len -= nob;
-                if (len < 0) {
-                        /* overflowed the string; leave it where it was */
-                        *str = 0;
-                        break;
-                }
-
                 str += nob;
                 sep = ",";
         }
@@ -251,6 +232,22 @@ lnet_destroy_remote_nets_table(void)
        the_lnet.ln_remote_nets_hash = NULL;
 }
 
+static void
+lnet_destroy_locks(void)
+{
+       if (the_lnet.ln_res_lock != NULL) {
+               cfs_percpt_lock_free(the_lnet.ln_res_lock);
+               the_lnet.ln_res_lock = NULL;
+       }
+
+       if (the_lnet.ln_net_lock != NULL) {
+               cfs_percpt_lock_free(the_lnet.ln_net_lock);
+               the_lnet.ln_net_lock = NULL;
+       }
+
+       lnet_fini_locks();
+}
+
 static int
 lnet_create_locks(void)
 {
@@ -267,26 +264,10 @@ lnet_create_locks(void)
        return 0;
 
  failed:
-       lnet_fini_locks();
+       lnet_destroy_locks();
        return -ENOMEM;
 }
 
-static void
-lnet_destroy_locks(void)
-{
-       if (the_lnet.ln_res_lock != NULL) {
-               cfs_percpt_lock_free(the_lnet.ln_res_lock);
-               the_lnet.ln_res_lock = NULL;
-       }
-
-       if (the_lnet.ln_net_lock != NULL) {
-               cfs_percpt_lock_free(the_lnet.ln_net_lock);
-               the_lnet.ln_net_lock = NULL;
-       }
-
-       lnet_fini_locks();
-}
-
 void lnet_assert_wire_constants (void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
@@ -1618,8 +1599,8 @@ LNetCtl(unsigned int cmd, void *arg)
                 return lnet_fail_nid(data->ioc_nid, data->ioc_count);
 
         case IOC_LIBCFS_ADD_ROUTE:
-                rc = lnet_add_route(data->ioc_net, data->ioc_count,
-                                    data->ioc_nid);
+               rc = lnet_add_route(data->ioc_net, data->ioc_count,
+                                   data->ioc_nid, data->ioc_priority);
                 return (rc != 0) ? rc : lnet_check_routes();
 
         case IOC_LIBCFS_DEL_ROUTE:
@@ -1628,7 +1609,8 @@ LNetCtl(unsigned int cmd, void *arg)
         case IOC_LIBCFS_GET_ROUTE:
                 return lnet_get_route(data->ioc_count,
                                       &data->ioc_net, &data->ioc_count,
-                                      &data->ioc_nid, &data->ioc_flags);
+                                     &data->ioc_nid, &data->ioc_flags,
+                                     &data->ioc_priority);
         case IOC_LIBCFS_NOTIFY_ROUTER:
                 return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
                                    cfs_time_current() -
@@ -2107,12 +2089,8 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i
         for (i = 0; i < n_ids; i++) {
                 tmpid.pid = info->pi_pid;
                 tmpid.nid = info->pi_ni[i].ns_nid;
-#ifdef __KERNEL__
-                if (cfs_copy_to_user(&ids[i], &tmpid, sizeof(tmpid)))
+               if (copy_to_user(&ids[i], &tmpid, sizeof(tmpid)))
                         goto out_1;
-#else
-                ids[i] = tmpid;
-#endif
         }
         rc = info->pi_nnis;