Whamcloud - gitweb
LU-10391 lnet: introduce struct lnet_nid 00/42100/26
authorMr NeilBrown <neilb@suse.de>
Fri, 20 Aug 2021 14:17:35 +0000 (10:17 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 31 Aug 2021 05:19:17 +0000 (05:19 +0000)
LNet nids are currently limited to 4-bytes for addresses.
This excludes the use of IPv6.

In order to support IPv6, introduce 'struct lnet_nid' which can hold
up to 128bit address and is extensible, and deprecate 'lnet_nid_t'.
lnet_nid_it will eventually be removed.  Where lnet_nid_t is often
passed around by value, 'struct lnet_nid' will normally be passed
around by reference as it is over twice as large.

The net_type field, which currently has value up to 16, is now limited
to 0-254 with 255 being used as a wildcard.  The most significant byte
is now a size field which gives the size of the whole nid minus 8.  So
zero is correct for current nids with 4-byte addresses.

Where we still need to use 4-byte-address nids, we will use names
containing "nid4".  So "nid4" is a lnet_nid_t when "nid" is a struct
lnet_nid.  lnet_nid_to_nid4 converts a 'struct lnet_nid' to an
lnet_nid_t.

While lnet_nid_t is stored and often transmitted in host-endian format
(and possibly byte-swapped on receipt), 'struct lnet_nid' is always
stored in network-byte-order (i.e.  big-endian).  This is more common
approach for network addresses.

In this first instance, 'struct lnet_nid' is used for ni_nid in
'struct lnet_ni', and related support functions.

In particular libcfs_nidstr() is introduced which parallels
libcfs_nid2str(), but takes 'struct lnet_nid'.

In cases were we need to have similar functions for old and new style
nid, the new function is introduced with a slightly different name,
such as libcfs_nid2str above, or LNET_NID_NET (like LNET_NIDNET).
It will be confusing having both, but the plan is to remove the old
names as soon as practical.

Test-Parameters: trivial
Test-Parameters: serverversion=2.12 serverdistro=el7.9 testlist=runtests
Test-Parameters: clientversion=2.12 testlist=runtests
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I4dcf1bab856621915b6535958d77cdde89105d96
Reviewed-on: https://review.whamcloud.com/42100
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
25 files changed:
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-types.h
lnet/include/uapi/linux/lnet/lnet-idl.h
lnet/include/uapi/linux/lnet/lnet-types.h
lnet/include/uapi/linux/lnet/nidstr.h
lnet/klnds/gnilnd/gnilnd.c
lnet/klnds/gnilnd/gnilnd.h
lnet/klnds/gnilnd/gnilnd_cb.c
lnet/klnds/gnilnd/gnilnd_conn.c
lnet/klnds/o2iblnd/o2iblnd.c
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd_cb.c
lnet/lnet/acceptor.c
lnet/lnet/api-ni.c
lnet/lnet/config.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/lib-socket.c
lnet/lnet/lo.c
lnet/lnet/net_fault.c
lnet/lnet/nidstrings.c
lnet/lnet/router.c
lnet/lnet/router_proc.c
lnet/lnet/udsp.c

index 96991bd..ecac958 100644 (file)
@@ -226,7 +226,7 @@ __must_hold(&ni->ni_lock)
 
        if (ni->ni_status && ni->ni_status->ns_status != status) {
                CDEBUG(D_NET, "ni %s status changed from %#x to %#x\n",
-                      libcfs_nid2str(ni->ni_nid),
+                      libcfs_nidstr(&ni->ni_nid),
                       ni->ni_status->ns_status, status);
                ni->ni_status->ns_status = status;
                update = true;
@@ -239,7 +239,7 @@ static inline unsigned int
 lnet_ni_get_status_locked(struct lnet_ni *ni)
 __must_hold(&ni->ni_lock)
 {
-       if (ni->ni_nid == LNET_NID_LO_0)
+       if (nid_is_lo0(&ni->ni_nid))
                return LNET_NI_STATUS_UP;
        else if (atomic_read(&ni->ni_fatal_error_on))
                return LNET_NI_STATUS_DOWN;
index fdf210c..e3aaa3e 100644 (file)
@@ -455,7 +455,7 @@ struct lnet_ni {
        __u32                   *ni_cpts;
 
        /* interface's NID */
-       lnet_nid_t              ni_nid;
+       struct lnet_nid         ni_nid;
 
        /* instance-specific data */
        void                    *ni_data;
index 35f7a75..303736a 100644 (file)
  * These are sent in sender's byte order (i.e. receiver flips).
  */
 
-/**
- * Address of an end-point in an LNet network.
+/** Address of an end-point in an LNet network.
  *
  * A node can have multiple end-points and hence multiple addresses.
  * An LNet network can be a simple network (e.g. tcp0) or a network of
  * LNet networks connected by LNet routers. Therefore an end-point address
  * has two parts: network ID, and address within a network.
+ * The most-significant-byte in this format is always 0.  A larger value
+ * would imply a larger nid with a larger address.
  *
  * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
  */
 typedef __u64 lnet_nid_t;
 
+/*
+ * Address of LNet end-point in extended form
+ *
+ * To support addresses larger than 32bits we have
+ * an extended nid which supports up to 128 bits
+ * of address and is extensible.
+ * If nid_size is 0, then the nid can be stored in an lnet_nid_t,
+ * and the first 8 bytes of the 'struct lnet_nid' are identical to
+ * the lnet_nid_t in big-endian format.
+ * If nid_type == 0xff, then all other fields should be ignored
+ * and this is an ANY wildcard address.  In particular, the nid_size
+ * can be 0xff without making the address too big to fit.
+ */
+struct lnet_nid {
+       __u8    nid_size;       /* total bytes - 8 */
+       __u8    nid_type;
+       __be16  nid_num;
+       __be32  nid_addr[4];
+} __attribute__((packed));
+
+#define NID_BYTES(nid)         ((nid)->nid_size + 8)
+#define NID_ADDR_BYTES(nid)    ((nid)->nid_size + 4)
+
 /**
  * ID of a process in a node. Shortened as PID to distinguish from
  * lnet_process_id, the global process ID.
index 69dc893..f00d84f 100644 (file)
@@ -32,6 +32,9 @@
 #ifndef __UAPI_LNET_TYPES_H__
 #define __UAPI_LNET_TYPES_H__
 
+#include <linux/string.h>
+#include <asm/byteorder.h>
+
 /** \addtogroup lnet
  * @{ */
 
 /** wildcard PID that matches any lnet_pid_t */
 #define LNET_PID_ANY     ((lnet_pid_t) -1)
 
+static inline int LNET_NID_IS_ANY(const struct lnet_nid *nid)
+{
+       /* A NULL pointer can be used to mean "ANY" */
+       return !nid || nid->nid_type == 0xFF;
+}
+
+#define LNET_ANY_NID ((struct lnet_nid)                        \
+                     {0xFF, 0xFF, ~0, {~0, ~0, ~0, ~0} })
+
 #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
 #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
 #define LNET_PID_LUSTRE 12345
@@ -81,7 +93,7 @@ static inline __u32 LNET_NETNUM(__u32 net)
 
 static inline __u32 LNET_NETTYP(__u32 net)
 {
-       return (net >> 16) & 0xffff;
+       return (net >> 16) & 0xff;
 }
 
 static inline __u32 LNET_MKNET(__u32 type, __u32 num)
@@ -94,6 +106,58 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
 
 #define LNET_NET_ANY LNET_NIDNET(LNET_NID_ANY)
 
+static inline int nid_is_nid4(const struct lnet_nid *nid)
+{
+       return NID_ADDR_BYTES(nid) == 4;
+}
+
+/* LOLND may not be defined yet, so we cannot use an inline */
+#define nid_is_lo0(__nid)                                              \
+       ((__nid)->nid_type == LOLND &&                                  \
+        nid_is_nid4(__nid) &&                                          \
+        (__nid)->nid_num == 0 &&                                       \
+        (__nid)->nid_addr[0] == 0)
+
+static inline __u32 LNET_NID_NET(const struct lnet_nid *nid)
+{
+       return LNET_MKNET(nid->nid_type, __be16_to_cpu(nid->nid_num));
+}
+
+static inline void lnet_nid4_to_nid(lnet_nid_t nid4, struct lnet_nid *nid)
+{
+       if (nid4 == LNET_NID_ANY) {
+               /* equal to setting to LNET_ANY_NID */
+               memset(nid, 0xff, sizeof(*nid));
+               return;
+       }
+
+       nid->nid_size = 0;
+       nid->nid_type = LNET_NETTYP(LNET_NIDNET(nid4));
+       nid->nid_num = __cpu_to_be16(LNET_NETNUM(LNET_NIDNET(nid4)));
+       nid->nid_addr[0] = __cpu_to_be32(LNET_NIDADDR(nid4));
+       nid->nid_addr[1] = nid->nid_addr[2] = nid->nid_addr[3] = 0;
+}
+
+static inline lnet_nid_t lnet_nid_to_nid4(const struct lnet_nid *nid)
+{
+       if (LNET_NID_IS_ANY(nid))
+               return LNET_NID_ANY;
+
+       return LNET_MKNID(LNET_NID_NET(nid), __be32_to_cpu(nid->nid_addr[0]));
+}
+
+static inline int nid_same(const struct lnet_nid *n1,
+                           const struct lnet_nid *n2)
+{
+       return n1->nid_size == n2->nid_size &&
+               n1->nid_type == n2->nid_type &&
+               n1->nid_num == n2->nid_num &&
+               n1->nid_addr[0] == n2->nid_addr[0] &&
+               n1->nid_addr[1] == n2->nid_addr[1] &&
+               n1->nid_addr[2] == n2->nid_addr[2] &&
+               n1->nid_addr[3] == n2->nid_addr[3];
+}
+
 struct lnet_counters_health {
        __u32   lch_rst_alloc;
        __u32   lch_resend_count;
index 7ac7f9a..c2d0e6a 100644 (file)
@@ -59,7 +59,7 @@ enum {
 struct list_head;
 
 #define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */
-#define LNET_NIDSTR_SIZE  32   /* size of each one (see below for usage) */
+#define LNET_NIDSTR_SIZE  64   /* size of each one (see below for usage) */
 
 /* support decl needed by both kernel and user space */
 char *libcfs_next_nidstring(void);
@@ -84,6 +84,13 @@ static inline char *libcfs_nid2str(lnet_nid_t nid)
        return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
                                LNET_NIDSTR_SIZE);
 }
+char *libcfs_nidstr_r(const struct lnet_nid *nid,
+                       char *buf, __kernel_size_t buf_size);
+static inline char *libcfs_nidstr(const struct lnet_nid *nid)
+{
+       return libcfs_nidstr_r(nid, libcfs_next_nidstring(),
+                                LNET_NIDSTR_SIZE);
+}
 __u32 libcfs_str2net(const char *str);
 lnet_nid_t libcfs_str2nid(const char *str);
 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
index bfe044c..b23b317 100644 (file)
@@ -91,7 +91,8 @@ kgnilnd_close_stale_conns_locked(kgn_peer_t *peer, kgn_conn_t *newconn)
        int                 loopback;
        int                 count = 0;
 
-       loopback = peer->gnp_nid == peer->gnp_net->gnn_ni->ni_nid;
+       loopback = (peer->gnp_nid ==
+                   lnet_nid_to_nid4(&peer->gnp_net->gnn_ni->ni_nid));
 
        list_for_each_entry_safe(conn, cnxt, &peer->gnp_conns, gnc_list) {
                if (conn->gnc_state != GNILND_CONN_ESTABLISHED)
@@ -161,7 +162,8 @@ kgnilnd_conn_isdup_locked(kgn_peer_t *peer, kgn_conn_t *newconn)
        int               loopback;
        ENTRY;
 
-       loopback = peer->gnp_nid == peer->gnp_net->gnn_ni->ni_nid;
+       loopback = (peer->gnp_nid ==
+                   lnet_nid_to_nid4(&peer->gnp_net->gnn_ni->ni_nid));
 
        list_for_each_entry(conn, &peer->gnp_conns, gnc_list) {
                CDEBUG(D_NET, "checking conn 0x%p for peer %s"
@@ -594,8 +596,9 @@ kgnilnd_peer_notify(kgn_peer_t *peer, int error, int alive)
 
                        net = nets[i];
 
-                       peer_nid = kgnilnd_lnd2lnetnid(net->gnn_ni->ni_nid,
-                                                                peer->gnp_nid);
+                       peer_nid = kgnilnd_lnd2lnetnid(
+                               lnet_nid_to_nid4(&net->gnn_ni->ni_nid),
+                               peer->gnp_nid);
 
                        CDEBUG(D_NET, "peer 0x%p->%s last_alive %lld (%llds ago)\n",
                                peer, libcfs_nid2str(peer_nid), peer->gnp_last_alive,
@@ -1726,7 +1729,7 @@ kgnilnd_report_node_state(lnet_nid_t nid, int down)
                /* The nid passed in does not yet contain the net portion.
                 * Let's build it up now
                 */
-               nid = LNET_MKNID(LNET_NIDNET(net->gnn_ni->ni_nid), nid);
+               nid = LNET_MKNID(LNET_NID_NET(&net->gnn_ni->ni_nid), nid);
                rc = kgnilnd_add_peer(net, nid, &new_peer);
 
                if (rc) {
@@ -1807,7 +1810,8 @@ kgnilnd_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg)
                 * LNET assumes a conn and peer per net, the LNET_MKNID/LNET_NIDADDR allows us to let Lnet see what it
                 * wants to see instead of the underlying network that is being used to send the data
                 */
-               data->ioc_nid    = LNET_MKNID(LNET_NIDNET(ni->ni_nid), LNET_NIDADDR(nid));
+               data->ioc_nid    = LNET_MKNID(LNET_NID_NET(&ni->ni_nid),
+                                             LNET_NIDADDR(nid));
                data->ioc_flags  = peer_connecting;
                data->ioc_count  = peer_refcount;
 
@@ -1858,7 +1862,8 @@ kgnilnd_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg)
                        /* LNET_MKNID is used to build the correct address based on what LNET wants to see instead of
                         * the generic connection that is used to send the data
                         */
-                       data->ioc_nid    = LNET_MKNID(LNET_NIDNET(ni->ni_nid), LNET_NIDADDR(conn->gnc_peer->gnp_nid));
+                       data->ioc_nid    = LNET_MKNID(LNET_NID_NET(&ni->ni_nid),
+                                                     LNET_NIDADDR(conn->gnc_peer->gnp_nid));
                        data->ioc_u32[0] = conn->gnc_device->gnd_id;
                        kgnilnd_conn_decref(conn);
                }
@@ -1881,12 +1886,12 @@ kgnilnd_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg)
        }
        case IOC_LIBCFS_REGISTER_MYNID: {
                /* Ignore if this is a noop */
-               if (data->ioc_nid == ni->ni_nid) {
+               if (data->ioc_nid == lnet_nid_to_nid4(&ni->ni_nid)) {
                        rc = 0;
                } else {
                        CERROR("obsolete IOC_LIBCFS_REGISTER_MYNID: %s(%s)\n",
                               libcfs_nid2str(data->ioc_nid),
-                              libcfs_nid2str(ni->ni_nid));
+                              libcfs_nidstr(&ni->ni_nid));
                        rc = -EINVAL;
                }
                break;
@@ -2640,9 +2645,9 @@ kgnilnd_startup(struct lnet_ni *ni)
        atomic_set(&net->gnn_refcount, 1);
 
        /* if we have multiple devices, spread the nets around */
-       net->gnn_netnum = LNET_NETNUM(LNET_NIDNET(ni->ni_nid));
+       net->gnn_netnum = LNET_NETNUM(LNET_NID_NET(&ni->ni_nid));
 
-       devno = LNET_NIDNET(ni->ni_nid) % GNILND_MAXDEVS;
+       devno = LNET_NID_NET(&ni->ni_nid) % GNILND_MAXDEVS;
        net->gnn_dev = &kgnilnd_data.kgn_devices[devno];
 
        /* allocate a 'dummy' cdm for datagram use. We can only have a single
@@ -2653,10 +2658,10 @@ kgnilnd_startup(struct lnet_ni *ni)
        /* the instance id for the cdm is the NETNUM offset by MAXDEVS -
         * ensuring we'll have a unique id */
 
-
-       ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid), net->gnn_dev->gnd_nid);
+       ni->ni_nid.nid_addr[0] =
+               cpu_to_be32(LNET_NIDADDR(net->gnn_dev->gnd_nid));
        CDEBUG(D_NET, "adding net %p nid=%s on dev %d \n",
-               net, libcfs_nid2str(ni->ni_nid), net->gnn_dev->gnd_id);
+               net, libcfs_nidstr(&ni->ni_nid), net->gnn_dev->gnd_id);
        /* until the gnn_list is set, we need to cleanup ourselves as
         * kgnilnd_shutdown is just gonna get confused */
 
index 3c7f742..c5282fe 100644 (file)
@@ -1169,20 +1169,20 @@ do {                                                                    \
                wake_up_var(&kgnilnd_data);                             \
 }while (0)
 
-#define kgnilnd_net_addref(net)                                                 \
-do {                                                                            \
-       int     val = atomic_inc_return(&net->gnn_refcount);                    \
-       LASSERTF(val > 1, "net %p refcount %d\n", net, val);                    \
-       CDEBUG(D_NETTRACE, "net %p->%s++ (%d)\n", net,                          \
-               libcfs_nid2str(net->gnn_ni->ni_nid), val);                      \
+#define kgnilnd_net_addref(net)                                                \
+do {                                                                   \
+       int     val = atomic_inc_return(&net->gnn_refcount);            \
+       LASSERTF(val > 1, "net %p refcount %d\n", net, val);            \
+       CDEBUG(D_NETTRACE, "net %p->%s++ (%d)\n", net,                  \
+               libcfs_nidstr(&net->gnn_ni->ni_nid), val);              \
 } while (0)
 
-#define kgnilnd_net_decref(net)                                                 \
-do {                                                                            \
-       int     val = atomic_dec_return(&net->gnn_refcount);                    \
-       LASSERTF(val >= 0, "net %p refcount %d\n", net, val);                   \
-       CDEBUG(D_NETTRACE, "net %p->%s-- (%d)\n", net,                          \
-              libcfs_nid2str(net->gnn_ni->ni_nid), val);                       \
+#define kgnilnd_net_decref(net)                                                \
+do {                                                                   \
+       int     val = atomic_dec_return(&net->gnn_refcount);            \
+       LASSERTF(val >= 0, "net %p refcount %d\n", net, val);           \
+       CDEBUG(D_NETTRACE, "net %p->%s-- (%d)\n", net,                  \
+              libcfs_nidstr(&net->gnn_ni->ni_nid), val);               \
 } while (0)
 
 #define kgnilnd_peer_addref(peer)                                               \
@@ -1376,7 +1376,7 @@ kgnilnd_check_purgatory_conn(kgn_conn_t *conn)
 
        if (conn->gnc_peer) {
                loopback = conn->gnc_peer->gnp_nid ==
-                      conn->gnc_peer->gnp_net->gnn_ni->ni_nid;
+                       lnet_nid_to_nid4(&conn->gnc_peer->gnp_net->gnn_ni->ni_nid);
        } else {
                /* short circuit - a conn that didn't complete
                 * setup never needs a purgatory hold */
@@ -1744,8 +1744,11 @@ kgnilnd_find_net(lnet_nid_t nid, kgn_net_t **netp)
                return -ESHUTDOWN;
        }
 
-       list_for_each_entry(net, kgnilnd_netnum2netlist(LNET_NETNUM(LNET_NIDNET(nid))), gnn_list) {
-               if (!net->gnn_shutdown && LNET_NIDNET(net->gnn_ni->ni_nid) == LNET_NIDNET(nid)) {
+       list_for_each_entry(net,
+                           kgnilnd_netnum2netlist(LNET_NETNUM(LNET_NIDNET(nid))),
+                           gnn_list) {
+               if (!net->gnn_shutdown &&
+                   LNET_NID_NET(&net->gnn_ni->ni_nid) == LNET_NIDNET(nid)) {
                        kgnilnd_net_addref(net);
                        up_read(&kgnilnd_data.kgn_net_rw_sem);
                        *netp = net;
index 2e3232a..124339b 100644 (file)
@@ -2074,9 +2074,11 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                       break;
 
                if ((reverse_rdma_flag & GNILND_REVERSE_GET) == 0)
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_GET_REQ, ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_GET_REQ,
+                                               lnet_nid_to_nid4(&ni->ni_nid));
                else
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_GET_REQ_REV, ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_GET_REQ_REV,
+                                               lnet_nid_to_nid4(&ni->ni_nid));
 
                if (tx == NULL) {
                        rc = -ENOMEM;
@@ -2118,9 +2120,11 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                       break;
 
                if ((reverse_rdma_flag & GNILND_REVERSE_PUT) == 0)
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_PUT_REQ, ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_PUT_REQ,
+                                               lnet_nid_to_nid4(&ni->ni_nid));
                else
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_PUT_REQ_REV, ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_PUT_REQ_REV,
+                                               lnet_nid_to_nid4(&ni->ni_nid));
 
                if (tx == NULL) {
                        rc = -ENOMEM;
@@ -2151,7 +2155,8 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        LASSERTF(nob <= *kgnilnd_tunables.kgn_max_immediate,
                "lntmsg 0x%p too large %d\n", lntmsg, nob);
 
-       tx = kgnilnd_new_tx_msg(GNILND_MSG_IMMEDIATE, ni->ni_nid);
+       tx = kgnilnd_new_tx_msg(GNILND_MSG_IMMEDIATE,
+                               lnet_nid_to_nid4(&ni->ni_nid));
        if (tx == NULL) {
                rc = -ENOMEM;
                goto out;
@@ -2202,7 +2207,7 @@ kgnilnd_setup_rdma(struct lnet_ni *ni, kgn_rx_t *rx, struct lnet_msg *lntmsg, in
                LBUG();
        }
 
-       tx = kgnilnd_new_tx_msg(done_type, ni->ni_nid);
+       tx = kgnilnd_new_tx_msg(done_type, lnet_nid_to_nid4(&ni->ni_nid));
        if (tx == NULL)
                goto failed_0;
 
@@ -2229,7 +2234,8 @@ kgnilnd_setup_rdma(struct lnet_ni *ni, kgn_rx_t *rx, struct lnet_msg *lntmsg, in
 
  failed_1:
        kgnilnd_tx_done(tx, rc);
-       kgnilnd_nak_rdma(conn, done_type, rc, rxmsg->gnm_u.get.gngm_cookie, ni->ni_nid);
+       kgnilnd_nak_rdma(conn, done_type, rc, rxmsg->gnm_u.get.gngm_cookie,
+                        lnet_nid_to_nid4(&ni->ni_nid));
  failed_0:
        lnet_finalize(lntmsg, rc);
 }
@@ -2434,13 +2440,14 @@ kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
                        /* only error if lntmsg == NULL, otherwise we are just
                         * short circuiting the rdma process of 0 bytes */
                        kgnilnd_nak_rdma(conn, rxmsg->gnm_type,
-                                       lntmsg == NULL ? -ENOENT : 0,
-                                       rxmsg->gnm_u.get.gngm_cookie,
-                                       ni->ni_nid);
+                                        lntmsg == NULL ? -ENOENT : 0,
+                                        rxmsg->gnm_u.get.gngm_cookie,
+                                        lnet_nid_to_nid4(&ni->ni_nid));
                        RETURN(0);
                }
                /* sending ACK with sink buff. info */
-               tx = kgnilnd_new_tx_msg(GNILND_MSG_PUT_ACK, ni->ni_nid);
+               tx = kgnilnd_new_tx_msg(GNILND_MSG_PUT_ACK,
+                                       lnet_nid_to_nid4(&ni->ni_nid));
                if (tx == NULL) {
                        kgnilnd_consume_rx(rx);
                        RETURN(-ENOMEM);
@@ -2479,7 +2486,9 @@ kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 
 nak_put_req:
                /* make sure we send an error back when the PUT fails */
-               kgnilnd_nak_rdma(conn, rxmsg->gnm_type, rc, rxmsg->gnm_u.get.gngm_cookie, ni->ni_nid);
+               kgnilnd_nak_rdma(conn, rxmsg->gnm_type, rc,
+                                rxmsg->gnm_u.get.gngm_cookie,
+                                lnet_nid_to_nid4(&ni->ni_nid));
                kgnilnd_tx_done(tx, rc);
                kgnilnd_consume_rx(rx);
 
@@ -2494,15 +2503,16 @@ nak_put_req:
                        /* only error if lntmsg == NULL, otherwise we are just
                         * short circuiting the rdma process of 0 bytes */
                        kgnilnd_nak_rdma(conn, rxmsg->gnm_type,
-                                       lntmsg == NULL ? -ENOENT : 0,
-                                       rxmsg->gnm_u.get.gngm_cookie,
-                                       ni->ni_nid);
+                                        lntmsg == NULL ? -ENOENT : 0,
+                                        rxmsg->gnm_u.get.gngm_cookie,
+                                        lnet_nid_to_nid4(&ni->ni_nid));
                        RETURN(0);
                }
                /* lntmsg can be null when parsing a LNET_GET */
                if (lntmsg != NULL) {
                        /* sending ACK with sink buff. info */
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_GET_ACK_REV, ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_GET_ACK_REV,
+                                               lnet_nid_to_nid4(&ni->ni_nid));
                        if (tx == NULL) {
                                kgnilnd_consume_rx(rx);
                                RETURN(-ENOMEM);
@@ -2536,9 +2546,9 @@ nak_put_req:
                } else {
                        /* No match */
                        kgnilnd_nak_rdma(conn, rxmsg->gnm_type,
-                                       -ENOENT,
-                                       rxmsg->gnm_u.get.gngm_cookie,
-                                       ni->ni_nid);
+                                        -ENOENT,
+                                        rxmsg->gnm_u.get.gngm_cookie,
+                                        lnet_nid_to_nid4(&ni->ni_nid));
                }
 
                kgnilnd_consume_rx(rx);
@@ -2546,7 +2556,9 @@ nak_put_req:
 
 nak_get_req_rev:
                /* make sure we send an error back when the GET fails */
-               kgnilnd_nak_rdma(conn, rxmsg->gnm_type, rc, rxmsg->gnm_u.get.gngm_cookie, ni->ni_nid);
+               kgnilnd_nak_rdma(conn, rxmsg->gnm_type, rc,
+                                rxmsg->gnm_u.get.gngm_cookie,
+                                lnet_nid_to_nid4(&ni->ni_nid));
                kgnilnd_tx_done(tx, rc);
                kgnilnd_consume_rx(rx);
 
@@ -2563,9 +2575,9 @@ nak_get_req_rev:
                        /* only error if lntmsg == NULL, otherwise we are just
                         * short circuiting the rdma process of 0 bytes */
                        kgnilnd_nak_rdma(conn, rxmsg->gnm_type,
-                                       lntmsg == NULL ? -ENOENT : 0,
-                                       rxmsg->gnm_u.get.gngm_cookie,
-                                       ni->ni_nid);
+                                        lntmsg == NULL ? -ENOENT : 0,
+                                        rxmsg->gnm_u.get.gngm_cookie,
+                                        lnet_nid_to_nid4(&ni->ni_nid));
                        RETURN(0);
                }
 
@@ -2575,9 +2587,9 @@ nak_get_req_rev:
                } else {
                        /* No match */
                        kgnilnd_nak_rdma(conn, rxmsg->gnm_type,
-                                       -ENOENT,
-                                       rxmsg->gnm_u.get.gngm_cookie,
-                                       ni->ni_nid);
+                                        -ENOENT,
+                                        rxmsg->gnm_u.get.gngm_cookie,
+                                        lnet_nid_to_nid4(&ni->ni_nid));
                }
                kgnilnd_consume_rx(rx);
                RETURN(0);
@@ -2588,9 +2600,9 @@ nak_get_req_rev:
                } else {
                        /* No match */
                        kgnilnd_nak_rdma(conn, rxmsg->gnm_type,
-                                       -ENOENT,
-                                       rxmsg->gnm_u.get.gngm_cookie,
-                                       ni->ni_nid);
+                                        -ENOENT,
+                                        rxmsg->gnm_u.get.gngm_cookie,
+                                        lnet_nid_to_nid4(&ni->ni_nid));
                }
                kgnilnd_consume_rx(rx);
                RETURN(0);
@@ -2666,7 +2678,8 @@ kgnilnd_check_conn_timeouts_locked(kgn_conn_t *conn)
                if (CFS_FAIL_CHECK(CFS_FAIL_GNI_NOOP_SEND))
                        return 0;
 
-               tx = kgnilnd_new_tx_msg(GNILND_MSG_NOOP, conn->gnc_peer->gnp_net->gnn_ni->ni_nid);
+               tx = kgnilnd_new_tx_msg(GNILND_MSG_NOOP,
+                                       lnet_nid_to_nid4(&conn->gnc_peer->gnp_net->gnn_ni->ni_nid));
                if (tx == NULL)
                        return 0;
                kgnilnd_queue_tx(conn, tx);
@@ -3674,7 +3687,8 @@ kgnilnd_process_fmaq(kgn_conn_t *conn)
                        if (CFS_FAIL_CHECK(CFS_FAIL_GNI_NOOP_SEND))
                                return;
 
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_NOOP, conn->gnc_peer->gnp_net->gnn_ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_NOOP,
+                                               lnet_nid_to_nid4(&conn->gnc_peer->gnp_net->gnn_ni->ni_nid));
                        if (tx != NULL) {
                                int     rc;
 
@@ -4549,7 +4563,8 @@ kgnilnd_send_conn_close(kgn_conn_t *conn)
                if (conn->gnc_ephandle != NULL) {
                        int rc = 0;
 
-                       tx = kgnilnd_new_tx_msg(GNILND_MSG_CLOSE, conn->gnc_peer->gnp_net->gnn_ni->ni_nid);
+                       tx = kgnilnd_new_tx_msg(GNILND_MSG_CLOSE,
+                                               lnet_nid_to_nid4(&conn->gnc_peer->gnp_net->gnn_ni->ni_nid));
                        if (tx != NULL) {
                                tx->tx_msg.gnm_u.completion.gncm_retval = conn->gnc_error;
                                tx->tx_state = GNILND_TX_WAITING_COMPLETION;
index c75f0ac..38dce1d 100644 (file)
@@ -880,12 +880,13 @@ kgnilnd_unpack_connreq(kgn_dgram_t *dgram)
                        return rc;
                }
 
-               if (net->gnn_ni->ni_nid != connreq->gncr_dstnid) {
+               if (lnet_nid_to_nid4(&net->gnn_ni->ni_nid) !=
+                   connreq->gncr_dstnid) {
                        CERROR("Bad connection data from %s: she sent "
                               "dst_nid %s, but I am %s with dgram 0x%p@%s\n",
                               libcfs_nid2str(connreq->gncr_srcnid),
                               libcfs_nid2str(connreq->gncr_dstnid),
-                              libcfs_nid2str(net->gnn_ni->ni_nid),
+                              libcfs_nidstr(&net->gnn_ni->ni_nid),
                               dgram, kgnilnd_dgram_type2str(dgram));
                        kgnilnd_net_decref(net);
                        return -EBADSLT;
@@ -1890,7 +1891,8 @@ kgnilnd_finish_connect(kgn_dgram_t *dgram)
        /* Dont send NOOP if fail_loc is set
         */
        if (!CFS_FAIL_CHECK(CFS_FAIL_GNI_ONLY_NOOP)) {
-               tx = kgnilnd_new_tx_msg(GNILND_MSG_NOOP, peer->gnp_net->gnn_ni->ni_nid);
+               tx = kgnilnd_new_tx_msg(GNILND_MSG_NOOP,
+                                       lnet_nid_to_nid4(&peer->gnp_net->gnn_ni->ni_nid));
                if (tx == NULL) {
                        CNETERR("can't get TX to initiate NOOP to %s\n",
                                libcfs_nid2str(peer->gnp_nid));
index 2d4ab79..3407c22 100644 (file)
@@ -180,23 +180,24 @@ void kiblnd_pack_msg(struct lnet_ni *ni, struct kib_msg *msg, int version,
 {
        struct kib_net *net = ni->ni_data;
 
-        /* CAVEAT EMPTOR! all message fields not set here should have been
-         * initialised previously. */
-        msg->ibm_magic    = IBLND_MSG_MAGIC;
-        msg->ibm_version  = version;
-        /*   ibm_type */
-        msg->ibm_credits  = credits;
-        /*   ibm_nob */
-        msg->ibm_cksum    = 0;
-        msg->ibm_srcnid   = ni->ni_nid;
-        msg->ibm_srcstamp = net->ibn_incarnation;
-        msg->ibm_dstnid   = dstnid;
-        msg->ibm_dststamp = dststamp;
-
-        if (*kiblnd_tunables.kib_cksum) {
-                /* NB ibm_cksum zero while computing cksum */
-                msg->ibm_cksum = kiblnd_cksum(msg, msg->ibm_nob);
-        }
+       /* CAVEAT EMPTOR! all message fields not set here should have been
+        * initialised previously.
+        */
+       msg->ibm_magic    = IBLND_MSG_MAGIC;
+       msg->ibm_version  = version;
+       /*   ibm_type */
+       msg->ibm_credits  = credits;
+       /*   ibm_nob */
+       msg->ibm_cksum    = 0;
+       msg->ibm_srcnid   = lnet_nid_to_nid4(&ni->ni_nid);
+       msg->ibm_srcstamp = net->ibn_incarnation;
+       msg->ibm_dstnid   = dstnid;
+       msg->ibm_dststamp = dststamp;
+
+       if (*kiblnd_tunables.kib_cksum) {
+               /* NB ibm_cksum zero while computing cksum */
+               msg->ibm_cksum = kiblnd_cksum(msg, msg->ibm_nob);
+       }
 }
 
 int kiblnd_unpack_msg(struct kib_msg *msg, int nob)
@@ -397,7 +398,7 @@ kiblnd_find_peer_locked(struct lnet_ni *ni, lnet_nid_t nid)
                 * created.
                 */
                if (peer_ni->ibp_nid != nid ||
-                   peer_ni->ibp_ni->ni_nid != ni->ni_nid)
+                   !nid_same(&peer_ni->ibp_ni->ni_nid, &ni->ni_nid))
                        continue;
 
                CDEBUG(D_NET, "got peer_ni [%p] -> %s (%d) version: %x\n",
@@ -2522,7 +2523,7 @@ kiblnd_set_ni_fatal_on(struct kib_hca_dev *hdev, int val)
        list_for_each_entry(net, &hdev->ibh_dev->ibd_nets, ibn_list) {
                if (val)
                        CDEBUG(D_NETERROR, "Fatal device error for NI %s\n",
-                                       libcfs_nid2str(net->ibn_ni->ni_nid));
+                                       libcfs_nidstr(&net->ibn_ni->ni_nid));
                atomic_set(&net->ibn_ni->ni_fatal_error_on, val);
        }
 }
@@ -3035,7 +3036,7 @@ kiblnd_shutdown(struct lnet_ni *ni)
                wait_var_event_warning(&net->ibn_npeers,
                                       atomic_read(&net->ibn_npeers) == 0,
                                       "%s: waiting for %d peers to disconnect\n",
-                                      libcfs_nid2str(ni->ni_nid),
+                                      libcfs_nidstr(&ni->ni_nid),
                                       atomic_read(&net->ibn_npeers));
 
                kiblnd_net_fini_pools(net);
@@ -3353,7 +3354,7 @@ kiblnd_startup(struct lnet_ni *ni)
        }
 
        net->ibn_dev = ibdev;
-       ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid), ibdev->ibd_ifip);
+       ni->ni_nid.nid_addr[0] = cpu_to_be32(ibdev->ibd_ifip);
 
        ni->ni_dev_cpt = ifaces[i].li_cpt;
 
index c6ae0f6..87eff59 100644 (file)
@@ -492,45 +492,45 @@ kiblnd_rx_complete(struct kib_rx *rx, int status, int nob)
        int rc;
        int err = -EIO;
 
-        LASSERT (net != NULL);
-        LASSERT (rx->rx_nob < 0);               /* was posted */
-        rx->rx_nob = 0;                         /* isn't now */
+       LASSERT(net);
+       LASSERT(rx->rx_nob < 0);        /* was posted */
+       rx->rx_nob = 0;                 /* isn't now */
 
-        if (conn->ibc_state > IBLND_CONN_ESTABLISHED)
-                goto ignore;
+       if (conn->ibc_state > IBLND_CONN_ESTABLISHED)
+               goto ignore;
 
-        if (status != IB_WC_SUCCESS) {
-                CNETERR("Rx from %s failed: %d\n",
-                        libcfs_nid2str(conn->ibc_peer->ibp_nid), status);
-                goto failed;
-        }
+       if (status != IB_WC_SUCCESS) {
+               CNETERR("Rx from %s failed: %d\n",
+                       libcfs_nid2str(conn->ibc_peer->ibp_nid), status);
+               goto failed;
+       }
 
-        LASSERT (nob >= 0);
-        rx->rx_nob = nob;
+       LASSERT(nob >= 0);
+       rx->rx_nob = nob;
 
-        rc = kiblnd_unpack_msg(msg, rx->rx_nob);
-        if (rc != 0) {
-                CERROR ("Error %d unpacking rx from %s\n",
-                        rc, libcfs_nid2str(conn->ibc_peer->ibp_nid));
-                goto failed;
-        }
+       rc = kiblnd_unpack_msg(msg, rx->rx_nob);
+       if (rc != 0) {
+               CERROR("Error %d unpacking rx from %s\n",
+                      rc, libcfs_nid2str(conn->ibc_peer->ibp_nid));
+               goto failed;
+       }
 
-        if (msg->ibm_srcnid != conn->ibc_peer->ibp_nid ||
-            msg->ibm_dstnid != ni->ni_nid ||
-            msg->ibm_srcstamp != conn->ibc_incarnation ||
-            msg->ibm_dststamp != net->ibn_incarnation) {
-                CERROR ("Stale rx from %s\n",
-                        libcfs_nid2str(conn->ibc_peer->ibp_nid));
-                err = -ESTALE;
-                goto failed;
-        }
+       if (msg->ibm_srcnid != conn->ibc_peer->ibp_nid ||
+           msg->ibm_dstnid != lnet_nid_to_nid4(&ni->ni_nid) ||
+           msg->ibm_srcstamp != conn->ibc_incarnation ||
+           msg->ibm_dststamp != net->ibn_incarnation) {
+               CERROR("Stale rx from %s\n",
+                      libcfs_nid2str(conn->ibc_peer->ibp_nid));
+               err = -ESTALE;
+               goto failed;
+       }
 
-        /* set time last known alive */
-        kiblnd_peer_alive(conn->ibc_peer);
+       /* set time last known alive */
+       kiblnd_peer_alive(conn->ibc_peer);
 
-        /* racing with connection establishment/teardown! */
+       /* racing with connection establishment/teardown! */
 
-        if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
+       if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
                rwlock_t  *g_lock = &kiblnd_data.kib_global_lock;
                unsigned long  flags;
 
@@ -542,15 +542,15 @@ kiblnd_rx_complete(struct kib_rx *rx, int status, int nob)
                        return;
                }
                write_unlock_irqrestore(g_lock, flags);
-        }
-        kiblnd_handle_rx(rx);
-        return;
+       }
+       kiblnd_handle_rx(rx);
+       return;
 
- failed:
-        CDEBUG(D_NET, "rx %p conn %p\n", rx, conn);
-        kiblnd_close_conn(conn, err);
- ignore:
-        kiblnd_drop_rx(rx);                     /* Don't re-post rx. */
+failed:
+       CDEBUG(D_NET, "rx %p conn %p\n", rx, conn);
+       kiblnd_close_conn(conn, err);
+ignore:
+       kiblnd_drop_rx(rx);                     /* Don't re-post rx. */
 }
 
 static int
@@ -2467,11 +2467,12 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
                rej.ibr_incarnation = net->ibn_incarnation;
        }
 
-       if (ni == NULL ||                         /* no matching net */
-           ni->ni_nid != reqmsg->ibm_dstnid ||   /* right NET, wrong NID! */
-           net->ibn_dev != ibdev) {              /* wrong device */
+       if (ni == NULL ||                       /* no matching net */
+           lnet_nid_to_nid4(&ni->ni_nid) !=
+           reqmsg->ibm_dstnid ||               /* right NET, wrong NID! */
+           net->ibn_dev != ibdev) {            /* wrong device */
                CERROR("Can't accept conn from %s on %s (%s:%d:%pI4h): bad dst nid %s\n", libcfs_nid2str(nid),
-                      ni ? libcfs_nid2str(ni->ni_nid) : "NA",
+                      ni ? libcfs_nidstr(&ni->ni_nid) : "NA",
                       ibdev->ibd_ifname, ibdev->ibd_nnets,
                       &ibdev->ibd_ifip,
                       libcfs_nid2str(reqmsg->ibm_dstnid));
@@ -2591,8 +2592,8 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
                 * the lower NID connection win so we can move forward.
                 */
                if (peer2->ibp_connecting != 0 &&
-                   nid < ni->ni_nid && peer2->ibp_races <
-                   MAX_CONN_RACES_BEFORE_ABORT) {
+                   nid < lnet_nid_to_nid4(&ni->ni_nid) &&
+                   peer2->ibp_races < MAX_CONN_RACES_BEFORE_ABORT) {
                        peer2->ibp_races++;
                        write_unlock_irqrestore(g_lock, flags);
 
@@ -3023,7 +3024,7 @@ kiblnd_check_connreply(struct kib_conn *conn, void *priv, int priv_nob)
         }
 
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
-       if (msg->ibm_dstnid == ni->ni_nid &&
+       if (msg->ibm_dstnid == lnet_nid_to_nid4(&ni->ni_nid) &&
            msg->ibm_dststamp == net->ibn_incarnation)
                rc = 0;
        else
@@ -3658,13 +3659,13 @@ kiblnd_qp_event(struct ib_event *event, void *arg)
        case IB_EVENT_PORT_ERR:
        case IB_EVENT_DEVICE_FATAL:
                CERROR("Fatal device error for NI %s\n",
-                      libcfs_nid2str(conn->ibc_peer->ibp_ni->ni_nid));
+                      libcfs_nidstr(&conn->ibc_peer->ibp_ni->ni_nid));
                atomic_set(&conn->ibc_peer->ibp_ni->ni_fatal_error_on, 1);
                return;
 
        case IB_EVENT_PORT_ACTIVE:
                CERROR("Port reactivated for NI %s\n",
-                      libcfs_nid2str(conn->ibc_peer->ibp_ni->ni_nid));
+                      libcfs_nidstr(&conn->ibc_peer->ibp_ni->ni_nid));
                atomic_set(&conn->ibc_peer->ibp_ni->ni_fatal_error_on, 0);
                return;
 
index ec7e069..307e16c 100644 (file)
@@ -937,7 +937,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_conn_cb *conn_cb,
                /* Am I already connecting to this guy?  Resolve in
                 * favour of higher NID...
                 */
-               if (peerid.nid < ni->ni_nid &&
+               if (peerid.nid < lnet_nid_to_nid4(&ni->ni_nid) &&
                    ksocknal_connecting(peer_ni->ksnp_conn_cb,
                                        ((struct sockaddr *) &conn->ksnc_peeraddr))) {
                        rc = EALREADY;
@@ -1793,15 +1793,16 @@ ksocknal_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg)
                 return ksocknal_close_matching_conns (id,
                                                       data->ioc_u32[0]);
 
-        case IOC_LIBCFS_REGISTER_MYNID:
-                /* Ignore if this is a noop */
-                if (data->ioc_nid == ni->ni_nid)
-                        return 0;
+       case IOC_LIBCFS_REGISTER_MYNID:
+               /* Ignore if this is a noop */
+               if (nid_is_nid4(&ni->ni_nid) &&
+                   data->ioc_nid == lnet_nid_to_nid4(&ni->ni_nid))
+                       return 0;
 
-                CERROR("obsolete IOC_LIBCFS_REGISTER_MYNID: %s(%s)\n",
-                       libcfs_nid2str(data->ioc_nid),
-                       libcfs_nid2str(ni->ni_nid));
-                return -EINVAL;
+               CERROR("obsolete IOC_LIBCFS_REGISTER_MYNID: %s(%s)\n",
+                      libcfs_nid2str(data->ioc_nid),
+                      libcfs_nidstr(&ni->ni_nid));
+               return -EINVAL;
 
         case IOC_LIBCFS_PUSH_CONNECTION:
                 id.nid = data->ioc_nid;
@@ -2348,10 +2349,8 @@ ksocknal_startup(struct lnet_ni *ni)
 
        LASSERT(ksi);
        LASSERT(ksi->ksni_addr.ss_family == AF_INET);
-       ni->ni_nid = LNET_MKNID(
-               LNET_NIDNET(ni->ni_nid),
-               ntohl(((struct sockaddr_in *)
-                      &ksi->ksni_addr)->sin_addr.s_addr));
+       ni->ni_nid.nid_addr[0] =
+               ((struct sockaddr_in *)&ksi->ksni_addr)->sin_addr.s_addr;
        list_add(&net->ksnn_list, &ksocknal_data.ksnd_nets);
        net->ksnn_ni = ni;
        ksocknal_data.ksnd_nnets++;
index ec3f952..54fd6b6 100644 (file)
@@ -1704,7 +1704,7 @@ ksocknal_send_hello(struct lnet_ni *ni, struct ksock_conn *conn,
        /* rely on caller to hold a ref on socket so it wouldn't disappear */
        LASSERT(conn->ksnc_proto != NULL);
 
-       hello->kshm_src_nid         = ni->ni_nid;
+       hello->kshm_src_nid         = lnet_nid_to_nid4(&ni->ni_nid);
        hello->kshm_dst_nid         = peer_nid;
        hello->kshm_src_pid         = the_lnet.ln_pid;
 
@@ -1737,16 +1737,16 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
                    struct lnet_process_id *peerid,
                    __u64 *incarnation)
 {
-        /* Return < 0        fatal error
-         *        0          success
-         *        EALREADY   lost connection race
-         *        EPROTO     protocol version mismatch
-         */
+       /* Return < 0        fatal error
+        *        0          success
+        *        EALREADY   lost connection race
+        *        EPROTO     protocol version mismatch
+        */
        struct socket        *sock = conn->ksnc_sock;
-        int                  active = (conn->ksnc_proto != NULL);
-        int                  timeout;
-        int                  proto_match;
-        int                  rc;
+       int                  active = (conn->ksnc_proto != NULL);
+       int                  timeout;
+       int                  proto_match;
+       int                  rc;
        const struct ksock_proto *proto;
        struct lnet_process_id recv_id;
 
@@ -1754,7 +1754,7 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
        LASSERT(!active == !(conn->ksnc_type != SOCKLND_CONN_NONE));
 
        timeout = active ? ksocknal_timeout() :
-                           lnet_acceptor_timeout();
+               lnet_acceptor_timeout();
 
        rc = lnet_sock_read(sock, &hello->kshm_magic,
                            sizeof(hello->kshm_magic), timeout);
@@ -1777,47 +1777,51 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
 
        rc = lnet_sock_read(sock, &hello->kshm_version,
                            sizeof(hello->kshm_version), timeout);
-        if (rc != 0) {
+       if (rc != 0) {
                CERROR("Error %d reading HELLO from %pIS\n",
                       rc, &conn->ksnc_peeraddr);
                LASSERT(rc < 0);
-                return rc;
-        }
+               return rc;
+       }
 
-        proto = ksocknal_parse_proto_version(hello);
-        if (proto == NULL) {
-                if (!active) {
-                        /* unknown protocol from peer_ni, tell peer_ni my protocol */
-                        conn->ksnc_proto = &ksocknal_protocol_v3x;
+       proto = ksocknal_parse_proto_version(hello);
+       if (proto == NULL) {
+               if (!active) {
+                       /* unknown protocol from peer_ni,
+                        * tell peer_ni my protocol.
+                        */
+                       conn->ksnc_proto = &ksocknal_protocol_v3x;
 #if SOCKNAL_VERSION_DEBUG
-                        if (*ksocknal_tunables.ksnd_protocol == 2)
-                                conn->ksnc_proto = &ksocknal_protocol_v2x;
-                        else if (*ksocknal_tunables.ksnd_protocol == 1)
-                                conn->ksnc_proto = &ksocknal_protocol_v1x;
+                       if (*ksocknal_tunables.ksnd_protocol == 2)
+                               conn->ksnc_proto = &ksocknal_protocol_v2x;
+                       else if (*ksocknal_tunables.ksnd_protocol == 1)
+                               conn->ksnc_proto = &ksocknal_protocol_v1x;
 #endif
-                        hello->kshm_nips = 0;
-                        ksocknal_send_hello(ni, conn, ni->ni_nid, hello);
-                }
+                       hello->kshm_nips = 0;
+                       ksocknal_send_hello(ni, conn,
+                                           lnet_nid_to_nid4(&ni->ni_nid),
+                                           hello);
+               }
 
                CERROR("Unknown protocol version (%d.x expected) from %pIS\n",
                       conn->ksnc_proto->pro_version, &conn->ksnc_peeraddr);
 
-                return -EPROTO;
-        }
+               return -EPROTO;
+       }
 
-        proto_match = (conn->ksnc_proto == proto);
-        conn->ksnc_proto = proto;
+       proto_match = (conn->ksnc_proto == proto);
+       conn->ksnc_proto = proto;
 
-        /* receive the rest of hello message anyway */
-        rc = conn->ksnc_proto->pro_recv_hello(conn, hello, timeout);
-        if (rc != 0) {
+       /* receive the rest of hello message anyway */
+       rc = conn->ksnc_proto->pro_recv_hello(conn, hello, timeout);
+       if (rc != 0) {
                CERROR("Error %d reading or checking hello from from %pIS\n",
                       rc, &conn->ksnc_peeraddr);
-                LASSERT (rc < 0);
-                return rc;
-        }
+               LASSERT(rc < 0);
+               return rc;
+       }
 
-        *incarnation = hello->kshm_src_incarnation;
+       *incarnation = hello->kshm_src_incarnation;
 
        if (hello->kshm_src_nid == LNET_NID_ANY) {
                CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY from %pIS\n",
@@ -1834,7 +1838,7 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
                        LNET_PID_USERFLAG;
                LASSERT(conn->ksnc_peeraddr.ss_family == AF_INET);
                recv_id.nid = LNET_MKNID(
-                       LNET_NIDNET(ni->ni_nid),
+                       LNET_NID_NET(&ni->ni_nid),
                        ntohl(((struct sockaddr_in *)
                               &conn->ksnc_peeraddr)->sin_addr.s_addr));
        } else {
@@ -1842,8 +1846,8 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
                recv_id.pid = hello->kshm_src_pid;
        }
 
-        if (!active) {
-                *peerid = recv_id;
+       if (!active) {
+               *peerid = recv_id;
 
                /* peer_ni determines type */
                conn->ksnc_type = ksocknal_invert_type(hello->kshm_ctype);
@@ -1866,10 +1870,10 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
                return -EPROTO;
        }
 
-        if (hello->kshm_ctype == SOCKLND_CONN_NONE) {
-                /* Possible protocol mismatch or I lost the connection race */
-                return proto_match ? EALREADY : EPROTO;
-        }
+       if (hello->kshm_ctype == SOCKLND_CONN_NONE) {
+               /* Possible protocol mismatch or I lost the connection race */
+               return proto_match ? EALREADY : EPROTO;
+       }
 
        if (ksocknal_invert_type(hello->kshm_ctype) != conn->ksnc_type) {
                CERROR("Mismatched types: me %d, %s ip %pIS %d\n",
index f287ae6..28c4ec7 100644 (file)
@@ -290,7 +290,8 @@ lnet_accept(struct socket *sock, __u32 magic)
 
        ni = lnet_nid2ni_addref(cr.acr_nid);
        if (ni == NULL ||               /* no matching net */
-           ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */
+           lnet_nid_to_nid4(&ni->ni_nid) != cr.acr_nid) {
+               /* right NET, wrong NID! */
                if (ni != NULL)
                        lnet_ni_decref(ni);
                LCONSOLE_ERROR_MSG(0x120,
index 11af33b..9ad1f84 100644 (file)
@@ -738,6 +738,17 @@ static void lnet_assert_wire_constants(void)
        BUILD_BUG_ON((int)sizeof(lnet_nid_t) != 8);
        BUILD_BUG_ON((int)sizeof(lnet_pid_t) != 4);
 
+       /* Checks for struct lnet_nid */
+       BUILD_BUG_ON((int)sizeof(struct lnet_nid) != 20);
+       BUILD_BUG_ON((int)offsetof(struct lnet_nid, nid_size) != 0);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_nid *)0)->nid_size) != 1);
+       BUILD_BUG_ON((int)offsetof(struct lnet_nid, nid_type) != 1);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_nid *)0)->nid_type) != 1);
+       BUILD_BUG_ON((int)offsetof(struct lnet_nid, nid_num) != 2);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_nid *)0)->nid_num) != 2);
+       BUILD_BUG_ON((int)offsetof(struct lnet_nid, nid_addr) != 4);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_nid *)0)->nid_addr) != 16);
+
        /* Checks for struct lnet_process_id_packed */
        BUILD_BUG_ON((int)sizeof(struct lnet_process_id_packed) != 12);
        BUILD_BUG_ON((int)offsetof(struct lnet_process_id_packed, nid) != 0);
@@ -1597,16 +1608,18 @@ lnet_islocalnet(__u32 net_id)
 }
 
 struct lnet_ni  *
-lnet_nid2ni_locked(lnet_nid_t nid, int cpt)
+lnet_nid2ni_locked(lnet_nid_t nid4, int cpt)
 {
-       struct lnet_net  *net;
-       struct lnet_ni   *ni;
+       struct lnet_net *net;
+       struct lnet_ni *ni;
+       struct lnet_nid nid;
 
        LASSERT(cpt != LNET_LOCK_EX);
+       lnet_nid4_to_nid(nid4, &nid);
 
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       if (ni->ni_nid == nid)
+                       if (nid_same(&ni->ni_nid, &nid))
                                return ni;
                }
        }
@@ -1906,7 +1919,9 @@ lnet_ping_target_install_locked(struct lnet_ping_buffer *pbuf)
 
                        ns = &pbuf->pb_info.pi_ni[i];
 
-                       ns->ns_nid = ni->ni_nid;
+                       if (!nid_is_nid4(&ni->ni_nid))
+                               continue;
+                       ns->ns_nid = lnet_nid_to_nid4(&ni->ni_nid);
 
                        lnet_ni_lock(ni);
                        ns->ns_status = lnet_ni_get_status_locked(ni);
@@ -2221,7 +2236,7 @@ lnet_clear_zombies_nis_locked(struct lnet_net *net)
                        if ((i & (-i)) == i) {
                                CDEBUG(D_WARNING,
                                       "Waiting for zombie LNI %s\n",
-                                      libcfs_nid2str(ni->ni_nid));
+                                      libcfs_nidstr(&ni->ni_nid));
                        }
                        schedule_timeout_uninterruptible(cfs_time_seconds(1));
 
@@ -2246,7 +2261,7 @@ lnet_clear_zombies_nis_locked(struct lnet_net *net)
 
                if (!islo)
                        CDEBUG(D_LNI, "Removed LNI %s\n",
-                             libcfs_nid2str(ni->ni_nid));
+                             libcfs_nidstr(&ni->ni_nid));
 
                lnet_ni_free(ni);
                i = 2;
@@ -2420,7 +2435,7 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_lnd_tunables *tun)
        atomic_set(&ni->ni_healthv, LNET_MAX_HEALTH_VALUE);
 
        CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n",
-               libcfs_nid2str(ni->ni_nid),
+               libcfs_nidstr(&ni->ni_nid),
                ni->ni_net->net_tunables.lct_peer_tx_credits,
                lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER,
                ni->ni_net->net_tunables.lct_peer_rtr_credits,
@@ -2997,7 +3012,7 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_ni *cfg_ni,
        size_t min_size = 0;
        int i;
 
-       if (!ni || !cfg_ni || !tun)
+       if (!ni || !cfg_ni || !tun || !nid_is_nid4(&ni->ni_nid))
                return;
 
        if (ni->ni_interface != NULL) {
@@ -3006,7 +3021,7 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_ni *cfg_ni,
                        sizeof(cfg_ni->lic_ni_intf));
        }
 
-       cfg_ni->lic_nid = ni->ni_nid;
+       cfg_ni->lic_nid = lnet_nid_to_nid4(&ni->ni_nid);
        cfg_ni->lic_status = lnet_ni_get_status_locked(ni);
        cfg_ni->lic_dev_cpt = ni->ni_dev_cpt;
 
@@ -3066,7 +3081,7 @@ lnet_fill_ni_info_legacy(struct lnet_ni *ni,
        size_t min_size, tunable_size = 0;
        int i;
 
-       if (!ni || !config)
+       if (!ni || !config || !nid_is_nid4(&ni->ni_nid))
                return;
 
        net_config = (struct lnet_ioctl_net_config *) config->cfg_bulk;
@@ -3080,7 +3095,7 @@ lnet_fill_ni_info_legacy(struct lnet_ni *ni,
                ni->ni_interface,
                sizeof(net_config->ni_interface));
 
-       config->cfg_nid = ni->ni_nid;
+       config->cfg_nid = lnet_nid_to_nid4(&ni->ni_nid);
        config->cfg_config_u.cfg_net.net_peer_timeout =
                ni->ni_net->net_tunables.lct_peer_timeout;
        config->cfg_config_u.cfg_net.net_max_tx_credits =
@@ -3362,7 +3377,7 @@ static int lnet_add_net_common(struct lnet_net *net,
                rc = lnet_udsp_apply_policies_on_ni(ni);
                if (rc)
                        CERROR("Failed to apply UDSPs on ni %s\n",
-                              libcfs_nid2str(ni->ni_nid));
+                              libcfs_nidstr(&ni->ni_nid));
        }
        lnet_net_unlock(LNET_LOCK_EX);
 
@@ -3709,12 +3724,13 @@ lnet_ni_set_healthv(lnet_nid_t nid, int value, bool all)
        lnet_net_lock(LNET_LOCK_EX);
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       if (ni->ni_nid == nid || all) {
+                       if (all || (nid_is_nid4(&ni->ni_nid) &&
+                                   lnet_nid_to_nid4(&ni->ni_nid) == nid)) {
                                atomic_set(&ni->ni_healthv, value);
                                if (list_empty(&ni->ni_recovery) &&
                                    value < LNET_MAX_HEALTH_VALUE) {
                                        CERROR("manually adding local NI %s to recovery\n",
-                                              libcfs_nid2str(ni->ni_nid));
+                                              libcfs_nidstr(&ni->ni_nid));
                                        list_add_tail(&ni->ni_recovery,
                                                      &the_lnet.ln_mt_localNIRecovq);
                                        lnet_ni_addref_locked(ni, 0);
@@ -3738,7 +3754,7 @@ lnet_ni_set_conns_per_peer(lnet_nid_t nid, int value, bool all)
        lnet_net_lock(LNET_LOCK_EX);
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       if (ni->ni_nid != nid && !all)
+                       if (lnet_nid_to_nid4(&ni->ni_nid) != nid && !all)
                                continue;
                        if (LNET_NETTYP(net->net_id) == SOCKLND)
                                ni->ni_lnd_tunables.lnd_tun_u.lnd_sock.lnd_conns_per_peer = value;
@@ -3793,7 +3809,9 @@ lnet_get_local_ni_recovery_list(struct lnet_ioctl_recovery_list *list)
 
        lnet_net_lock(LNET_LOCK_EX);
        list_for_each_entry(ni, &the_lnet.ln_mt_localNIRecovq, ni_recovery) {
-               list->rlst_nid_array[i] = ni->ni_nid;
+               if (!nid_is_nid4(&ni->ni_nid))
+                       continue;
+               list->rlst_nid_array[i] = lnet_nid_to_nid4(&ni->ni_nid);
                i++;
                if (i >= LNET_MAX_SHOW_NUM_NID)
                        break;
@@ -4434,7 +4452,7 @@ bool LNetIsPeerLocal(lnet_nid_t nid)
        cpt = lnet_net_lock_current();
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       if (ni->ni_nid == nid) {
+                       if (lnet_nid_to_nid4(&ni->ni_nid) == nid) {
                                lnet_net_unlock(cpt);
                                return true;
                        }
@@ -4471,10 +4489,13 @@ LNetGetId(unsigned int index, struct lnet_process_id *id)
 
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
+                       if (!nid_is_nid4(&ni->ni_nid))
+                               /* FIXME this needs to be handled */
+                               continue;
                        if (index-- != 0)
                                continue;
 
-                       id->nid = ni->ni_nid;
+                       id->nid = lnet_nid_to_nid4(&ni->ni_nid);
                        id->pid = the_lnet.ln_pid;
                        rc = 0;
                        break;
index f6ade39..c4a2cc2 100644 (file)
@@ -384,7 +384,7 @@ lnet_ni_add_interface(struct lnet_ni *ni, char *iface)
        if (ni->ni_interface != NULL) {
                LCONSOLE_ERROR_MSG(0x115, "%s: interface %s already set for net %s: rc = %d\n",
                                   iface, ni->ni_interface,
-                                  libcfs_net2str(LNET_NIDNET(ni->ni_nid)),
+                                  libcfs_net2str(LNET_NID_NET(&ni->ni_nid)),
                                   -EINVAL);
                return -EINVAL;
        }
@@ -446,7 +446,8 @@ lnet_ni_alloc_common(struct lnet_net *net, char *iface)
 
        ni->ni_net = net;
        /* LND will fill in the address part of the NID */
-       ni->ni_nid = LNET_MKNID(net->net_id, 0);
+       ni->ni_nid.nid_type = LNET_NETTYP(net->net_id);
+       ni->ni_nid.nid_num = cpu_to_be16(LNET_NETNUM(net->net_id));
 
        /* Store net namespace in which current ni is being created */
        if (current->nsproxy && current->nsproxy->net_ns)
index 8f2a7a6..957c8ba 100644 (file)
@@ -733,7 +733,7 @@ lnet_ni_send(struct lnet_ni *ni, struct lnet_msg *msg)
        int rc;
 
        LASSERT(!in_interrupt());
-       LASSERT(ni->ni_nid == LNET_NID_LO_0 ||
+       LASSERT(nid_is_lo0(&ni->ni_nid) ||
                (msg->msg_txcredit && msg->msg_peertxcredit));
 
        rc = (ni->ni_net->net_lnd->lnd_send)(ni, priv, msg);
@@ -843,7 +843,8 @@ lnet_post_send_locked(struct lnet_msg *msg, int do_send)
 
        /* can't get here if we're sending to the loopback interface */
        if (the_lnet.ln_loni)
-               LASSERT(lp->lpni_nid != the_lnet.ln_loni->ni_nid);
+               LASSERT(lp->lpni_nid !=
+                       lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
 
        /* NB 'lp' is always the next hop */
        if ((msg->msg_target.pid & LNET_PID_USERFLAG) == 0 &&
@@ -1322,10 +1323,11 @@ lnet_select_peer_ni(struct lnet_ni *best_ni, lnet_nid_t dst_nid,
                 * preferred, then let's use it
                 */
                if (best_ni) {
-                       lpni_is_preferred = lnet_peer_is_pref_nid_locked(lpni,
-                                                               best_ni->ni_nid);
+                       /* FIXME need to handle large-addr nid */
+                       lpni_is_preferred = lnet_peer_is_pref_nid_locked(
+                               lpni, lnet_nid_to_nid4(&best_ni->ni_nid));
                        CDEBUG(D_NET, "%s lpni_is_preferred = %d\n",
-                              libcfs_nid2str(best_ni->ni_nid),
+                              libcfs_nidstr(&best_ni->ni_nid),
                               lpni_is_preferred);
                } else {
                        lpni_is_preferred = false;
@@ -1701,9 +1703,9 @@ lnet_get_best_ni(struct lnet_net *local_net, struct lnet_ni *best_ni,
 
                if (best_ni)
                        CDEBUG(D_NET, "compare ni %s [c:%d, d:%d, s:%d, p:%u, g:%u] with best_ni %s [c:%d, d:%d, s:%d, p:%u, g:%u]\n",
-                              libcfs_nid2str(ni->ni_nid), ni_credits, distance,
+                              libcfs_nidstr(&ni->ni_nid), ni_credits, distance,
                               ni->ni_seq, ni_sel_prio, ni_dev_prio,
-                              (best_ni) ? libcfs_nid2str(best_ni->ni_nid)
+                              (best_ni) ? libcfs_nidstr(&best_ni->ni_nid)
                               : "not selected", best_credits, shortest_distance,
                               (best_ni) ? best_ni->ni_seq : 0,
                               best_sel_prio, best_dev_prio);
@@ -1748,7 +1750,7 @@ select_ni:
        }
 
        CDEBUG(D_NET, "selected best_ni %s\n",
-              (best_ni) ? libcfs_nid2str(best_ni->ni_nid) : "no selection");
+              (best_ni) ? libcfs_nidstr(&best_ni->ni_nid) : "no selection");
 
        return best_ni;
 }
@@ -1807,11 +1809,12 @@ lnet_handle_lo_send(struct lnet_send_data *sd)
 
        /* No send credit hassles with LOLND */
        lnet_ni_addref_locked(the_lnet.ln_loni, cpt);
-       msg->msg_hdr.dest_nid = cpu_to_le64(the_lnet.ln_loni->ni_nid);
+       msg->msg_hdr.dest_nid =
+               cpu_to_le64(lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
        if (!msg->msg_routing)
                msg->msg_hdr.src_nid =
-                       cpu_to_le64(the_lnet.ln_loni->ni_nid);
-       msg->msg_target.nid = the_lnet.ln_loni->ni_nid;
+                       cpu_to_le64(lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
+       msg->msg_target.nid = lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid);
        lnet_msg_commit(msg, cpt);
        msg->msg_txni = the_lnet.ln_loni;
 
@@ -1841,7 +1844,7 @@ lnet_handle_send(struct lnet_send_data *sd)
        best_ni->ni_net->net_seq++;
 
        CDEBUG(D_NET, "%s NI seq info: [%d:%d:%d:%u] %s LPNI seq info [%d:%d:%d:%u]\n",
-              libcfs_nid2str(best_ni->ni_nid),
+              libcfs_nidstr(&best_ni->ni_nid),
               best_ni->ni_seq, best_ni->ni_net->net_seq,
               atomic_read(&best_ni->ni_tx_credits),
               best_ni->ni_sel_priority,
@@ -1911,7 +1914,8 @@ lnet_handle_send(struct lnet_send_data *sd)
         * originator and set it here.
         */
        if (!msg->msg_routing)
-               msg->msg_hdr.src_nid = cpu_to_le64(msg->msg_txni->ni_nid);
+               msg->msg_hdr.src_nid =
+                       cpu_to_le64(lnet_nid_to_nid4(&msg->msg_txni->ni_nid));
 
        if (routing) {
                msg->msg_target_is_router = 1;
@@ -1953,7 +1957,7 @@ lnet_handle_send(struct lnet_send_data *sd)
        if (!rc)
                CDEBUG(D_NET, "TRACE: %s(%s:%s) -> %s(%s:%s) %s : %s try# %d\n",
                       libcfs_nid2str(msg->msg_hdr.src_nid),
-                      libcfs_nid2str(msg->msg_txni->ni_nid),
+                      libcfs_nidstr(&msg->msg_txni->ni_nid),
                       libcfs_nid2str(sd->sd_src_nid),
                       libcfs_nid2str(msg->msg_hdr.dest_nid),
                       libcfs_nid2str(sd->sd_dst_nid),
@@ -1971,9 +1975,10 @@ lnet_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, struct lnet_ni *lni,
        if (!lnet_peer_is_multi_rail(lpni->lpni_peer_net->lpn_peer) &&
            !lnet_msg_is_response(msg) && lpni->lpni_pref_nnids == 0) {
                CDEBUG(D_NET, "Setting preferred local NID %s on NMR peer %s\n",
-                      libcfs_nid2str(lni->ni_nid),
+                      libcfs_nidstr(&lni->ni_nid),
                       libcfs_nid2str(lpni->lpni_nid));
-               lnet_peer_ni_set_non_mr_pref_nid(lpni, lni->ni_nid);
+               lnet_peer_ni_set_non_mr_pref_nid(
+                       lpni, lnet_nid_to_nid4(&lni->ni_nid));
        }
 }
 
@@ -2026,7 +2031,8 @@ lnet_handle_spec_local_mr_dst(struct lnet_send_data *sd)
        }
 
        if (sd->sd_best_lpni &&
-           sd->sd_best_lpni->lpni_nid == the_lnet.ln_loni->ni_nid)
+           sd->sd_best_lpni->lpni_nid ==
+           lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid))
                return lnet_handle_lo_send(sd);
        else if (sd->sd_best_lpni)
                return lnet_handle_send(sd);
@@ -2150,8 +2156,9 @@ lnet_handle_find_routed_path(struct lnet_send_data *sd,
        struct lnet_peer_ni *gwni = NULL;
        bool route_found = false;
        lnet_nid_t src_nid = (sd->sd_src_nid != LNET_NID_ANY) ? sd->sd_src_nid :
-               (sd->sd_best_ni != NULL) ? sd->sd_best_ni->ni_nid :
-               LNET_NID_ANY;
+               (sd->sd_best_ni != NULL)
+               ? lnet_nid_to_nid4(&sd->sd_best_ni->ni_nid)
+               : LNET_NID_ANY;
        int best_lpn_healthv = 0;
        __u32 best_lpn_sel_prio = LNET_MAX_SELECTION_PRIORITY;
 
@@ -2673,7 +2680,8 @@ lnet_handle_any_mr_dsta(struct lnet_send_data *sd)
                 * network
                 */
                if (sd->sd_best_lpni &&
-                   sd->sd_best_lpni->lpni_nid == the_lnet.ln_loni->ni_nid) {
+                   sd->sd_best_lpni->lpni_nid ==
+                   lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid)) {
                        /*
                         * in case we initially started with a routed
                         * destination, let's reset to local
@@ -3448,7 +3456,7 @@ lnet_recover_local_nis(void)
                lnet_net_unlock(0);
 
                CDEBUG(D_NET, "attempting to recover local ni: %s\n",
-                      libcfs_nid2str(ni->ni_nid));
+                      libcfs_nidstr(&ni->ni_nid));
 
                lnet_ni_lock(ni);
                if (!(ni->ni_recovery_state & LNET_NI_RECOVERY_PENDING)) {
@@ -3458,7 +3466,7 @@ lnet_recover_local_nis(void)
                        LIBCFS_ALLOC(ev_info, sizeof(*ev_info));
                        if (!ev_info) {
                                CERROR("out of memory. Can't recover %s\n",
-                                      libcfs_nid2str(ni->ni_nid));
+                                      libcfs_nidstr(&ni->ni_nid));
                                lnet_ni_lock(ni);
                                ni->ni_recovery_state &=
                                  ~LNET_NI_RECOVERY_PENDING;
@@ -3472,7 +3480,8 @@ lnet_recover_local_nis(void)
                         * We'll unlink the mdh in this case below.
                         */
                        LNetInvalidateMDHandle(&ni->ni_ping_mdh);
-                       nid = ni->ni_nid;
+                       /* FIXME need to handle large-addr nid */
+                       nid = lnet_nid_to_nid4(&ni->ni_nid);
 
                        /*
                         * remove the NI from the local queue and drop the
@@ -4250,11 +4259,12 @@ lnet_parse_get(struct lnet_ni *ni, struct lnet_msg *msg, int rdma_get)
        lnet_ni_recv(ni, msg->msg_private, NULL, 0, 0, 0, 0);
        msg->msg_receiving = 0;
 
-       rc = lnet_send(ni->ni_nid, msg, msg->msg_from);
+       /* FIXME need to handle large-addr nid */
+       rc = lnet_send(lnet_nid_to_nid4(&ni->ni_nid), msg, msg->msg_from);
        if (rc < 0) {
                /* didn't get as far as lnet_ni_send() */
                CERROR("%s: Unable to send REPLY for GET from %s: %d\n",
-                      libcfs_nid2str(ni->ni_nid),
+                      libcfs_nidstr(&ni->ni_nid),
                       libcfs_id2str(info.mi_id), rc);
 
                lnet_finalize(msg, rc);
@@ -4285,7 +4295,7 @@ lnet_parse_reply(struct lnet_ni *ni, struct lnet_msg *msg)
        if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
                CNETERR("%s: Dropping REPLY from %s for %s "
                        "MD %#llx.%#llx\n",
-                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+                       libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
                        (md == NULL) ? "invalid" : "inactive",
                        hdr->msg.reply.dst_wmd.wh_interface_cookie,
                        hdr->msg.reply.dst_wmd.wh_object_cookie);
@@ -4306,7 +4316,7 @@ lnet_parse_reply(struct lnet_ni *ni, struct lnet_msg *msg)
            (md->md_options & LNET_MD_TRUNCATE) == 0) {
                CNETERR("%s: Dropping REPLY from %s length %d "
                        "for MD %#llx would overflow (%d)\n",
-                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+                       libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
                        rlength, hdr->msg.reply.dst_wmd.wh_object_cookie,
                        mlength);
                lnet_res_unlock(cpt);
@@ -4314,7 +4324,7 @@ lnet_parse_reply(struct lnet_ni *ni, struct lnet_msg *msg)
        }
 
        CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md %#llx\n",
-              libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+              libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
               mlength, rlength, hdr->msg.reply.dst_wmd.wh_object_cookie);
 
        lnet_msg_attach_md(msg, md, 0, mlength);
@@ -4354,7 +4364,7 @@ lnet_parse_ack(struct lnet_ni *ni, struct lnet_msg *msg)
                /* Don't moan; this is expected */
                CDEBUG(D_NET,
                       "%s: Dropping ACK from %s to %s MD %#llx.%#llx\n",
-                      libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+                      libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
                       (md == NULL) ? "invalid" : "inactive",
                       hdr->msg.ack.dst_wmd.wh_interface_cookie,
                       hdr->msg.ack.dst_wmd.wh_object_cookie);
@@ -4367,7 +4377,7 @@ lnet_parse_ack(struct lnet_ni *ni, struct lnet_msg *msg)
        }
 
        CDEBUG(D_NET, "%s: ACK from %s into md %#llx\n",
-              libcfs_nid2str(ni->ni_nid), libcfs_id2str(src),
+              libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
               hdr->msg.ack.dst_wmd.wh_object_cookie);
 
        lnet_msg_attach_md(msg, md, 0, 0);
@@ -4479,12 +4489,13 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        dest_pid = le32_to_cpu(hdr->dest_pid);
        payload_length = le32_to_cpu(hdr->payload_length);
 
-       for_me = (ni->ni_nid == dest_nid);
+       /* FIXME handle large-addr nids */
+       for_me = (lnet_nid_to_nid4(&ni->ni_nid) == dest_nid);
        cpt = lnet_cpt_of_nid(from_nid, ni);
 
        CDEBUG(D_NET, "TRACE: %s(%s) <- %s : %s - %s\n",
                libcfs_nid2str(dest_nid),
-               libcfs_nid2str(ni->ni_nid),
+               libcfs_nidstr(&ni->ni_nid),
                libcfs_nid2str(src_nid),
                lnet_msgtyp2str(type),
                (for_me) ? "for me" : "routed");
@@ -4541,7 +4552,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
         * or malicious so we chop them off at the knees :) */
 
        if (!for_me) {
-               if (LNET_NIDNET(dest_nid) == LNET_NIDNET(ni->ni_nid)) {
+               if (LNET_NIDNET(dest_nid) == LNET_NID_NET(&ni->ni_nid)) {
                        /* should have gone direct */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(should have been sent direct)\n",
@@ -4592,8 +4603,9 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                goto drop;
        }
 
+       /* FIXME need to support large-addr nid */
        if (!list_empty(&the_lnet.ln_drop_rules) &&
-           lnet_drop_rule_match(hdr, ni->ni_nid, NULL)) {
+           lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&ni->ni_nid), NULL)) {
                CDEBUG(D_NET,
                       "%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
                       libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
@@ -4637,7 +4649,9 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        }
 
        lnet_net_lock(cpt);
-       lpni = lnet_nid2peerni_locked(from_nid, ni->ni_nid, cpt);
+       /* FIXME support large-addr nid */
+       lpni = lnet_nid2peerni_locked(from_nid, lnet_nid_to_nid4(&ni->ni_nid),
+                                     cpt);
        if (IS_ERR(lpni)) {
                lnet_net_unlock(cpt);
                CERROR("%s, src %s: Dropping %s "
@@ -5062,7 +5076,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
 
        if (msg == NULL) {
                CERROR("%s: Dropping REPLY from %s: can't allocate msg\n",
-                      libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id));
+                      libcfs_nidstr(&ni->ni_nid), libcfs_id2str(peer_id));
                goto drop;
        }
 
@@ -5073,7 +5087,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
 
        if (getmd->md_threshold == 0) {
                CERROR("%s: Dropping REPLY from %s for inactive MD %p\n",
-                       libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id),
+                       libcfs_nidstr(&ni->ni_nid), libcfs_id2str(peer_id),
                        getmd);
                lnet_res_unlock(cpt);
                goto drop;
@@ -5082,7 +5096,7 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg)
        LASSERT(getmd->md_offset == 0);
 
        CDEBUG(D_NET, "%s: Reply from %s md %p\n",
-              libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id), getmd);
+              libcfs_nidstr(&ni->ni_nid), libcfs_id2str(peer_id), getmd);
 
        /* setup information for lnet_build_msg_event */
        msg->msg_initiator = getmsg->msg_txpeer->lpni_peer_net->lpn_peer->lp_primary_nid;
@@ -5294,7 +5308,8 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
        cpt = lnet_net_lock_current();
 
        while ((ni = lnet_get_next_ni_locked(NULL, ni))) {
-               if (ni->ni_nid == dstnid) {
+               /* FIXME support large-addr nid */
+               if (lnet_nid_to_nid4(&ni->ni_nid) == dstnid) {
                        if (srcnidp != NULL)
                                *srcnidp = dstnid;
                        if (orderp != NULL) {
@@ -5308,7 +5323,7 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
                        return local_nid_dist_zero ? 0 : 1;
                }
 
-               if (!matched_dstnet && LNET_NIDNET(ni->ni_nid) == dstnet) {
+               if (!matched_dstnet && LNET_NID_NET(&ni->ni_nid) == dstnet) {
                        matched_dstnet = true;
                        /* We matched the destination net, but we may have
                         * additional local NIs to inspect.
@@ -5317,7 +5332,8 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
                         * they may be overwritten if we match local NI above.
                         */
                        if (srcnidp)
-                               *srcnidp = ni->ni_nid;
+                               /* FIXME support large-addr nids */
+                               *srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
 
                        if (orderp) {
                                /* Check if ni was originally created in
@@ -5373,7 +5389,8 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
                                net = lnet_get_net_locked(shortest->lr_lnet);
                                LASSERT(net);
                                ni = lnet_get_next_ni_locked(net, NULL);
-                               *srcnidp = ni->ni_nid;
+                               /* FIXME support large-addr nids */
+                               *srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
                        }
                        if (orderp != NULL)
                                *orderp = order;
index f23d7d3..b20690b 100644 (file)
@@ -466,7 +466,7 @@ lnet_ni_add_to_recoveryq_locked(struct lnet_ni *ni,
        lnet_ni_set_next_ping(ni, now);
 
        CDEBUG(D_NET, "%s added to recovery queue. ping count: %u next ping: %lld health :%d\n",
-              libcfs_nid2str(ni->ni_nid),
+              libcfs_nidstr(&ni->ni_nid),
               ni->ni_ping_count,
               ni->ni_next_ping,
               atomic_read(&ni->ni_healthv));
@@ -800,10 +800,11 @@ lnet_health_check(struct lnet_msg *msg)
         * if we're sending to the LOLND then the msg_txpeer will not be
         * set. So no need to sanity check it.
         */
-       if (msg->msg_tx_committed && msg->msg_txni->ni_nid != LNET_NID_LO_0)
+       if (msg->msg_tx_committed &&
+           !nid_is_lo0(&msg->msg_txni->ni_nid))
                LASSERT(msg->msg_txpeer);
        else if (msg->msg_tx_committed &&
-                msg->msg_txni->ni_nid == LNET_NID_LO_0)
+                nid_is_lo0(&msg->msg_txni->ni_nid))
                lo = true;
 
        if (hstatus != LNET_MSG_STATUS_OK &&
@@ -830,7 +831,7 @@ lnet_health_check(struct lnet_msg *msg)
                LASSERT(ni);
 
        CDEBUG(D_NET, "health check: %s->%s: %s: %s\n",
-              libcfs_nid2str(ni->ni_nid),
+              libcfs_nidstr(&ni->ni_nid),
               (lo) ? "self" : libcfs_nid2str(lpni->lpni_nid),
               lnet_msgtyp2str(msg->msg_type),
               lnet_health_error2str(hstatus));
@@ -1112,7 +1113,7 @@ lnet_send_error_simulation(struct lnet_msg *msg,
 
        CDEBUG(D_NET, "src %s(%s)->dst %s: %s simulate health error: %s\n",
                libcfs_nid2str(msg->msg_hdr.src_nid),
-               libcfs_nid2str(msg->msg_txni->ni_nid),
+               libcfs_nidstr(&msg->msg_txni->ni_nid),
                libcfs_nid2str(msg->msg_hdr.dest_nid),
                lnet_msgtyp2str(msg->msg_type),
                lnet_health_error2str(*hstatus));
index d443ae4..90cdc3e 100644 (file)
@@ -238,9 +238,50 @@ retry:
 #if IS_ENABLED(CONFIG_IPV6)
                case AF_INET6: {
                        struct sockaddr_in6 *sin6 = (void *)&locaddr;
+                       int val = 0;
 
                        sin6->sin6_family = AF_INET6;
                        sin6->sin6_addr = in6addr_any;
+
+                       /* Make sure we get both IPv4 and IPv6 connections.
+                        * This is the default, but it can be overridden so we
+                        * force it back.
+                        */
+#ifdef HAVE_KERNEL_SETSOCKOPT
+                       kernel_setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
+                                         (char *) &val, sizeof(val));
+#elif defined(_LINUX_SOCKPTR_H)
+                       /* sockptr_t was introduced around
+                        * v5.8-rc4-1952-ga7b75c5a8c41 and allows a
+                        * kernel address to be passed to ->setsockopt
+                        */
+                       if (ipv6_only_sock(sock->sk)) {
+                               sockptr_t optval = KERNEL_SOCKPTR(&val);
+
+                               sock->ops->setsockopt(sock,
+                                                     IPPROTO_IPV6, IPV6_V6ONLY,
+                                                     optval, sizeof(val));
+                       }
+#else
+                       /* From v5.7-rc6-2614-g5a892ff2facb when
+                        * kernel_setsockopt() was removed until
+                        * sockptr_t (above) there is no clean way to
+                        * pass kernel address to setsockopt.  We could
+                        * use get_fs()/set_fs(), but in this particular
+                        * situation there is an easier way.  It depends
+                        * on the fact that at least for these few
+                        * kernels a NULL address to ipv6_setsockopt()
+                        * is treated like the address of a zero.
+                        */
+                       if (ipv6_only_sock(sock->sk) && !val) {
+                               void *optval = NULL;
+
+                               sock->ops->setsockopt(sock,
+                                                     IPPROTO_IPV6, IPV6_V6ONLY,
+                                                     optval, sizeof(val));
+                       }
+#endif /* HAVE_KERNEL_SETSOCKOPT */
+
                        if (interface >= 0 && remaddr) {
                                struct sockaddr_in6 *rem = (void *)remaddr;
 
@@ -343,7 +384,6 @@ struct socket *
 lnet_sock_listen(int local_port, int backlog, struct net *ns)
 {
        struct socket *sock;
-       int val = 0;
        int rc;
 
        sock = lnet_sock_create(-1, NULL, local_port, ns);
@@ -355,39 +395,6 @@ lnet_sock_listen(int local_port, int backlog, struct net *ns)
                return ERR_PTR(rc);
        }
 
-       /* Make sure we get both IPv4 and IPv6 connections.
-        * This is the default, but it can be overridden so
-        * we force it back.
-        */
-#ifdef HAVE_KERNEL_SETSOCKOPT
-       kernel_setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
-                         (char *) &val, sizeof(val));
-#elif defined(_LINUX_SOCKPTR_H)
-       /* sockptr_t was introduced around v5.8-rc4-1952-ga7b75c5a8c41
-        * and allows a kernel address to be passed to ->setsockopt
-        */
-       if (ipv6_only_sock(sock->sk)) {
-               sockptr_t optval = KERNEL_SOCKPTR(&val);
-               sock->ops->setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
-                                     optval, sizeof(val));
-       }
-#else
-       /* From v5.7-rc6-2614-g5a892ff2facb when kernel_setsockopt()
-        * was removed until sockptr_t (above) there is no clean
-        * way to pass kernel address to setsockopt.  We could use
-        * get_fs()/set_fs(), but in this particular situation there
-        * is an easier way.
-        * It depends on the fact that at least for these few kernels
-        * a NULL address to ipv6_setsockopt() is treated like the address
-        * of a zero.
-        */
-       if (ipv6_only_sock(sock->sk) && !val) {
-               void *optval = NULL;
-               sock->ops->setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
-                               optval, sizeof(val));
-       }
-#endif
-
        rc = kernel_listen(sock, backlog);
        if (rc == 0)
                return sock;
index fad700e..82b723c 100644 (file)
@@ -38,7 +38,8 @@ lolnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        LASSERT(!lntmsg->msg_routing);
        LASSERT(!lntmsg->msg_target_is_router);
 
-       return lnet_parse(ni, &lntmsg->msg_hdr, ni->ni_nid, lntmsg, 0);
+       return lnet_parse(ni, &lntmsg->msg_hdr,
+                         lnet_nid_to_nid4(&ni->ni_nid), lntmsg, 0);
 }
 
 static int
index cea39da..dde84cf 100644 (file)
@@ -682,7 +682,7 @@ delayed_msg_process(struct list_head *msg_list, bool drop)
                        list_del_init(&msg->msg_list);
                        ni = msg->msg_txni;
                        CDEBUG(D_NET, "TRACE: msg %p %s -> %s : %s\n", msg,
-                              libcfs_nid2str(ni->ni_nid),
+                              libcfs_nidstr(&ni->ni_nid),
                               libcfs_nid2str(msg->msg_txpeer->lpni_nid),
                               lnet_msgtyp2str(msg->msg_type));
                        lnet_ni_send(ni, msg);
index c95c32c..f0720aa 100644 (file)
@@ -910,6 +910,46 @@ libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size)
 }
 EXPORT_SYMBOL(libcfs_nid2str_r);
 
+char *
+libcfs_nidstr_r(const struct lnet_nid *nid, char *buf, size_t buf_size)
+{
+       __u32 nnum = be16_to_cpu(nid->nid_num);
+       __u32 lnd  = nid->nid_type;
+       struct netstrfns *nf;
+
+       if (LNET_NID_IS_ANY(nid)) {
+               strncpy(buf, "<?>", buf_size);
+               buf[buf_size - 1] = '\0';
+               return buf;
+       }
+
+       nf = libcfs_lnd2netstrfns(lnd);
+       if (nf && nid_is_nid4(nid)) {
+               size_t addr_len;
+
+               nf->nf_addr2str(ntohl(nid->nid_addr[0]), buf, buf_size);
+               addr_len = strlen(buf);
+               if (nnum == 0)
+                       snprintf(buf + addr_len, buf_size - addr_len, "@%s",
+                                nf->nf_name);
+               else
+                       snprintf(buf + addr_len, buf_size - addr_len, "@%s%u",
+                                nf->nf_name, nnum);
+       } else {
+               int l = 0;
+               int words = DIV_ROUND_UP(NID_ADDR_BYTES(nid), 4);
+               int i;
+
+               for (i = 0; i < words && i < 4; i++)
+                       l = snprintf(buf+l, buf_size-l, "%s%x",
+                                    i ? ":" : "", ntohl(nid->nid_addr[i]));
+               snprintf(buf+l, buf_size-l, "@<%u:%u>", lnd, nnum);
+       }
+
+       return buf;
+}
+EXPORT_SYMBOL(libcfs_nidstr_r);
+
 static struct netstrfns *
 libcfs_str2net_internal(const char *str, __u32 *net)
 {
index 50441b3..b75a515 100644 (file)
@@ -1715,23 +1715,22 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset,
        LASSERT(!in_interrupt());
 
        CDEBUG(D_NET, "%s notifying %s: %s\n",
-              (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
+              (ni == NULL) ? "userspace" : libcfs_nidstr(&ni->ni_nid),
               libcfs_nid2str(nid), alive ? "up" : "down");
 
        if (ni != NULL &&
-           LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
+           LNET_NID_NET(&ni->ni_nid) != LNET_NIDNET(nid)) {
                CWARN("Ignoring notification of %s %s by %s (different net)\n",
                      libcfs_nid2str(nid), alive ? "birth" : "death",
-                     libcfs_nid2str(ni->ni_nid));
+                     libcfs_nidstr(&ni->ni_nid));
                return -EINVAL;
        }
 
        /* can't do predictions... */
        if (when > now) {
-               CWARN("Ignoring prediction from %s of %s %s "
-                     "%lld seconds in the future\n",
-                     (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
-                     libcfs_nid2str(nid), alive ? "up" : "down", when - now);
+               CWARN("Ignoring prediction from %s of %s %s %lld seconds in the future\n",
+                       ni ? libcfs_nidstr(&ni->ni_nid) :  "userspace",
+                       libcfs_nid2str(nid), alive ? "up" : "down", when - now);
                return -EINVAL;
        }
 
index df5e25a..69fb21c 100644 (file)
@@ -704,7 +704,7 @@ proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer,
 
                                s += scnprintf(s, tmpstr + tmpsiz - s,
                                       "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n",
-                                      libcfs_nid2str(ni->ni_nid), stat,
+                                      libcfs_nidstr(&ni->ni_nid), stat,
                                       last_alive, *ni->ni_refs[i],
                                       ni->ni_net->net_tunables.lct_peer_tx_credits,
                                       ni->ni_net->net_tunables.lct_peer_rtr_credits,
index 1b0db21..e5741b2 100644 (file)
@@ -212,7 +212,8 @@ lnet_udsp_apply_rule_on_ni(struct udsp_info *udi)
        struct lnet_ud_nid_descr *ni_match = udi->udi_match;
        __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
 
-       rc = cfs_match_nid_net(ni->ni_nid,
+       rc = cfs_match_nid_net(
+               lnet_nid_to_nid4(&ni->ni_nid),
                ni_match->ud_net_id.udn_net_type,
                &ni_match->ud_net_id.udn_net_num_range,
                &ni_match->ud_addr_range);
@@ -220,7 +221,7 @@ lnet_udsp_apply_rule_on_ni(struct udsp_info *udi)
                return 0;
 
        CDEBUG(D_NET, "apply udsp on ni %s\n",
-              libcfs_nid2str(ni->ni_nid));
+              libcfs_nidstr(&ni->ni_nid));
 
        /* Detected match. Set NIDs priority */
        lnet_ni_set_sel_priority_locked(ni, priority);
@@ -476,7 +477,8 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                if (LNET_NETTYP(net->net_id) != ni_action->ud_net_id.udn_net_type)
                        continue;
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       rc = cfs_match_nid_net(ni->ni_nid,
+                       rc = cfs_match_nid_net(
+                               lnet_nid_to_nid4(&ni->ni_nid),
                                ni_action->ud_net_id.udn_net_type,
                                &ni_action->ud_net_id.udn_net_num_range,
                                &ni_action->ud_addr_range);
@@ -495,15 +497,16 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                                }
                        }
                        CDEBUG(D_NET, "add nid %s as preferred for peer %s\n",
-                               libcfs_nid2str(ni->ni_nid),
+                               libcfs_nidstr(&ni->ni_nid),
                                libcfs_nid2str(lpni->lpni_nid));
                        /* match. Add to pref NIDs */
-                       rc = lnet_peer_add_pref_nid(lpni, ni->ni_nid);
+                       rc = lnet_peer_add_pref_nid(
+                               lpni, lnet_nid_to_nid4(&ni->ni_nid));
                        lnet_net_lock(LNET_LOCK_EX);
                        /* success if EEXIST return */
                        if (rc && rc != -EEXIST) {
                                CERROR("Failed to add %s to %s pref nid list\n",
-                                       libcfs_nid2str(ni->ni_nid),
+                                       libcfs_nidstr(&ni->ni_nid),
                                        libcfs_nid2str(lpni->lpni_nid));
                                return rc;
                        }