Whamcloud - gitweb
LU-10391 lnet: migrate full LNet NI information collection 55/50255/25
authorJames Simmons <jsimmons@infradead.org>
Thu, 5 Oct 2023 13:52:54 +0000 (09:52 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 25 Oct 2023 18:02:20 +0000 (18:02 +0000)
Fill in the rest of the LNet NI state to report to user land. This
mostly covers the stats information of the NI and LND specific
tunables. To handle the LND specific tunables we need to reorder
the code to send an updated key table. With the additional
information I found status wasn't properly set and the nesting
for was properly set for multiple NIs per NET. This is now fixed.

Test-Parameters: trivial testlist=sanity-lnet
Fixes: 8f8f6e2f36e ("LU-10003 lnet: use Netlink to support old and new NI APIs")
Change-Id: I32b06b1ce8cb049a33f45f2310d31897ffa7dc90
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50255
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
lnet/include/lnet/lib-types.h
lnet/include/lnet/udsp.h
lnet/klnds/gnilnd/gnilnd.c
lnet/klnds/gnilnd/gnilnd.h
lnet/klnds/kfilnd/kfilnd.c
lnet/klnds/o2iblnd/o2iblnd.c
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/lnet/api-ni.c
lnet/lnet/udsp.c
lnet/utils/lnetconfig/liblnetconfig.h
lnet/utils/lnetctl.c
lustre/tests/sanity-lnet.sh

index 52470b3..72fb1e6 100644 (file)
@@ -326,6 +326,7 @@ struct lnet_lnd {
                                         unsigned int dev_idx);
 
        /* Handle LND specific Netlink handling */
+       int (*lnd_nl_get)(int cmd, struct sk_buff *msg, int type, void *data);
        int (*lnd_nl_set)(int cmd, struct nlattr *attr, int type, void *data);
 
        const struct ln_key_list *lnd_keys;
@@ -463,7 +464,7 @@ struct lnet_net {
  *
  * @LNET_NET_ATTR_UNSPEC:              unspecified attribute to catch errors
  *
- * @LNET_NET_ATTR_HDR:                 grouping for LNet net data (NLA_NESTED)
+ * @LNET_NET_ATTR_HDR:                 grouping for LNet net data (NLA_NUL_STRING)
  * @LNET_NET_ATTR_TYPE:                        LNet net this NI belongs to (NLA_STRING)
  * @LNET_NET_ATTR_LOCAL:               Local NI information (NLA_NESTED)
  */
@@ -479,15 +480,32 @@ enum lnet_net_attrs {
 
 #define LNET_NET_ATTR_MAX (__LNET_NET_ATTR_MAX_PLUS_ONE - 1)
 
-/** enum lnet_net_local_ni_attrs      - LNet local NI netlink properties
- *                                     attributes that describe local NI
+/** enum lnet_net_local_ni_attrs             - LNet local NI netlink properties
+ *                                             attributes that describe local
+ *                                             NI
  *
- * @LNET_NET_LOCAL_NI_ATTR_UNSPEC:     unspecified attribute to catch errors
+ * @LNET_NET_LOCAL_NI_ATTR_UNSPEC:             unspecified attribute to catch
+ *                                             errors
  *
- * @LNET_NET_LOCAL_NI_ATTR_NID:                NID that represents this NI (NLA_STRING)
- * @LNET_NET_LOCAL_NI_ATTR_STATUS:     State of this NI (NLA_STRING)
- * @LNET_NET_LOCAL_NI_ATTR_INTERFACE:  Defines physical devices (NLA_NESTED)
- *                                     Used to be many devices but no longer.
+ * @LNET_NET_LOCAL_NI_ATTR_NID:                        NID that represents this NI
+ *                                             (NLA_STRING)
+ * @LNET_NET_LOCAL_NI_ATTR_STATUS:             State of this NI (NLA_STRING)
+ * @LNET_NET_LOCAL_NI_ATTR_INTERFACE:          Defines physical devices. used
+ *                                             to be many devices but no longer
+ *                                             (NLA_NESTED)
+ *
+ * @LNET_NET_LOCAL_NI_ATTR_STATS:              NI general msg stats (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_UDSP_INFO:          NI UDSP state (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_SEND_STATS:         NI send stats (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_RECV_STATS:         NI recieved stats (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS:      NI dropped stats (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS:       NI health stats (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_TUNABLES:           NI tunables (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES:       NI LND tunables (NLA_NESTED)
+ * @LNET_NET_LOCAL_NI_ATTR_DEV_CPT:            NI CPT interface bound to
+ *                                             (NLA_S32)
+ * @LNET_NET_LOCAL_NI_ATTR_CPTS:               CPT core used by this NI
+ *                                             (NLA_STRING)
  */
 enum lnet_net_local_ni_attrs {
        LNET_NET_LOCAL_NI_ATTR_UNSPEC = 0,
@@ -496,6 +514,17 @@ enum lnet_net_local_ni_attrs {
        LNET_NET_LOCAL_NI_ATTR_STATUS,
        LNET_NET_LOCAL_NI_ATTR_INTERFACE,
 
+       LNET_NET_LOCAL_NI_ATTR_STATS,
+       LNET_NET_LOCAL_NI_ATTR_UDSP_INFO,
+       LNET_NET_LOCAL_NI_ATTR_SEND_STATS,
+       LNET_NET_LOCAL_NI_ATTR_RECV_STATS,
+       LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS,
+       LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS,
+       LNET_NET_LOCAL_NI_ATTR_TUNABLES,
+       LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES,
+       LNET_NET_LOCAL_NI_DEV_CPT,
+       LNET_NET_LOCAL_NI_CPTS,
+
        __LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE,
 };
 
@@ -519,6 +548,110 @@ enum lnet_net_local_ni_intf_attrs {
 
 #define LNET_NET_LOCAL_NI_INTF_ATTR_MAX (__LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE - 1)
 
+/** enum lnet_net_local_ni_stats_attrs       - LNet NI netlink properties
+ *                                             attributes that reports the
+ *                                             network traffic stats
+ *
+ * @LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC:       unspecified attribute to catch
+ *                                             errors
+ *
+ * @LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT:   Number of sent messages
+ *                                             (NLA_U32)
+ * @LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT:   Number of recieved messages
+ *                                             (NLA_U32)
+ * @LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT:   Number of dropped messages
+ *                                             (NLA_U32)
+ */
+enum lnet_net_local_ni_stats_attrs {
+       LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC = 0,
+
+       LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT,
+       LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT,
+       LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT,
+       __LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_NET_LOCAL_NI_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE - 1)
+
+/** enum lnet_net_local_ni_msg_stats_attrs           - LNet NI netlink
+ *                                                     properties attributes
+ *                                                     that reports the message
+ *                                                     type traffic stats
+ *
+ * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC:           unspecified attribute
+ *                                                     to catch errors
+ *
+ * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT:                Number of PUT messages
+ *                                                     (NLA_U32)
+ * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT:                Number of GET messages
+ *                                                     (NLA_U32)
+ * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT:      Number of REPLY messages
+ *                                                     (NLA_U32)
+ * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT:                Number of ACK messages
+ *                                                     (NLA_U32)
+ * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT:      Number of HELLO messages
+ *                                                     (NLA_U32)
+ */
+enum lnet_net_local_ni_msg_stats_attrs {
+       LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC = 0,
+
+       LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
+       LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
+       LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
+       LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
+       LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
+       __LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE - 1)
+
+/** enum lnet_net_local_ni_health_stats_attrs        - LNet NI netlink
+ *                                                     properties attributes
+ *                                                     that reports how
+ *                                                     healthly it is.
+ *
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC:                unspecified attribute
+ *                                                     to catch errors
+ *
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS:  How many fatal errors
+ *                                                     (NLA_S32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL:         How healthly is NI
+ *                                                     (NLA_S32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS:    How many interrupts
+ *                                                     happened (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED:       How much traffic has
+ *                                                     been dropped (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED:       How many aborts
+ *                                                     happened (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE:      How often routing broke
+ *                                                     (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS:      How often timeouts
+ *                                                     occurred (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR:         The number of errors
+ *                                                     reported (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT:    Number of successful
+ *                                                     ping (NLA_U32)
+ * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING:     Number of next pings
+ *                                                     (NLA_U64)
+ */
+enum lnet_net_local_ni_health_stats_attrs {
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC = 0,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PAD = LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC,
+
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT,
+       LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING,
+       __LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
+};
+#define LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
+
 /** enum lnet_net_local_ni_tunables_attrs            - LNet NI tunables
  *                                                     netlink properties.
  *                                                     Performance options
@@ -633,6 +766,51 @@ enum lnet_ping_peer_ni_attr {
 
 #define LNET_PING_PEER_NI_ATTR_MAX (__LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
 
+/** enum lnet_udsp_info_attr                         - LNet UDSP information reported for
+ *                                                     some subsystem that tracks it.
+ *
+ * @LNET_UDSP_INFO_ATTR_UNSPEC:                                unspecified attribute to catch errors
+ *
+ * @LNET_UDSP_INFO_ATTR_NET_PRIORITY,                  LNet net priority in selection.
+ *                                                     (NLA_S32)
+ * @LNET_UDSP_INFO_ATTR_NID_PRIORITY,                  NID's priority in selection.
+ *                                                     (NLA_S32)
+ * @LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST:            Which gateway's are preferred.
+ *                                                     (NLA_NESTED)
+ * @LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST:                        Which NIDs are preferred.
+ *                                                     (NLA_NESTED)
+ */
+enum lnet_udsp_info_attr {
+       LNET_UDSP_INFO_ATTR_UNSPEC = 0,
+
+       LNET_UDSP_INFO_ATTR_NET_PRIORITY,
+       LNET_UDSP_INFO_ATTR_NID_PRIORITY,
+       LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST,
+       LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST,
+       __LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_UDSP_INFO_ATTR_MAX (__LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE - 1)
+
+/** enum lnet_udsp_info_pref_nids_attr               - LNet UDSP information reported for
+ *                                                     some subsystem that tracks it.
+ *
+ * @LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC:              unspecified attribute to catch errors
+ *
+ * @LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,               UDSP prority NIDs label
+ *                                                     (NLA_NUL_STRING)
+ * @LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,                 UDSP prority NID (NLA_STRING)
+ */
+enum lnet_udsp_info_pref_nids_attr {
+       LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC = 0,
+
+       LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,
+       LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,
+       __LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX (__LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE - 1)
+
 struct lnet_ni {
        /* chain on the lnet_net structure */
        struct list_head        ni_netlist;
index 3ba5a30..5c1bef5 100644 (file)
@@ -138,6 +138,7 @@ int lnet_udsp_demarshal_add(void *bulk, __u32 bulk_size);
  *     get information of how the UDSP policies impacted the given
  *     construct.
  */
-void lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info);
+void lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info,
+                                 struct lnet_nid *nid);
 
 #endif /* UDSP_H */
index dbb8f0b..b31f3b3 100644 (file)
  */
 #include "gnilnd.h"
 
+static int
+kgnilnd_nl_get(int cmd, struct sk_buff *msg, int type, void *data)
+{
+       struct lnet_ioctl_config_gnilnd_tunables *tuns;
+       struct lnet_ni *ni = data;
+
+       if (!ni || !msg)
+               return -EINVAL;
+
+       if (cmd != LNET_CMD_NETS || type != LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES)
+               return -EOPNOTSUPP;
+
+       tuns = &ni->ni_lnd_tunables.lnd_tun_u.lnd_gni;
+       nla_put_u32(msg, LNET_NET_GNILND_TUNABLES_ATTR_LND_TIMEOUT,
+                   kgnilnd_timeout());
+}
+
 /* Primary entry points from LNET.  There are no guarantees against reentrance. */
 const struct lnet_lnd the_kgnilnd = {
        .lnd_type       = GNILND,
@@ -33,6 +50,7 @@ const struct lnet_lnd the_kgnilnd = {
        .lnd_send       = kgnilnd_send,
        .lnd_recv       = kgnilnd_recv,
        .lnd_eager_recv = kgnilnd_eager_recv,
+       .lnd_nl_get     = kgnilnd_nl_get,
 };
 
 kgn_data_t      kgnilnd_data;
index 91c5f14..3dde41f 100644 (file)
@@ -1776,6 +1776,15 @@ kgnilnd_find_net(lnet_nid_t nid, kgn_net_t **netp)
 #define KGNILND_POISON(ptr, c, s) memset(ptr, c, s)
 #endif
 
+enum kgnilnd_ni_lnd_tunables_attr {
+       LNET_NET_GNILND_TUNABLES_ATTR_UNSPEC = 0,
+
+       LNET_NET_GNILND_TUNABLES_ATTR_LND_TIMEOUT,
+       __LNET_NET_GNILND_TUNABLES_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_NET_GNILND_TUNABLES_ATTR_MAX (__LNET_NET_GNILND_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
+
 int kgnilnd_dev_init(kgn_device_t *dev);
 void kgnilnd_dev_fini(kgn_device_t *dev);
 int kgnilnd_startup(struct lnet_ni *ni);
index 3bd70c7..e3d7732 100644 (file)
@@ -366,6 +366,31 @@ static const struct ln_key_list kfilnd_tunables_keys = {
 };
 
 static int
+kfilnd_nl_get(int cmd, struct sk_buff *msg, int type, void *data)
+{
+       struct lnet_lnd_tunables *tunables;
+       struct lnet_ni *ni = data;
+
+       if (!ni || !msg)
+               return -EINVAL;
+
+       if (cmd != LNET_CMD_NETS || type != LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES)
+               return -EOPNOTSUPP;
+
+       tunables = &ni->ni_lnd_tunables;
+       nla_put_s32(msg, LNET_NET_KFILND_TUNABLES_ATTR_PROV_MAJOR,
+                   tunables->lnd_tun_u.lnd_kfi.lnd_prov_major_version);
+       nla_put_s32(msg, LNET_NET_KFILND_TUNABLES_ATTR_PROV_MINOR,
+                   tunables->lnd_tun_u.lnd_kfi.lnd_prov_minor_version);
+       nla_put_s32(msg, LNET_NET_KFILND_TUNABLES_ATTR_AUTH_KEY,
+                   tunables->lnd_tun_u.lnd_kfi.lnd_auth_key);
+       nla_put_string(msg, LNET_NET_KFILND_TUNABLES_ATTR_TRAFFIC_CLASS,
+                      tunables->lnd_tun_u.lnd_kfi.lnd_traffic_class_str);
+
+       return 0;
+}
+
+static int
 kfilnd_nl_set(int cmd, struct nlattr *attr, int type, void *data)
 {
        struct lnet_lnd_tunables *tunables = data;
@@ -407,6 +432,7 @@ static const struct lnet_lnd the_kfilnd = {
        .lnd_shutdown   = kfilnd_shutdown,
        .lnd_send       = kfilnd_send,
        .lnd_recv       = kfilnd_recv,
+       .lnd_nl_get     = kfilnd_nl_get,
        .lnd_nl_set     = kfilnd_nl_set,
        .lnd_keys       = &kfilnd_tunables_keys,
 };
index 818b900..61f8aa4 100644 (file)
@@ -1251,10 +1251,50 @@ static const struct ln_key_list kiblnd_tunables_keys = {
                        .lkp_value      = "conns_per_peer",
                        .lkp_data_type  = NLA_U16
                },
+               [LNET_NET_O2IBLND_TUNABLES_ATTR_LND_TIMEOUT] = {
+                       .lkp_value      = "timeout",
+                       .lkp_data_type  = NLA_U32,
+               },
        },
 };
 
 static int
+kiblnd_nl_get(int cmd, struct sk_buff *msg, int type, void *data)
+{
+       struct lnet_ioctl_config_o2iblnd_tunables *tuns;
+       struct lnet_ni *ni = data;
+
+       if (!ni || !msg)
+               return -EINVAL;
+
+       if (cmd != LNET_CMD_NETS || type != LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES)
+               return -EOPNOTSUPP;
+
+       tuns = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
+       nla_put_u32(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_HIW_PEER_CREDITS,
+                   tuns->lnd_peercredits_hiw);
+       if (tuns->lnd_map_on_demand) {
+               nla_put_flag(msg,
+                            LNET_NET_O2IBLND_TUNABLES_ATTR_MAP_ON_DEMAND);
+       }
+       nla_put_u32(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_CONCURRENT_SENDS,
+                   tuns->lnd_concurrent_sends);
+       nla_put_u32(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_POOL_SIZE,
+                   tuns->lnd_fmr_pool_size);
+       nla_put_u32(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_FLUSH_TRIGGER,
+                   tuns->lnd_fmr_flush_trigger);
+       nla_put_u32(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_CACHE,
+                   tuns->lnd_fmr_cache);
+       nla_put_u16(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_NTX, tuns->lnd_ntx);
+       nla_put_u16(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_CONNS_PER_PEER,
+                   tuns->lnd_conns_per_peer);
+       nla_put_u32(msg, LNET_NET_O2IBLND_TUNABLES_ATTR_LND_TIMEOUT,
+                   kiblnd_timeout());
+
+       return 0;
+}
+
+static int
 kiblnd_nl_set(int cmd, struct nlattr *attr, int type, void *data)
 {
        struct lnet_lnd_tunables *tunables = data;
@@ -3713,6 +3753,7 @@ static const struct lnet_lnd the_o2iblnd = {
        .lnd_send       = kiblnd_send,
        .lnd_recv       = kiblnd_recv,
        .lnd_get_dev_prio = kiblnd_get_dev_prio,
+       .lnd_nl_get     = kiblnd_nl_get,
        .lnd_nl_set     = kiblnd_nl_set,
        .lnd_keys       = &kiblnd_tunables_keys,
 };
index 621540a..f9727d4 100644 (file)
@@ -111,6 +111,7 @@ enum kiblnd_ni_lnd_tunables_attr {
        LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_CACHE,
        LNET_NET_O2IBLND_TUNABLES_ATTR_NTX,
        LNET_NET_O2IBLND_TUNABLES_ATTR_CONNS_PER_PEER,
+       LNET_NET_O2IBLND_TUNABLES_ATTR_LND_TIMEOUT,
        __LNET_NET_O2IBLND_TUNABLES_ATTR_MAX_PLUS_ONE,
 };
 
index 019b264..23a5345 100644 (file)
@@ -806,12 +806,37 @@ static const struct ln_key_list ksocknal_tunables_keys = {
        .lkl_list                       = {
                [LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER]  = {
                        .lkp_value      = "conns_per_peer",
-                       .lkp_data_type  = NLA_S32
+                       .lkp_data_type  = NLA_U16
+               },
+               [LNET_NET_SOCKLND_TUNABLES_ATTR_LND_TIMEOUT]    = {
+                       .lkp_value      = "timeout",
+                       .lkp_data_type  = NLA_U32
                },
        },
 };
 
 static int
+ksocknal_nl_get(int cmd, struct sk_buff *msg, int type, void *data)
+{
+       struct lnet_lnd_tunables *tun;
+       struct lnet_ni *ni = data;
+
+       if (!ni || !msg)
+               return -EINVAL;
+
+        if (cmd != LNET_CMD_NETS || type != LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES)
+               return -EOPNOTSUPP;
+
+       tun = &ni->ni_lnd_tunables;
+       nla_put_u16(msg, LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER,
+                   tun->lnd_tun_u.lnd_sock.lnd_conns_per_peer);
+       nla_put_u32(msg, LNET_NET_SOCKLND_TUNABLES_ATTR_LND_TIMEOUT,
+                   ksocknal_timeout());
+
+       return 0;
+}
+
+static int
 ksocknal_nl_set(int cmd, struct nlattr *attr, int type, void *data)
 {
        struct lnet_lnd_tunables *tunables = data;
@@ -2590,6 +2615,7 @@ static const struct lnet_lnd the_ksocklnd = {
        .lnd_recv               = ksocknal_recv,
        .lnd_notify_peer_down   = ksocknal_notify_gw_down,
        .lnd_accept             = ksocknal_accept,
+       .lnd_nl_get             = ksocknal_nl_get,
        .lnd_nl_set             = ksocknal_nl_set,
        .lnd_keys               = &ksocknal_tunables_keys,
 };
index b8c1fd9..f34ffec 100644 (file)
@@ -87,6 +87,7 @@ enum ksocklnd_ni_lnd_tunables_attr {
        LNET_NET_SOCKLND_TUNABLES_ATTR_UNSPEC = 0,
 
        LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER,
+       LNET_NET_SOCKLND_TUNABLES_ATTR_LND_TIMEOUT,
        __LNET_NET_SOCKLND_TUNABLES_ATTR_MAX_PLUS_ONE,
 };
 
index bc82b02..6a390e9 100644 (file)
@@ -3480,14 +3480,11 @@ lnet_get_ni_config(struct lnet_ioctl_config_ni *cfg_ni,
 static int lnet_get_ni_stats(struct lnet_ioctl_element_msg_stats *msg_stats)
 {
        struct lnet_ni *ni;
-       int cpt;
        int rc = -ENOENT;
 
        if (!msg_stats)
                return -EINVAL;
 
-       cpt = lnet_net_lock_current();
-
        ni = lnet_get_ni_idx_locked(msg_stats->im_idx);
 
        if (ni) {
@@ -3495,8 +3492,6 @@ static int lnet_get_ni_stats(struct lnet_ioctl_element_msg_stats *msg_stats)
                rc = 0;
        }
 
-       lnet_net_unlock(cpt);
-
        return rc;
 }
 
@@ -4200,12 +4195,17 @@ LNetCtl(unsigned int cmd, void *arg)
 
        case IOC_LIBCFS_GET_LOCAL_NI_MSG_STATS: {
                struct lnet_ioctl_element_msg_stats *msg_stats = arg;
+               int cpt;
 
                if (msg_stats->im_hdr.ioc_len != sizeof(*msg_stats))
                        return -EINVAL;
 
                mutex_lock(&the_lnet.ln_api_mutex);
+
+               cpt = lnet_net_lock_current();
                rc = lnet_get_ni_stats(msg_stats);
+               lnet_net_unlock(cpt);
+
                mutex_unlock(&the_lnet.ln_api_mutex);
 
                return rc;
@@ -4699,8 +4699,11 @@ report_ping_err:
                CDEBUG(D_NET, "GET_UDSP_INFO for %s\n",
                       libcfs_nid2str(info->cud_nid));
 
+               lnet_nid4_to_nid(info->cud_nid, &nid);
                mutex_lock(&the_lnet.ln_api_mutex);
-               lnet_udsp_get_construct_info(info);
+               lnet_net_lock(0);
+               lnet_udsp_get_construct_info(info, &nid);
+               lnet_net_unlock(0);
                mutex_unlock(&the_lnet.ln_api_mutex);
 
                return 0;
@@ -4723,6 +4726,99 @@ report_ping_err:
 }
 EXPORT_SYMBOL(LNetCtl);
 
+/* This is the keys for the UDSP info which is used by many
+ * Netlink commands.
+ */
+static const struct ln_key_list udsp_info_list = {
+       .lkl_maxattr                    = LNET_UDSP_INFO_ATTR_MAX,
+       .lkl_list                       = {
+               [LNET_UDSP_INFO_ATTR_NET_PRIORITY]              = {
+                       .lkp_value      = "net priority",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_UDSP_INFO_ATTR_NID_PRIORITY]              = {
+                       .lkp_value      = "nid priority",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST]        = {
+                       .lkp_value      = "Preferred gateway NIDs",
+                       .lkp_key_format = LNKF_MAPPING,
+                       .lkp_data_type  = NLA_NESTED,
+               },
+               [LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST]            = {
+                       .lkp_value      = "Preferred source NIDs",
+                       .lkp_key_format = LNKF_MAPPING,
+                       .lkp_data_type  = NLA_NESTED,
+               },
+       },
+};
+
+static const struct ln_key_list udsp_info_pref_nids_list = {
+       .lkl_maxattr                    = LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX,
+       .lkl_list                       = {
+               [LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX]           = {
+                       .lkp_value      = "NID-0",
+                       .lkp_data_type  = NLA_NUL_STRING,
+               },
+               [LNET_UDSP_INFO_PREF_NIDS_ATTR_NID]             = {
+                       .lkp_value      = "0@lo",
+                       .lkp_data_type  = NLA_STRING,
+               },
+       },
+};
+
+static int lnet_udsp_info_send(struct sk_buff *msg, int attr,
+                              struct lnet_nid *nid, bool remote)
+{
+       struct lnet_ioctl_construct_udsp_info *udsp;
+       struct nlattr *udsp_attr, *udsp_info;
+       struct nlattr *udsp_list_attr;
+       struct nlattr *udsp_list_info;
+       int i;
+
+       CFS_ALLOC_PTR(udsp);
+       if (!udsp)
+               return -ENOMEM;
+
+       udsp->cud_peer = remote;
+       lnet_udsp_get_construct_info(udsp, nid);
+
+       udsp_info = nla_nest_start(msg, attr);
+       udsp_attr = nla_nest_start(msg, 0);
+       nla_put_s32(msg, LNET_UDSP_INFO_ATTR_NET_PRIORITY,
+                   udsp->cud_net_priority);
+       nla_put_s32(msg, LNET_UDSP_INFO_ATTR_NID_PRIORITY,
+                   udsp->cud_nid_priority);
+
+       if (udsp->cud_pref_rtr_nid[0] == 0)
+               goto skip_list;
+
+       udsp_list_info = nla_nest_start(msg,
+                                       LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST);
+       for (i = 0; i < LNET_MAX_SHOW_NUM_NID; i++) {
+               char tmp[8]; /* NID-"3 number"\0 */
+
+               if (udsp->cud_pref_rtr_nid[i] == 0)
+                       break;
+
+               udsp_list_attr = nla_nest_start(msg, i);
+               snprintf(tmp, sizeof(tmp), "NID-%d", i);
+               nla_put_string(msg, LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,
+                              tmp);
+               nla_put_string(msg, LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,
+                              libcfs_nid2str(udsp->cud_pref_rtr_nid[i]));
+               nla_nest_end(msg, udsp_list_attr);
+       }
+       nla_nest_end(msg, udsp_list_info);
+skip_list:
+       nla_nest_end(msg, udsp_attr);
+       nla_nest_end(msg, udsp_info);
+       LIBCFS_FREE(udsp, sizeof(*udsp));
+
+       return 0;
+}
+
+/* LNet NI handling */
 static const struct ln_key_list net_props_list = {
        .lkl_maxattr                    = LNET_NET_ATTR_MAX,
        .lkl_list                       = {
@@ -4746,19 +4842,68 @@ static const struct ln_key_list net_props_list = {
 static struct ln_key_list local_ni_list = {
        .lkl_maxattr                    = LNET_NET_LOCAL_NI_ATTR_MAX,
        .lkl_list                       = {
-               [LNET_NET_LOCAL_NI_ATTR_NID]    = {
+               [LNET_NET_LOCAL_NI_ATTR_NID]            = {
                        .lkp_value              = "nid",
                        .lkp_data_type          = NLA_STRING
                },
-               [LNET_NET_LOCAL_NI_ATTR_STATUS] = {
+               [LNET_NET_LOCAL_NI_ATTR_STATUS]         = {
                        .lkp_value              = "status",
                        .lkp_data_type          = NLA_STRING
                },
-               [LNET_NET_LOCAL_NI_ATTR_INTERFACE] = {
+               [LNET_NET_LOCAL_NI_ATTR_INTERFACE]      = {
                        .lkp_value              = "interfaces",
                        .lkp_key_format         = LNKF_MAPPING,
                        .lkp_data_type          = NLA_NESTED
                },
+               [LNET_NET_LOCAL_NI_ATTR_STATS]          = {
+                       .lkp_value              = "statistics",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_ATTR_UDSP_INFO]      = {
+                       .lkp_value              = "udsp info",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_ATTR_SEND_STATS]     = {
+                       .lkp_value              = "sent_stats",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_ATTR_RECV_STATS]     = {
+                       .lkp_value              = "received_stats",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS]  = {
+                       .lkp_value              = "dropped_stats",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+
+               },
+               [LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS]   = {
+                       .lkp_value              = "health stats",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_ATTR_TUNABLES]       = {
+                       .lkp_value              = "tunables",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES]   = {
+                       .lkp_value              = "lnd tunables",
+                       .lkp_key_format         = LNKF_MAPPING,
+                       .lkp_data_type          = NLA_NESTED
+               },
+               [LNET_NET_LOCAL_NI_DEV_CPT]             = {
+                       .lkp_value              = "dev cpt",
+                       .lkp_data_type          = NLA_S32,
+               },
+               [LNET_NET_LOCAL_NI_CPTS]                = {
+                       .lkp_value              = "CPT",
+                       .lkp_data_type          = NLA_STRING,
+               },
        },
 };
 
@@ -4772,6 +4917,118 @@ static const struct ln_key_list local_ni_interfaces_list = {
        },
 };
 
+static const struct ln_key_list local_ni_stats_list = {
+       .lkl_maxattr                    = LNET_NET_LOCAL_NI_STATS_ATTR_MAX,
+       .lkl_list                       = {
+               [LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT]       = {
+                       .lkp_value      = "send_count",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT]       = {
+                       .lkp_value      = "recv_count",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT]       = {
+                       .lkp_value      = "drop_count",
+                       .lkp_data_type  = NLA_U32
+               },
+       },
+};
+
+static const struct ln_key_list local_ni_msg_stats_list = {
+       .lkl_maxattr                    = LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX,
+       .lkl_list                       = {
+               [LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT]    = {
+                       .lkp_value      = "put",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT]    = {
+                       .lkp_value      = "get",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT]  = {
+                       .lkp_value      = "reply",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT]    = {
+                       .lkp_value      = "ack",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT]  = {
+                       .lkp_value      = "hello",
+                       .lkp_data_type  = NLA_U32
+               },
+       },
+};
+
+static const struct ln_key_list local_ni_health_stats_list = {
+       .lkl_maxattr                    = LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX,
+       .lkl_list                       = {
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS] = {
+                       .lkp_value      = "fatal_error",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL] = {
+                       .lkp_value      = "health value",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS] = {
+                       .lkp_value      = "interrupts",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED] = {
+                       .lkp_value      = "dropped",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED] = {
+                       .lkp_value      = "aborted",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE] = {
+                       .lkp_value      = "no route",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS] = {
+                       .lkp_value      = "timeouts",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR] = {
+                       .lkp_value      = "error",
+                       .lkp_data_type  = NLA_U32
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT] = {
+                       .lkp_value      = "ping_count",
+                       .lkp_data_type  = NLA_U32,
+               },
+               [LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING] = {
+                       .lkp_value      = "next_ping",
+                       .lkp_data_type  = NLA_U64
+               },
+       },
+};
+
+static const struct ln_key_list local_ni_tunables_list = {
+       .lkl_maxattr                    = LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX,
+       .lkl_list                       = {
+               [LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT]  = {
+                       .lkp_value      = "peer_timeout",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS]  = {
+                       .lkp_value      = "peer_credits",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS] = {
+                       .lkp_value      = "peer_buffer_credits",
+                       .lkp_data_type  = NLA_S32
+               },
+               [LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS] = {
+                       .lkp_value      = "credits",
+                       .lkp_data_type  = NLA_S32
+               },
+       },
+};
+
 /* Use an index since the traversal is across LNet nets and ni collections */
 struct lnet_genl_net_list {
        unsigned int    lngl_net_id;
@@ -4878,73 +5135,110 @@ static int lnet_net_show_dump(struct sk_buff *msg,
 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
        struct netlink_ext_ack *extack = NULL;
 #endif
+       struct genlmsghdr *gnlh = nlmsg_data(cb->nlh);
        int portid = NETLINK_CB(cb->skb).portid;
+       bool found = false, started = true;
+       const struct lnet_lnd *lnd = NULL;
+       int idx = nlist->lngl_idx, rc = 0;
        int seq = cb->nlh->nlmsg_seq;
        struct lnet_net *net;
-       int idx = 0, rc = 0;
-       bool found = false;
        void *hdr = NULL;
 
 #ifdef HAVE_NL_DUMP_WITH_EXT_ACK
        extack = cb->extack;
 #endif
-       if (!nlist->lngl_idx) {
-               const struct ln_key_list *all[] = {
-                       &net_props_list, &local_ni_list,
-                       &local_ni_interfaces_list,
-                       NULL
-               };
-
-               rc = lnet_genl_send_scalar_list(msg, portid, seq,
-                                               &lnet_family,
-                                               NLM_F_CREATE | NLM_F_MULTI,
-                                               LNET_CMD_NETS, all);
-               if (rc < 0) {
-                       NL_SET_ERR_MSG(extack, "failed to send key table");
-                       GOTO(send_error, rc);
-               }
-       }
-
        lnet_net_lock(LNET_LOCK_EX);
 
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
+               struct nlattr *local_ni, *ni_attr;
                struct lnet_ni *ni;
+               int dev = 0;
 
                if (nlist->lngl_net_id != LNET_NET_ANY &&
                    nlist->lngl_net_id != net->net_id)
                        continue;
 
-               list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       struct nlattr *local_ni, *ni_attr;
-                       char *status = "up";
+               if (gnlh->version && LNET_NETTYP(net->net_id) != LOLND) {
+                       if (!net->net_lnd) {
+                               NL_SET_ERR_MSG(extack,
+                                              "LND not setup for NI");
+                               GOTO(net_unlock, rc = -ENODEV);
+                       }
+                       if (net->net_lnd != lnd)
+                               lnd = net->net_lnd;
+                       else
+                               lnd = NULL;
+               }
 
-                       if (idx++ < nlist->lngl_idx)
-                               continue;
+               /* We need to resend the key table every time the base LND
+                * changed.
+                */
+               if (!idx || lnd) {
+                       const struct ln_key_list *all[] = {
+                               &net_props_list, &local_ni_list,
+                               &local_ni_interfaces_list,
+                               &local_ni_stats_list,
+                               &udsp_info_list,
+                               &udsp_info_pref_nids_list,
+                               &udsp_info_pref_nids_list,
+                               &local_ni_msg_stats_list,
+                               &local_ni_msg_stats_list,
+                               &local_ni_msg_stats_list,
+                               &local_ni_health_stats_list,
+                               &local_ni_tunables_list,
+                               NULL, /* lnd tunables */
+                               NULL
+                       };
+                       int flags = NLM_F_CREATE | NLM_F_MULTI;
 
-                       hdr = genlmsg_put(msg, portid, seq, &lnet_family,
-                                         NLM_F_MULTI, LNET_CMD_NETS);
-                       if (!hdr) {
-                               NL_SET_ERR_MSG(extack, "failed to send values");
-                               GOTO(net_unlock, rc = -EMSGSIZE);
+                       if (lnd) {
+                               all[ARRAY_SIZE(all) - 2] = lnd->lnd_keys;
+                               if (idx)
+                                       flags |= NLM_F_REPLACE;
+                               started = true;
+                       }
+
+                       rc = lnet_genl_send_scalar_list(msg, portid, seq,
+                                                       &lnet_family, flags,
+                                                       LNET_CMD_NETS, all);
+                       if (rc < 0) {
+                               NL_SET_ERR_MSG(extack, "failed to send key table");
+                               GOTO(net_unlock, rc);
                        }
+               }
 
-                       if (idx == 1)
-                               nla_put_string(msg, LNET_NET_ATTR_HDR, "");
+               hdr = genlmsg_put(msg, portid, seq, &lnet_family,
+                                 NLM_F_MULTI, LNET_CMD_NETS);
+               if (!hdr) {
+                       NL_SET_ERR_MSG(extack, "failed to send values");
+                       GOTO(net_unlock, rc = -EMSGSIZE);
+               }
 
-                       nla_put_string(msg, LNET_NET_ATTR_TYPE,
-                                      libcfs_net2str(net->net_id));
-                       found = true;
+               if (started) {
+                       nla_put_string(msg, LNET_NET_ATTR_HDR, "");
+                       started = false;
+               }
+
+               nla_put_string(msg, LNET_NET_ATTR_TYPE,
+                              libcfs_net2str(net->net_id));
+
+               local_ni = nla_nest_start(msg, LNET_NET_ATTR_LOCAL);
+               list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
+                       char *status = "up";
 
-                       local_ni = nla_nest_start(msg, LNET_NET_ATTR_LOCAL);
-                       ni_attr = nla_nest_start(msg, idx - 1);
+                       if (idx++ < nlist->lngl_idx)
+                               continue;
 
+                       ni_attr = nla_nest_start(msg, dev++);
+                       found = true;
                        lnet_ni_lock(ni);
                        nla_put_string(msg, LNET_NET_LOCAL_NI_ATTR_NID,
                                       libcfs_nidstr(&ni->ni_nid));
-                       if (nid_is_lo0(&ni->ni_nid) &&
+                       if (!nid_is_lo0(&ni->ni_nid) &&
                            *ni->ni_status != LNET_NI_STATUS_UP)
                                status = "down";
-                       nla_put_string(msg, LNET_NET_LOCAL_NI_ATTR_STATUS, "up");
+                       nla_put_string(msg, LNET_NET_LOCAL_NI_ATTR_STATUS,
+                                      status);
 
                        if (!nid_is_lo0(&ni->ni_nid) && ni->ni_interface) {
                                struct nlattr *intf_nest, *intf_attr;
@@ -4959,12 +5253,210 @@ static int lnet_net_show_dump(struct sk_buff *msg,
                                nla_nest_end(msg, intf_nest);
                        }
 
-                       lnet_ni_unlock(ni);
-                       nla_nest_end(msg, ni_attr);
-                       nla_nest_end(msg, local_ni);
+                       if (gnlh->version) {
+                               char cpts[LNET_MAX_SHOW_NUM_CPT * 4 + 4], *cpt;
+                               struct lnet_ioctl_element_msg_stats msg_stats;
+                               struct lnet_ioctl_element_stats stats;
+                               size_t buf_len = sizeof(cpts), len;
+                               struct nlattr *health_attr, *health_stats;
+                               struct nlattr *send_attr, *send_stats;
+                               struct nlattr *recv_attr, *recv_stats;
+                               struct nlattr *drop_attr, *drop_stats;
+                               struct nlattr *stats_attr, *ni_stats;
+                               struct nlattr *tun_attr, *ni_tun;
+                               int j;
+
+                               stats.iel_send_count = lnet_sum_stats(&ni->ni_stats,
+                                                                     LNET_STATS_TYPE_SEND);
+                               stats.iel_recv_count = lnet_sum_stats(&ni->ni_stats,
+                                                                     LNET_STATS_TYPE_RECV);
+                               stats.iel_drop_count = lnet_sum_stats(&ni->ni_stats,
+                                                                     LNET_STATS_TYPE_DROP);
+                               lnet_ni_unlock(ni);
+
+                               stats_attr = nla_nest_start(msg, LNET_NET_LOCAL_NI_ATTR_STATS);
+                               ni_stats = nla_nest_start(msg, 0);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT,
+                                           stats.iel_send_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT,
+                                           stats.iel_recv_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT,
+                                           stats.iel_drop_count);
+                               nla_nest_end(msg, ni_stats);
+                               nla_nest_end(msg, stats_attr);
+
+                               if (gnlh->version < 4)
+                                       goto skip_udsp;
+
+                               /* UDSP info */
+                               rc = lnet_udsp_info_send(msg, LNET_NET_LOCAL_NI_ATTR_UDSP_INFO,
+                                                        &ni->ni_nid, false);
+                               if (rc < 0) {
+                                       NL_SET_ERR_MSG(extack,
+                                                      "Failed to get udsp info");
+                                       genlmsg_cancel(msg, hdr);
+                                       GOTO(net_unlock, rc = -ENOMEM);
+                               }
+skip_udsp:
+                               if (gnlh->version < 2)
+                                       goto skip_msg_stats;
 
-                       genlmsg_end(msg, hdr);
+                               msg_stats.im_idx = idx - 1;
+                               rc = lnet_get_ni_stats(&msg_stats);
+                               if (rc < 0) {
+                                       NL_SET_ERR_MSG(extack,
+                                                      "failed to get msg stats");
+                                       genlmsg_cancel(msg, hdr);
+                                       GOTO(net_unlock, rc = -ENOMEM);
+                               }
+
+                               send_stats = nla_nest_start(msg, LNET_NET_LOCAL_NI_ATTR_SEND_STATS);
+                               send_attr = nla_nest_start(msg, 0);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
+                                           msg_stats.im_send_stats.ico_get_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
+                                           msg_stats.im_send_stats.ico_put_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
+                                           msg_stats.im_send_stats.ico_reply_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
+                                           msg_stats.im_send_stats.ico_ack_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
+                                           msg_stats.im_send_stats.ico_hello_count);
+                               nla_nest_end(msg, send_attr);
+                               nla_nest_end(msg, send_stats);
+
+                               recv_stats = nla_nest_start(msg, LNET_NET_LOCAL_NI_ATTR_RECV_STATS);
+                               recv_attr = nla_nest_start(msg, 0);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
+                                           msg_stats.im_recv_stats.ico_get_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
+                                           msg_stats.im_recv_stats.ico_put_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
+                                           msg_stats.im_recv_stats.ico_reply_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
+                                           msg_stats.im_recv_stats.ico_ack_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
+                                           msg_stats.im_recv_stats.ico_hello_count);
+                               nla_nest_end(msg, recv_attr);
+                               nla_nest_end(msg, recv_stats);
+
+                               drop_stats = nla_nest_start(msg,
+                                                           LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS);
+                               drop_attr = nla_nest_start(msg, 0);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
+                                           msg_stats.im_drop_stats.ico_get_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
+                                           msg_stats.im_drop_stats.ico_put_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
+                                           msg_stats.im_drop_stats.ico_reply_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
+                                           msg_stats.im_drop_stats.ico_ack_count);
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
+                                           msg_stats.im_drop_stats.ico_hello_count);
+                               nla_nest_end(msg, drop_attr);
+                               nla_nest_end(msg, drop_stats);
+
+                               /* health stats */
+                               health_stats = nla_nest_start(msg,
+                                                             LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS);
+                               health_attr = nla_nest_start(msg, 0);
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS,
+                                           atomic_read(&ni->ni_fatal_error_on));
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL,
+                                           atomic_read(&ni->ni_healthv));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS,
+                                           atomic_read(&ni->ni_hstats.hlt_local_interrupt));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED,
+                                           atomic_read(&ni->ni_hstats.hlt_local_dropped));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED,
+                                           atomic_read(&ni->ni_hstats.hlt_local_aborted));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE,
+                                           atomic_read(&ni->ni_hstats.hlt_local_no_route));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS,
+                                           atomic_read(&ni->ni_hstats.hlt_local_timeout));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR,
+                                           atomic_read(&ni->ni_hstats.hlt_local_error));
+                               nla_put_u32(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT,
+                                           ni->ni_ping_count);
+                               nla_put_u64_64bit(msg, LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING,
+                                                 ni->ni_next_ping,
+                                                 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PAD);
+                               nla_nest_end(msg, health_attr);
+                               nla_nest_end(msg, health_stats);
+skip_msg_stats:
+                               /* Report net tunables */
+                               tun_attr = nla_nest_start(msg, LNET_NET_LOCAL_NI_ATTR_TUNABLES);
+                               ni_tun = nla_nest_start(msg, 0);
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT,
+                                           ni->ni_net->net_tunables.lct_peer_timeout);
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS,
+                                           ni->ni_net->net_tunables.lct_peer_tx_credits);
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS,
+                                           ni->ni_net->net_tunables.lct_peer_rtr_credits);
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS,
+                                           ni->ni_net->net_tunables.lct_max_tx_credits);
+                               nla_nest_end(msg, ni_tun);
+
+                               nla_nest_end(msg, tun_attr);
+
+                               if (lnd && lnd->lnd_nl_get && lnd->lnd_keys) {
+                                       struct nlattr *lnd_tun_attr, *lnd_ni_tun;
+
+                                       lnd_tun_attr = nla_nest_start(msg,
+                                                                     LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES);
+                                       lnd_ni_tun = nla_nest_start(msg, 0);
+                                       rc = lnd->lnd_nl_get(LNET_CMD_NETS, msg,
+                                                            LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES,
+                                                            ni);
+                                       if (rc < 0) {
+                                               NL_SET_ERR_MSG(extack,
+                                                              "failed to get lnd tunables");
+                                               genlmsg_cancel(msg, hdr);
+                                               GOTO(net_unlock, rc);
+                                       }
+                                       nla_nest_end(msg, lnd_ni_tun);
+                                       nla_nest_end(msg, lnd_tun_attr);
+                               }
+
+                               nla_put_s32(msg, LNET_NET_LOCAL_NI_DEV_CPT, ni->ni_dev_cpt);
+
+                               /* Report cpts. We could send this as a nested list
+                                * of integers but older versions of the tools
+                                * except a string. The new versions can handle
+                                * both formats so in the future we can change
+                                * this to a nested list.
+                                */
+                               len = snprintf(cpts, buf_len, "\"[");
+                               cpt = cpts + len;
+                               buf_len -= len;
+
+                               if (ni->ni_ncpts == LNET_CPT_NUMBER && !ni->ni_cpts)  {
+                                       for (j = 0; j < ni->ni_ncpts; j++) {
+                                               len = snprintf(cpt, buf_len, "%d,", j);
+                                               buf_len -= len;
+                                               cpt += len;
+                                       }
+                               } else {
+                                       for (j = 0;
+                                            ni->ni_cpts && j < ni->ni_ncpts &&
+                                            j < LNET_MAX_SHOW_NUM_CPT; j++) {
+                                               len = snprintf(cpt, buf_len, "%d,",
+                                                              ni->ni_cpts[j]);
+                                               buf_len -= len;
+                                               cpt += len;
+                                       }
+                               }
+                               snprintf(cpt - 1, sizeof(cpts), "]\"");
+
+                               nla_put_string(msg, LNET_NET_LOCAL_NI_CPTS, cpts);
+                       } else {
+                               lnet_ni_unlock(ni);
+                       }
+                       nla_nest_end(msg, ni_attr);
                }
+               nla_nest_end(msg, local_ni);
+
+               genlmsg_end(msg, hdr);
        }
 
        if (!found) {
@@ -4974,10 +5466,9 @@ static int lnet_net_show_dump(struct sk_buff *msg,
                NL_SET_ERR_MSG(extack, "Network is down");
                rc = -ESRCH;
        }
+       nlist->lngl_idx = idx;
 net_unlock:
        lnet_net_unlock(LNET_LOCK_EX);
-send_error:
-       nlist->lngl_idx = idx;
 
        return lnet_nl_send_error(cb->skb, portid, seq, rc);
 }
@@ -5127,7 +5618,7 @@ lnet_genl_parse_local_ni(struct nlattr *entry, struct genl_info *info,
                                if (nla_type(intf) !=
                                    LN_SCALAR_ATTR_VALUE) {
                                        GENL_SET_ERR_MSG(info,
-                                                        "0 key is invalid");
+                                                        "cannot parse interface");
                                        GOTO(out, rc = -EINVAL);
                                }
 
@@ -5307,10 +5798,10 @@ static int lnet_net_cmd(struct sk_buff *skb, struct genl_info *info)
        }
 
        nla_for_each_nested(attr, params, rem) {
+               bool ni_list = false, ipnets = false;
                struct lnet_ioctl_config_ni conf;
                u32 net_id = LNET_NET_ANY;
                struct nlattr *entry;
-               bool ni_list = false;
                int rem2;
 
                if (nla_type(attr) != LN_SCALAR_ATTR_LIST)
@@ -5340,6 +5831,7 @@ static int lnet_net_cmd(struct sk_buff *skb, struct genl_info *info)
                                                GOTO(out, rc = len);
                                        }
                                        ni_list = true;
+                                       ipnets = true;
                                } else if (nla_strcmp(entry, "net type") == 0) {
                                        char tmp[LNET_NIDSTR_SIZE];
 
@@ -5382,6 +5874,7 @@ static int lnet_net_cmd(struct sk_buff *skb, struct genl_info *info)
                                struct nlattr *interface;
                                int rem3;
 
+                               ipnets = false;
                                nla_for_each_nested(interface, entry, rem3) {
                                        rc = lnet_genl_parse_local_ni(interface, info,
                                                                      net_id, &conf,
@@ -5407,6 +5900,13 @@ static int lnet_net_cmd(struct sk_buff *skb, struct genl_info *info)
                                GENL_SET_ERR_MSG(info,
                                                 "cannot del network");
                        }
+               } else if ((info->nlhdr->nlmsg_flags & NLM_F_CREATE) &&
+                          ipnets && ni_list) {
+                       rc = lnet_handle_legacy_ip2nets(conf.lic_legacy_ip2nets,
+                                                       NULL);
+                       if (rc < 0)
+                               GENL_SET_ERR_MSG(info,
+                                                "cannot setup ip2nets");
                }
        }
 out:
index a22a611..508b81a 100644 (file)
@@ -1056,29 +1056,26 @@ lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info,
 }
 
 void
-lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info)
+lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info,
+                            struct lnet_nid *nid)
 {
        struct lnet_ni *ni;
        struct lnet_peer_ni *lpni;
-       struct lnet_nid nid;
 
-       lnet_net_lock(0);
-       lnet_nid4_to_nid(info->cud_nid, &nid);
        if (!info->cud_peer) {
-               ni = lnet_nid_to_ni_locked(&nid, 0);
+               ni = lnet_nid_to_ni_locked(nid, 0);
                if (ni)
                        lnet_udsp_get_ni_info(info, ni);
        } else {
-               lpni = lnet_peer_ni_find_locked(&nid);
+               lpni = lnet_peer_ni_find_locked(nid);
                if (!lpni) {
                        CDEBUG(D_NET, "nid %s is not found\n",
-                              libcfs_nidstr(&nid));
+                              libcfs_nidstr(nid));
                } else {
                        lnet_udsp_get_peer_info(info, lpni);
                        lnet_peer_ni_decref_locked(lpni);
                }
        }
-       lnet_net_unlock(0);
 }
 
 struct lnet_udsp *
index 14101ab..d7c8acc 100644 (file)
@@ -63,6 +63,7 @@
 
 #define MAX_NUM_IPS            128
 #define INT_STRING_LEN         23
+#define LNET_DEFAULT_INDENT    6
 
 #define modparam_path "/sys/module/lnet/parameters/"
 #define o2ib_modparam_path "/sys/module/ko2iblnd/parameters/"
index b5d9d16..af5bacf 100644 (file)
@@ -940,7 +940,7 @@ static void yaml_lnet_print_error(int op, char *cmd, const char *errstr)
        snprintf(errcode, sizeof(errcode), "%d", errno);
 
        yaml_emitter_initialize(&log);
-       yaml_emitter_set_indent(&log, 6);
+       yaml_emitter_set_indent(&log, LNET_DEFAULT_INDENT);
        yaml_emitter_set_output_file(&log, stderr);
 
        yaml_emitter_open(&log);
@@ -1518,8 +1518,8 @@ static int yaml_add_ni_tunables(yaml_emitter_t *output,
                                struct lnet_ioctl_config_lnd_tunables *tunables,
                                struct lnet_dlc_network_descr *nw_descr)
 {
+       char num[INT_STRING_LEN];
        yaml_event_t event;
-       char num[23];
        int rc;
 
        if (tunables->lt_cmn.lct_peer_timeout < 0 &&
@@ -1746,23 +1746,24 @@ static int yaml_lnet_config_ni(char *net_id, char *ip2net,
                               struct lnet_dlc_network_descr *nw_descr,
                               struct lnet_ioctl_config_lnd_tunables *tunables,
                               struct cfs_expr_list *global_cpts,
-                              int flags)
+                              int version, int flags)
 {
        struct lnet_dlc_intf_descr *intf;
        struct nl_sock *sk = NULL;
+       const char *msg = NULL;
        yaml_emitter_t output;
        yaml_parser_t reply;
        yaml_event_t event;
        int rc;
 
-       if (!ip2net && (!nw_descr || nw_descr->nw_id == 0)) {
+       if (!(flags & NLM_F_DUMP) && !ip2net && (!nw_descr || nw_descr->nw_id == 0)) {
                fprintf(stdout, "missing mandatory parameters in NI config: '%s'",
                        (!nw_descr) ? "network , interface" :
                        (nw_descr->nw_id == 0) ? "network" : "interface");
                return -EINVAL;
        }
 
-       if ((flags == NLM_F_CREATE) && list_empty(&nw_descr->nw_intflist)) {
+       if ((flags == NLM_F_CREATE) && !ip2net && list_empty(&nw_descr->nw_intflist)) {
                fprintf(stdout, "creating a local NI needs at least one interface");
                return -EINVAL;
        }
@@ -1780,17 +1781,20 @@ static int yaml_lnet_config_ni(char *net_id, char *ip2net,
        }
 
        rc = yaml_parser_set_input_netlink(&reply, sk, false);
-       if (rc == 0)
+       if (rc == 0) {
+               msg = yaml_parser_get_reader_error(&reply);
                goto free_reply;
+       }
 
        /* Create Netlink emitter to send request to kernel */
        rc = yaml_emitter_initialize(&output);
-       if (rc == 0)
+       if (rc == 0) {
+               msg = "failed to initialize emitter";
                goto free_reply;
+       }
 
        rc = yaml_emitter_set_output_netlink(&output, sk, LNET_GENL_NAME,
-                                            LNET_GENL_VERSION, LNET_CMD_NETS,
-                                            flags);
+                                            version, LNET_CMD_NETS, flags);
        if (rc == 0)
                goto emitter_error;
 
@@ -1864,7 +1868,7 @@ static int yaml_lnet_config_ni(char *net_id, char *ip2net,
                goto no_net_id;
        }
 
-       if (list_empty(&nw_descr->nw_intflist))
+       if (!nw_descr || list_empty(&nw_descr->nw_intflist))
                goto skip_intf;
 
        yaml_scalar_event_initialize(&event, NULL,
@@ -1962,7 +1966,7 @@ static int yaml_lnet_config_ni(char *net_id, char *ip2net,
                                                     LNET_MAX_SHOW_NUM_CPT,
                                                     &cpt_array);
                        for (i = 0; i < count; i++) {
-                               char core[23];
+                               char core[INT_STRING_LEN];
 
                                snprintf(core, sizeof(core), "%u", cpt_array[i]);
                                yaml_scalar_event_initialize(&event, NULL,
@@ -2024,12 +2028,26 @@ emitter_error:
                yaml_document_t errmsg;
 
                rc = yaml_parser_load(&reply, &errmsg);
+               if (rc == 1 && (flags & NLM_F_DUMP)) {
+                       yaml_emitter_t debug;
+
+                       rc = yaml_emitter_initialize(&debug);
+                       if (rc == 1) {
+                               yaml_emitter_set_indent(&debug,
+                                                       LNET_DEFAULT_INDENT);
+                               yaml_emitter_set_output_file(&debug, stdout);
+                               rc = yaml_emitter_dump(&debug, &errmsg);
+                       }
+                       yaml_emitter_delete(&debug);
+               } else {
+                       msg = yaml_parser_get_reader_error(&reply);
+               }
+               yaml_document_delete(&errmsg);
        }
        yaml_emitter_delete(&output);
 free_reply:
        if (rc == 0) {
-               yaml_lnet_print_error(flags, "net",
-                                     yaml_parser_get_reader_error(&reply));
+               yaml_lnet_print_error(flags, "net", msg);
                rc = -EINVAL;
        }
        yaml_parser_delete(&reply);
@@ -2206,7 +2224,7 @@ static int jt_add_ni(int argc, char **argv)
        rc = yaml_lnet_config_ni(net_id, ip2net, &nw_descr,
                                 found ? &tunables : NULL,
                                 (cpt_rc == 0) ? global_cpts : NULL,
-                                NLM_F_CREATE);
+                                LNET_GENL_VERSION, NLM_F_CREATE);
        if (rc <= 0) {
                if (rc == -EOPNOTSUPP)
                        goto old_api;
@@ -2327,7 +2345,8 @@ static int jt_del_ni(int argc, char **argv)
                }
        }
 
-       rc = yaml_lnet_config_ni(net_id, NULL, &nw_descr, NULL, NULL, 0);
+       rc = yaml_lnet_config_ni(net_id, NULL, &nw_descr, NULL, NULL,
+                                LNET_GENL_VERSION, 0);
        if (rc <= 0) {
                if (rc != -EOPNOTSUPP)
                        return rc;
@@ -2629,7 +2648,6 @@ static int jt_show_net(int argc, char **argv)
        int rc, opt;
        struct cYAML *err_rc = NULL, *show_rc = NULL;
        long int detail = 0;
-
        const char *const short_options = "n:v";
        static const struct option long_options[] = {
                { .name = "net",     .has_arg = required_argument, .val = 'n' },
@@ -2662,6 +2680,13 @@ static int jt_show_net(int argc, char **argv)
                }
        }
 
+       rc = yaml_lnet_config_ni(network, NULL, NULL, NULL, NULL,
+                                detail, NLM_F_DUMP);
+       if (rc <= 0) {
+               if (rc != -EOPNOTSUPP)
+                       return rc;
+       }
+
        rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc,
                                  false);
 
index 3e4da2d..9aaed97 100755 (executable)
@@ -1362,10 +1362,10 @@ test_108() {
        add_net "tcp" "$FAKE_IF" || return $?
 
        cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
-        - nid: ${FAKE_IP}@tcp
-          status: up
-          interfaces:
-              0: ${FAKE_IF}
+      -     nid: ${FAKE_IP}@tcp
+            status: up
+            interfaces:
+                  0: ${FAKE_IF}
 EOF
        $LNETCTL net show > $TMP/sanity-lnet-$testnum-actual.yaml
        compare_yaml_files || error "not all interfaces were setup"