Whamcloud - gitweb
LU-10452 lnet: cleanup YAML output
[fs/lustre-release.git] / lnet / utils / lnetconfig / liblnetconfig.c
index f172698..dce0795 100644 (file)
@@ -18,7 +18,7 @@
  *
  * LGPL HEADER END
  *
- * Copyright (c) 2014, 2016, Intel Corporation.
+ * Copyright (c) 2014, 2017, Intel Corporation.
  *
  * Author:
  *   Amir Shehata <amir.shehata@intel.com>
@@ -51,7 +51,6 @@
 #include <fcntl.h>
 #include <ifaddrs.h>
 #include "liblnetconfig.h"
-#include "cyaml.h"
 
 #define CONFIG_CMD             "configure"
 #define UNCONFIG_CMD           "unconfigure"
@@ -62,6 +61,7 @@
 #define MANAGE_CMD              "manage"
 
 #define modparam_path "/sys/module/lnet/parameters/"
+#define gni_nid_path "/proc/cray_xt/"
 
 const char *gmsg_stat_names[] = {"sent_stats", "received_stats",
                                 "dropped_stats"};
@@ -240,6 +240,7 @@ int lustre_lnet_add_intf_descr(struct list_head *list, char *intf, int len)
 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr)
 {
        if (nw_descr != NULL) {
+               nw_descr->nw_id = 0;
                INIT_LIST_HEAD(&nw_descr->network_on_rule);
                INIT_LIST_HEAD(&nw_descr->nw_intflist);
        }
@@ -396,8 +397,7 @@ failed:
 
 int lustre_lnet_config_lib_init(void)
 {
-       return register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH,
-                               LNET_DEV_MAJOR, LNET_DEV_MINOR);
+       return register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH);
 }
 
 void lustre_lnet_config_lib_uninit(void)
@@ -498,7 +498,7 @@ static int infra_ping_nid(char *ping_nids, char *oper, int param, int ioc_call,
        struct lnet_ioctl_ping_data ping;
        struct cYAML *root = NULL, *ping_node = NULL, *item = NULL,
                     *first_seq = NULL, *tmp = NULL, *peer_ni = NULL;
-       lnet_process_id_t id;
+       struct lnet_process_id id;
        char err_str[LNET_MAX_STR_LEN] = {0};
        char *sep, *token, *end;
        char buf[6];
@@ -507,7 +507,7 @@ static int infra_ping_nid(char *ping_nids, char *oper, int param, int ioc_call,
        int i;
        bool flag = false;
 
-       len = (sizeof(lnet_process_id_t) * LNET_INTERFACES_MAX_DEFAULT);
+       len = (sizeof(struct lnet_process_id) * LNET_INTERFACES_MAX_DEFAULT);
 
        data = calloc(1, len);
        if (data == NULL)
@@ -823,7 +823,7 @@ int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
        if (nw == NULL || gw == NULL) {
                snprintf(err_str,
                         sizeof(err_str),
-                        "\"missing mandatory parameter(s): '%s'\"",
+                        "\"missing mandatory parameter in route config:'%s'\"",
                         (nw == NULL && gw == NULL) ? "network, gateway" :
                         (nw == NULL) ? "network" : "gateway");
                rc = LUSTRE_CFG_RC_MISSING_PARAM;
@@ -906,7 +906,7 @@ int lustre_lnet_del_route(char *nw, char *gw,
        if (nw == NULL || gw == NULL) {
                snprintf(err_str,
                         sizeof(err_str),
-                        "\"missing mandatory parameter(s): '%s'\"",
+                        "\"missing mandatory parameter in route delete: '%s'\"",
                         (nw == NULL && gw == NULL) ? "network, gateway" :
                         (nw == NULL) ? "network" : "gateway");
                rc = LUSTRE_CFG_RC_MISSING_PARAM;
@@ -952,7 +952,7 @@ out:
 
 int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
                           int seq_no, struct cYAML **show_rc,
-                          struct cYAML **err_rc)
+                          struct cYAML **err_rc, bool backup)
 {
        struct lnet_ioctl_config_data data;
        lnet_nid_t gateway_nid;
@@ -1072,7 +1072,8 @@ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
                                                cfg_route.rtr_priority) == NULL)
                                goto out;
 
-                       if (cYAML_create_string(item, "state",
+                       if (!backup &&
+                           cYAML_create_string(item, "state",
                                                data.cfg_config_u.cfg_route.
                                                        rtr_flags ?
                                                "up" : "down") == NULL)
@@ -1147,51 +1148,102 @@ static int socket_intf_query(int request, char *intf,
        return rc;
 }
 
+static int lustre_lnet_queryip(struct lnet_dlc_intf_descr *intf, __u32 *ip)
+{
+       struct ifreq ifr;
+       int rc;
+
+       memset(&ifr, 0, sizeof(ifr));
+       rc = socket_intf_query(SIOCGIFFLAGS, intf->intf_name, &ifr);
+       if (rc != 0)
+               return LUSTRE_CFG_RC_BAD_PARAM;
+
+       if ((ifr.ifr_flags & IFF_UP) == 0)
+               return LUSTRE_CFG_RC_BAD_PARAM;
+
+       memset(&ifr, 0, sizeof(ifr));
+       rc = socket_intf_query(SIOCGIFADDR, intf->intf_name, &ifr);
+       if (rc != 0)
+               return LUSTRE_CFG_RC_BAD_PARAM;
+
+       *ip = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
+       *ip = bswap_32(*ip);
+
+       return LUSTRE_CFG_RC_NO_ERR;
+}
+
 /*
  * for each interface in the array of interfaces find the IP address of
  * that interface, create its nid and add it to an array of NIDs.
  * Stop if any of the interfaces is down
  */
 static int lustre_lnet_intf2nids(struct lnet_dlc_network_descr *nw,
-                                lnet_nid_t **nids, __u32 *nnids)
+                                lnet_nid_t **nids, __u32 *nnids,
+                                char *err_str, size_t str_len)
 {
        int i = 0, count = 0, rc;
-       struct ifreq ifr;
-       __u32 ip;
        struct lnet_dlc_intf_descr *intf;
+       char val[LNET_MAX_STR_LEN];
+       __u32 ip;
+       int gni_num;
 
-       if (nw == NULL || nids == NULL)
+
+       if (nw == NULL || nids == NULL) {
+               snprintf(err_str, str_len,
+                        "\"unexpected parameters to lustre_lnet_intf2nids()\"");
+               err_str[str_len - 1] = '\0';
                return LUSTRE_CFG_RC_BAD_PARAM;
+       }
 
-       list_for_each_entry(intf, &nw->nw_intflist, intf_on_network)
-               count++;
+       if (LNET_NETTYP(nw->nw_id) == GNILND) {
+               count = 1;
+       } else {
+               list_for_each_entry(intf, &nw->nw_intflist, intf_on_network)
+                       count++;
+       }
 
        *nids = calloc(count, sizeof(lnet_nid_t));
-       if (*nids == NULL)
+       if (*nids == NULL) {
+               snprintf(err_str, str_len,
+                        "\"out of memory\"");
+               err_str[str_len - 1] = '\0';
                return LUSTRE_CFG_RC_OUT_OF_MEM;
-
-       list_for_each_entry(intf, &nw->nw_intflist, intf_on_network) {
-               memset(&ifr, 0, sizeof(ifr));
-               rc = socket_intf_query(SIOCGIFFLAGS, intf->intf_name, &ifr);
-               if (rc != 0)
-                       goto failed;
-
-               if ((ifr.ifr_flags & IFF_UP) == 0) {
-                       rc = LUSTRE_CFG_RC_BAD_PARAM;
+       }
+       /*
+        * special case the GNI interface since it doesn't have an IP
+        * address. The assumption is that there can only be one GNI
+        * interface in the system. No interface name is provided.
+        */
+       if (LNET_NETTYP(nw->nw_id) == GNILND) {
+               rc = read_sysfs_file(gni_nid_path, "nid", val,
+                               1, sizeof(val));
+               if (rc) {
+                       snprintf(err_str, str_len,
+                                "\"cannot read gni nid\"");
+                       err_str[str_len - 1] = '\0';
                        goto failed;
                }
+               gni_num = atoi(val);
 
-               memset(&ifr, 0, sizeof(ifr));
-               rc = socket_intf_query(SIOCGIFADDR, intf->intf_name, &ifr);
-               if (rc != 0)
-                       goto failed;
+               (*nids)[i] = LNET_MKNID(nw->nw_id, gni_num);
 
-               ip = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
-               ip = bswap_32(ip);
+               goto out;
+       }
+
+       /* look at the other interfaces */
+       list_for_each_entry(intf, &nw->nw_intflist, intf_on_network) {
+               rc = lustre_lnet_queryip(intf, &ip);
+               if (rc != LUSTRE_CFG_RC_NO_ERR) {
+                       snprintf(err_str, str_len,
+                                "\"couldn't query intf %s\"", intf->intf_name);
+                       err_str[str_len - 1] = '\0';
+                       goto failed;
+               }
                (*nids)[i] = LNET_MKNID(nw->nw_id, ip);
                i++;
        }
 
+out:
        *nnids = count;
 
        return 0;
@@ -1360,25 +1412,34 @@ int lustre_lnet_match_ip_to_intf(struct ifaddrs *ifa,
        return LUSTRE_CFG_RC_MATCH;
 }
 
-int lustre_lnet_resolve_ip2nets_rule(struct lustre_lnet_ip2nets *ip2nets,
-                                    lnet_nid_t **nids, __u32 *nnids)
+static int lustre_lnet_resolve_ip2nets_rule(struct lustre_lnet_ip2nets *ip2nets,
+                                           lnet_nid_t **nids, __u32 *nnids,
+                                           char *err_str, size_t str_len)
 {
        struct ifaddrs *ifa;
        int rc = LUSTRE_CFG_RC_NO_ERR;
 
        rc = getifaddrs(&ifa);
-       if (rc < 0)
+       if (rc < 0) {
+               snprintf(err_str, str_len,
+                        "\"failed to get interface addresses: %d\"", -errno);
+               err_str[str_len - 1] = '\0';
                return -errno;
+       }
 
        rc = lustre_lnet_match_ip_to_intf(ifa,
                                          &ip2nets->ip2nets_net.nw_intflist,
                                          &ip2nets->ip2nets_ip_ranges);
        if (rc != LUSTRE_CFG_RC_MATCH) {
+               snprintf(err_str, str_len,
+                        "\"couldn't match ip to existing interfaces\"");
+               err_str[str_len - 1] = '\0';
                freeifaddrs(ifa);
                return rc;
        }
 
-       rc = lustre_lnet_intf2nids(&ip2nets->ip2nets_net, nids, nnids);
+       rc = lustre_lnet_intf2nids(&ip2nets->ip2nets_net, nids, nnids,
+                                  err_str, sizeof(err_str));
        if (rc != LUSTRE_CFG_RC_NO_ERR) {
                *nids = NULL;
                *nnids = 0;
@@ -1496,13 +1557,10 @@ lustre_lnet_config_ip2nets(struct lustre_lnet_ip2nets *ip2nets,
         * The memory is allocated in that function then freed here when
         * it's no longer needed.
         */
-       rc = lustre_lnet_resolve_ip2nets_rule(ip2nets, &nids, &nnids);
-       if (rc != LUSTRE_CFG_RC_NO_ERR && rc != LUSTRE_CFG_RC_MATCH) {
-               snprintf(err_str,
-                        sizeof(err_str),
-                        "\"cannot resolve ip2nets rule\"");
+       rc = lustre_lnet_resolve_ip2nets_rule(ip2nets, &nids, &nnids, err_str,
+                                             sizeof(err_str));
+       if (rc != LUSTRE_CFG_RC_NO_ERR && rc != LUSTRE_CFG_RC_MATCH)
                goto out;
-       }
 
        if (list_empty(&ip2nets->ip2nets_net.nw_intflist)) {
                snprintf(err_str, sizeof(err_str),
@@ -1543,10 +1601,14 @@ int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
 
        snprintf(err_str, sizeof(err_str), "\"success\"");
 
-       if (ip2net == NULL && nw_descr == NULL) {
+       if (ip2net == NULL && (nw_descr == NULL || nw_descr->nw_id == 0 ||
+           (list_empty(&nw_descr->nw_intflist) &&
+            LNET_NETTYP(nw_descr->nw_id) != GNILND))) {
                snprintf(err_str,
                         sizeof(err_str),
-                        "\"mandatory parameters not specified.\"");
+                        "\"missing mandatory parameters in NI config: '%s'\"",
+                        (nw_descr == NULL) ? "network , interface" :
+                        (nw_descr->nw_id == 0) ? "network" : "interface");
                rc = LUSTRE_CFG_RC_MISSING_PARAM;
                goto out;
        }
@@ -1627,7 +1689,11 @@ int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
                goto out;
        }
 
-       if (list_empty(&nw_descr->nw_intflist)) {
+       /*
+        * special case the GNI since no interface name is expected
+        */
+       if (list_empty(&nw_descr->nw_intflist) &&
+           (LNET_NETTYP(nw_descr->nw_id) != GNILND)) {
                snprintf(err_str,
                        sizeof(err_str),
                        "\"no interface name provided\"");
@@ -1635,10 +1701,9 @@ int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
                goto out;
        }
 
-       rc = lustre_lnet_intf2nids(nw_descr, &nids, &nnids);
+       rc = lustre_lnet_intf2nids(nw_descr, &nids, &nnids,
+                                  err_str, sizeof(err_str));
        if (rc != 0) {
-               snprintf(err_str, sizeof(err_str),
-                        "\"bad parameter\"");
                rc = LUSTRE_CFG_RC_BAD_PARAM;
                goto out;
        }
@@ -1680,10 +1745,12 @@ int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw_descr,
 
        snprintf(err_str, sizeof(err_str), "\"success\"");
 
-       if (nw_descr == NULL) {
+       if (nw_descr == NULL || nw_descr->nw_id == 0) {
                snprintf(err_str,
                         sizeof(err_str),
-                        "\"missing mandatory parameter\"");
+                        "\"missing mandatory parameter in deleting NI: '%s'\"",
+                        (nw_descr == NULL) ? "network , interface" :
+                        (nw_descr->nw_id == 0) ? "network" : "interface");
                rc = LUSTRE_CFG_RC_MISSING_PARAM;
                goto out;
        }
@@ -1700,10 +1767,9 @@ int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw_descr,
                goto out;
        }
 
-       rc = lustre_lnet_intf2nids(nw_descr, &nids, &nnids);
+       rc = lustre_lnet_intf2nids(nw_descr, &nids, &nnids,
+                                  err_str, sizeof(err_str));
        if (rc != 0) {
-               snprintf(err_str, sizeof(err_str),
-                        "\"bad parameter\"");
                rc = LUSTRE_CFG_RC_BAD_PARAM;
                goto out;
        }
@@ -1793,7 +1859,8 @@ get_counts(struct lnet_ioctl_element_msg_stats *msg_stats, int idx)
 }
 
 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
-                        struct cYAML **show_rc, struct cYAML **err_rc)
+                        struct cYAML **show_rc, struct cYAML **err_rc,
+                        bool backup)
 {
        char *buf;
        struct lnet_ioctl_config_ni *ni_data;
@@ -1870,6 +1937,10 @@ int lustre_lnet_show_net(char *nw, int detail, int seq_no,
                    net != rc_net)
                        continue;
 
+               /* if we're backing up don't store lo */
+               if (backup && LNET_NETTYP(rc_net) == LOLND)
+                       continue;
+
                /* default rc to -1 in case we hit the goto */
                rc = -1;
                exist = true;
@@ -1903,11 +1974,13 @@ int lustre_lnet_show_net(char *nw, int detail, int seq_no,
                if (first_seq == NULL)
                        first_seq = item;
 
-               if (cYAML_create_string(item, "nid",
+               if (!backup &&
+                   cYAML_create_string(item, "nid",
                                        libcfs_nid2str(ni_data->lic_nid)) == NULL)
                        goto out;
 
-               if (cYAML_create_string(item,
+               if (!backup &&
+                   cYAML_create_string(item,
                                        "status",
                                        (ni_data->lic_status ==
                                          LNET_NI_STATUS_UP) ?
@@ -1938,6 +2011,9 @@ int lustre_lnet_show_net(char *nw, int detail, int seq_no,
                        char *limit;
                        int k;
 
+                       if (backup)
+                               goto continue_without_msg_stats;
+
                        statistics = cYAML_create_object(item, "statistics");
                        if (statistics == NULL)
                                goto out;
@@ -1999,24 +2075,30 @@ continue_without_msg_stats:
                        if (rc != LUSTRE_CFG_RC_NO_ERR)
                                goto out;
 
-                       tunables = cYAML_create_object(item, "lnd tunables");
-                       if (tunables == NULL)
-                               goto out;
-
                        rc = lustre_ni_show_tunables(tunables, LNET_NETTYP(rc_net),
                                                     &lnd->lt_tun);
-                       if (rc != LUSTRE_CFG_RC_NO_ERR)
+                       if (rc != LUSTRE_CFG_RC_NO_ERR &&
+                           rc != LUSTRE_CFG_RC_NO_MATCH)
                                goto out;
 
-                       if (cYAML_create_number(item, "tcp bonding",
-                                               ni_data->lic_tcp_bonding)
-                                                       == NULL)
-                               goto out;
+                       if (rc != LUSTRE_CFG_RC_NO_MATCH) {
+                               tunables = cYAML_create_object(item,
+                                                              "lnd tunables");
+                               if (tunables == NULL)
+                                       goto out;
+                       }
 
-                       if (cYAML_create_number(item, "dev cpt",
+                       if (!backup &&
+                           cYAML_create_number(item, "dev cpt",
                                                ni_data->lic_dev_cpt) == NULL)
                                goto out;
 
+                       if (!backup &&
+                           cYAML_create_number(item, "tcp bonding",
+                                               ni_data->lic_tcp_bonding)
+                                                       == NULL)
+                               goto out;
+
                        /* out put the CPTs in the format: "[x,x,x,...]" */
                        limit = str_buf + str_buf_len - 3;
                        pos += snprintf(pos, limit - pos, "\"[");
@@ -2226,7 +2308,7 @@ out:
 }
 
 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
-                            struct cYAML **err_rc)
+                            struct cYAML **err_rc, bool backup)
 {
        struct lnet_ioctl_config_data *data;
        struct lnet_ioctl_pool_cfg *pool_cfg = NULL;
@@ -2255,7 +2337,10 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
        if (root == NULL)
                goto out;
 
-       pools_node = cYAML_create_seq(root, "routing");
+       if (backup)
+               pools_node = cYAML_create_object(root, "routing");
+       else
+               pools_node = cYAML_create_seq(root, "routing");
        if (pools_node == NULL)
                goto out;
 
@@ -2275,6 +2360,9 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
 
                pool_cfg = (struct lnet_ioctl_pool_cfg *)data->cfg_bulk;
 
+               if (backup)
+                       goto calculate_buffers;
+
                snprintf(node_name, sizeof(node_name), "cpt[%d]", i);
                item = cYAML_create_seq_item(pools_node);
                if (item == NULL)
@@ -2287,24 +2375,31 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
                if (cpt == NULL)
                        goto out;
 
+calculate_buffers:
                /* create the tree  and print */
                for (j = 0; j < LNET_NRBPOOLS; j++) {
-                       type_node = cYAML_create_object(cpt, pools[j]);
-                       if (type_node == NULL)
-                               goto out;
-                       if (cYAML_create_number(type_node, "npages",
+                       if (!backup) {
+                               type_node = cYAML_create_object(cpt, pools[j]);
+                               if (type_node == NULL)
+                                       goto out;
+                       }
+                       if (!backup &&
+                           cYAML_create_number(type_node, "npages",
                                                pool_cfg->pl_pools[j].pl_npages)
                            == NULL)
                                goto out;
-                       if (cYAML_create_number(type_node, "nbuffers",
+                       if (!backup &&
+                           cYAML_create_number(type_node, "nbuffers",
                                                pool_cfg->pl_pools[j].
                                                  pl_nbuffers) == NULL)
                                goto out;
-                       if (cYAML_create_number(type_node, "credits",
+                       if (!backup &&
+                           cYAML_create_number(type_node, "credits",
                                                pool_cfg->pl_pools[j].
                                                   pl_credits) == NULL)
                                goto out;
-                       if (cYAML_create_number(type_node, "mincredits",
+                       if (!backup &&
+                           cYAML_create_number(type_node, "mincredits",
                                                pool_cfg->pl_pools[j].
                                                   pl_mincredits) == NULL)
                                goto out;
@@ -2315,6 +2410,15 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
        }
 
        if (pool_cfg != NULL) {
+               if (backup) {
+                       if (cYAML_create_number(pools_node, "enable",
+                                               pool_cfg->pl_routing) ==
+                       NULL)
+                               goto out;
+
+                       goto add_buffer_section;
+               }
+
                item = cYAML_create_seq_item(pools_node);
                if (item == NULL)
                        goto out;
@@ -2324,6 +2428,7 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
                        goto out;
        }
 
+add_buffer_section:
        /* create a buffers entry in the show. This is necessary so that
         * if the YAML output is used to configure a node, the buffer
         * configuration takes hold */
@@ -2379,7 +2484,8 @@ out:
 }
 
 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
-                         struct cYAML **show_rc, struct cYAML **err_rc)
+                         struct cYAML **show_rc, struct cYAML **err_rc,
+                         bool backup)
 {
        /*
         * TODO: This function is changing in a future patch to accommodate
@@ -2399,7 +2505,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                     *first_seq = NULL, *peer_root = NULL, *tmp = NULL,
                     *msg_statistics = NULL, *statistics = NULL;
        char err_str[LNET_MAX_STR_LEN];
-       lnet_process_id_t *list = NULL;
+       struct lnet_process_id *list = NULL;
        void *data = NULL;
        void *lpni_data;
 
@@ -2416,7 +2522,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                goto out;
 
        count = 1000;
-       size = count * sizeof(lnet_process_id_t);
+       size = count * sizeof(struct lnet_process_id);
        list = malloc(size);
        if (list == NULL) {
                l_errno = ENOMEM;
@@ -2512,6 +2618,17 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                                        peer_info.prcfg_mr ? "True" : "False")
                    == NULL)
                        goto out;
+               /*
+                * print out the state of the peer only if details are
+                * requested
+                */
+               if (detail >= 3) {
+                       if (!backup &&
+                           cYAML_create_number(peer, "peer state",
+                                               peer_info.prcfg_state)
+                               == NULL)
+                               goto out;
+               }
 
                tmp = cYAML_create_seq(peer, "peer ni");
                if (tmp == NULL)
@@ -2534,6 +2651,9 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                            == NULL)
                                goto out;
 
+                       if (backup)
+                               continue;
+
                        if (cYAML_create_string(peer_ni, "state",
                                                lpni_cri->cr_aliveness)
                            == NULL)
@@ -2669,7 +2789,7 @@ int lustre_lnet_list_peer(int seq_no,
        int l_errno = 0;
        struct cYAML *root = NULL, *list_root = NULL, *first_seq = NULL;
        char err_str[LNET_MAX_STR_LEN];
-       lnet_process_id_t *list = NULL;
+       struct lnet_process_id *list = NULL;
 
        snprintf(err_str, sizeof(err_str),
                 "\"out of memory\"");
@@ -2686,7 +2806,7 @@ int lustre_lnet_list_peer(int seq_no,
                goto out;
 
        count = 1000;
-       size = count * sizeof(lnet_process_id_t);
+       size = count * sizeof(struct lnet_process_id);
        list = malloc(size);
        if (list == NULL) {
                l_errno = ENOMEM;
@@ -3620,8 +3740,7 @@ static int handle_yaml_show_route(struct cYAML *tree, struct cYAML **show_rc,
                                      (prio) ? prio->cy_valueint : -1,
                                      (detail) ? detail->cy_valueint : 0,
                                      (seq_no) ? seq_no->cy_valueint : -1,
-                                     show_rc,
-                                     err_rc);
+                                     show_rc, err_rc, false);
 }
 
 static int handle_yaml_show_net(struct cYAML *tree, struct cYAML **show_rc,
@@ -3636,8 +3755,7 @@ static int handle_yaml_show_net(struct cYAML *tree, struct cYAML **show_rc,
        return lustre_lnet_show_net((net) ? net->cy_valuestring : NULL,
                                    (detail) ? detail->cy_valueint : 0,
                                    (seq_no) ? seq_no->cy_valueint : -1,
-                                   show_rc,
-                                   err_rc);
+                                   show_rc, err_rc, false);
 }
 
 static int handle_yaml_show_routing(struct cYAML *tree, struct cYAML **show_rc,
@@ -3648,7 +3766,7 @@ static int handle_yaml_show_routing(struct cYAML *tree, struct cYAML **show_rc,
        seq_no = cYAML_get_object_item(tree, "seq_no");
 
        return lustre_lnet_show_routing((seq_no) ? seq_no->cy_valueint : -1,
-                                       show_rc, err_rc);
+                                       show_rc, err_rc, false);
 }
 
 static int handle_yaml_show_peers(struct cYAML *tree, struct cYAML **show_rc,
@@ -3663,7 +3781,7 @@ static int handle_yaml_show_peers(struct cYAML *tree, struct cYAML **show_rc,
        return lustre_lnet_show_peer((nid) ? nid->cy_valuestring : NULL,
                                     (detail) ? detail->cy_valueint : 0,
                                     (seq_no) ? seq_no->cy_valueint : -1,
-                                    show_rc, err_rc);
+                                    show_rc, err_rc, false);
 }
 
 static int handle_yaml_show_stats(struct cYAML *tree, struct cYAML **show_rc,
@@ -3677,6 +3795,41 @@ static int handle_yaml_show_stats(struct cYAML *tree, struct cYAML **show_rc,
                                      show_rc, err_rc);
 }
 
+static int handle_yaml_config_numa(struct cYAML *tree, struct cYAML **show_rc,
+                                 struct cYAML **err_rc)
+{
+       struct cYAML *seq_no, *range;
+
+       seq_no = cYAML_get_object_item(tree, "seq_no");
+       range = cYAML_get_object_item(tree, "range");
+
+       return lustre_lnet_config_numa_range(range ? range->cy_valueint : -1,
+                                            seq_no ? seq_no->cy_valueint : -1,
+                                            err_rc);
+}
+
+static int handle_yaml_del_numa(struct cYAML *tree, struct cYAML **show_rc,
+                              struct cYAML **err_rc)
+{
+       struct cYAML *seq_no;
+
+       seq_no = cYAML_get_object_item(tree, "seq_no");
+
+       return lustre_lnet_config_numa_range(0, seq_no ? seq_no->cy_valueint : -1,
+                                            err_rc);
+}
+
+static int handle_yaml_show_numa(struct cYAML *tree, struct cYAML **show_rc,
+                               struct cYAML **err_rc)
+{
+       struct cYAML *seq_no;
+
+       seq_no = cYAML_get_object_item(tree, "seq_no");
+
+       return lustre_lnet_show_numa_range(seq_no ? seq_no->cy_valueint : -1,
+                                          show_rc, err_rc);
+}
+
 static int handle_yaml_config_global_settings(struct cYAML *tree,
                                              struct cYAML **show_rc,
                                              struct cYAML **err_rc)
@@ -3820,6 +3973,7 @@ static struct lookup_cmd_hdlr_tbl lookup_config_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_config_buffers },
        { .name = "statistics", .cb = handle_yaml_no_op },
        { .name = "global",     .cb = handle_yaml_config_global_settings},
+       { .name = "numa",       .cb = handle_yaml_config_numa },
        { .name = "ping",       .cb = handle_yaml_no_op },
        { .name = "discover",   .cb = handle_yaml_no_op },
        { .name = NULL } };
@@ -3833,6 +3987,7 @@ static struct lookup_cmd_hdlr_tbl lookup_del_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_no_op },
        { .name = "statistics", .cb = handle_yaml_no_op },
        { .name = "global",     .cb = handle_yaml_del_global_settings},
+       { .name = "numa",       .cb = handle_yaml_del_numa },
        { .name = "ping",       .cb = handle_yaml_no_op },
        { .name = "discover",   .cb = handle_yaml_no_op },
        { .name = NULL } };
@@ -3846,6 +4001,7 @@ static struct lookup_cmd_hdlr_tbl lookup_show_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_show_routing },
        { .name = "statistics", .cb = handle_yaml_show_stats },
        { .name = "global",     .cb = handle_yaml_show_global_settings},
+       { .name = "numa",       .cb = handle_yaml_show_numa },
        { .name = "ping",       .cb = handle_yaml_no_op },
        { .name = "discover",   .cb = handle_yaml_no_op },
        { .name = NULL } };
@@ -3859,6 +4015,7 @@ static struct lookup_cmd_hdlr_tbl lookup_exec_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_no_op },
        { .name = "statistics", .cb = handle_yaml_no_op },
        { .name = "global",     .cb = handle_yaml_no_op },
+       { .name = "numa",       .cb = handle_yaml_no_op },
        { .name = "ping",       .cb = handle_yaml_ping },
        { .name = "discover",   .cb = handle_yaml_discover },
        { .name = NULL } };