Whamcloud - gitweb
LU-13837 lnet: Introduce constant for net ID of LNET_NID_ANY 44/39544/4
authorChris Horn <chris.horn@hpe.com>
Thu, 30 Jul 2020 16:29:30 +0000 (11:29 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 26 Nov 2020 09:26:05 +0000 (09:26 +0000)
This patch adds a new constant, LNET_NET_ANY, to represent the net
ID of the LNET_NID_ANY wildcard NID.

Test-Parameters: trivial
HPE-bug-id: LUS-9122
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: I4b4d9e70ba2826843c6585ad5a9e365799face65
Reviewed-on: https://review.whamcloud.com/39544
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
12 files changed:
libcfs/libcfs/util/nidstrings.c
lnet/include/uapi/linux/lnet/lnet-types.h
lnet/lnet/config.c
lnet/lnet/lib-move.c
lnet/lnet/nidstrings.c
lnet/lnet/peer.c
lnet/lnet/router.c
lnet/utils/lnetconfig/liblnetconfig.c
lustre/ldlm/ldlm_lib.c
lustre/mgs/lproc_mgs.c
lustre/ptlrpc/sec_config.c
lustre/utils/portals.c

index b3380d9..f9792c3 100644 (file)
@@ -671,7 +671,7 @@ libcfs_str2net(const char *str)
        if (libcfs_str2net_internal(str, &net) != NULL)
                return net;
 
-       return LNET_NIDNET(LNET_NID_ANY);
+       return LNET_NET_ANY;
 }
 
 lnet_nid_t
index d9cb63a..2a478ef 100644 (file)
@@ -110,6 +110,8 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
 /** The lolnd NID (i.e. myself) */
 #define LNET_NID_LO_0 LNET_MKNID(LNET_MKNET(LOLND, 0), 0)
 
+#define LNET_NET_ANY LNET_NIDNET(LNET_NID_ANY)
+
 #define WIRE_ATTR      __attribute__((packed))
 
 /* Packed version of struct lnet_process_id to transfer via network */
index bf5deea..746253b 100644 (file)
@@ -692,7 +692,7 @@ lnet_parse_networks(struct list_head *netlist, const char *networks,
                 * At this point the name is properly terminated.
                 */
                net_id = libcfs_str2net(name);
-               if (net_id == LNET_NIDNET(LNET_NID_ANY)) {
+               if (net_id == LNET_NET_ANY) {
                        LCONSOLE_ERROR_MSG(0x113,
                                        "Unrecognised network type\n");
                        str = name;
@@ -1181,7 +1181,7 @@ lnet_parse_route(char *str, int *im_a_router)
 
                        if (ntokens == 1) {
                                net = libcfs_str2net(ltb->ltb_text);
-                               if (net == LNET_NIDNET(LNET_NID_ANY) ||
+                               if (net == LNET_NET_ANY ||
                                    LNET_NETTYP(net) == LOLND)
                                        goto token_error;
                        } else {
@@ -1208,7 +1208,7 @@ lnet_parse_route(char *str, int *im_a_router)
        list_for_each(tmp1, &nets) {
                ltb = list_entry(tmp1, struct lnet_text_buf, ltb_list);
                net = libcfs_str2net(ltb->ltb_text);
-               LASSERT (net != LNET_NIDNET(LNET_NID_ANY));
+               LASSERT(net != LNET_NET_ANY);
 
                list_for_each(tmp2, &gateways) {
                        ltb = list_entry(tmp2, struct lnet_text_buf, ltb_list);
@@ -1419,7 +1419,7 @@ lnet_splitnets(char *source, struct list_head *nets)
                        *sep++ = 0;
 
                net = lnet_netspec2net(tb->ltb_text);
-               if (net == LNET_NIDNET(LNET_NID_ANY)) {
+               if (net == LNET_NET_ANY) {
                        lnet_syntax("ip2nets", source, offset,
                                    strlen(tb->ltb_text));
                        return -EINVAL;
index 9565e29..c1e6483 100644 (file)
@@ -1414,10 +1414,9 @@ lnet_find_best_lpni(struct lnet_ni *lni, lnet_nid_t dst_nid,
                    struct lnet_peer *peer, __u32 net_id)
 {
        struct lnet_peer_net *peer_net;
-       __u32 any_net = LNET_NIDNET(LNET_NID_ANY);
 
        /* find the best_lpni on any local network */
-       if (net_id == any_net) {
+       if (net_id == LNET_NET_ANY) {
                struct lnet_peer_ni *best_lpni = NULL;
                struct lnet_peer_net *lpn;
                list_for_each_entry(lpn, &peer->lp_peer_nets, lpn_peer_nets) {
index 2061142..26edd33 100644 (file)
@@ -888,7 +888,7 @@ libcfs_str2net(const char *str)
        if (libcfs_str2net_internal(str, &net) != NULL)
                return net;
 
-       return LNET_NIDNET(LNET_NID_ANY);
+       return LNET_NET_ANY;
 }
 EXPORT_SYMBOL(libcfs_str2net);
 
index 4c3225c..a6943e7 100644 (file)
@@ -605,7 +605,7 @@ lnet_peer_table_del_rtrs_locked(struct lnet_net *net,
                        gw_nid = lp->lpni_peer_net->lpn_peer->lp_primary_nid;
 
                        lnet_net_unlock(LNET_LOCK_EX);
-                       lnet_del_route(LNET_NIDNET(LNET_NID_ANY), gw_nid);
+                       lnet_del_route(LNET_NET_ANY, gw_nid);
                        lnet_net_lock(LNET_LOCK_EX);
                }
        }
index 4858ffc..33b4a17 100644 (file)
@@ -682,7 +682,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,
 
        if (gateway == LNET_NID_ANY ||
            gateway == LNET_NID_LO_0 ||
-           net == LNET_NIDNET(LNET_NID_ANY) ||
+           net == LNET_NET_ANY ||
            LNET_NETTYP(net) == LOLND ||
            LNET_NIDNET(gateway) == net ||
            (hops != LNET_UNDEFINED_HOPS && (hops < 1 || hops > 255)))
@@ -865,7 +865,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid)
                lnet_peer_ni_decref_locked(lpni);
        }
 
-       if (net != LNET_NIDNET(LNET_NID_ANY)) {
+       if (net != LNET_NET_ANY) {
                rnet = lnet_find_rnet_locked(net);
                if (!rnet) {
                        lnet_net_unlock(LNET_LOCK_EX);
@@ -923,7 +923,7 @@ delete_zombies:
 void
 lnet_destroy_routes (void)
 {
-       lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
+       lnet_del_route(LNET_NET_ANY, LNET_NID_ANY);
 }
 
 int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg)
index 3f24797..c584c1d 100644 (file)
@@ -801,7 +801,7 @@ int lustre_lnet_route_common(char *nw, char *nidstr, int hops, int prio,
        }
 
        rnet = libcfs_str2net(nw);
-       if (rnet == LNET_NIDNET(LNET_NID_ANY)) {
+       if (rnet == LNET_NET_ANY) {
                snprintf(err_str, LNET_MAX_STR_LEN,
                         "\"cannot parse remote net %s\"", nw);
                rc = LUSTRE_CFG_RC_BAD_PARAM;
@@ -918,7 +918,7 @@ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
        lnet_nid_t gateway_nid;
        int rc = LUSTRE_CFG_RC_OUT_OF_MEM;
        int l_errno = 0;
-       __u32 net = LNET_NIDNET(LNET_NID_ANY);
+       __u32 net = LNET_NET_ANY;
        int i;
        struct cYAML *root = NULL, *route = NULL, *item = NULL;
        struct cYAML *first_seq = NULL;
@@ -927,7 +927,7 @@ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
 
        if (nw != NULL) {
                net = libcfs_str2net(nw);
-               if (net == LNET_NIDNET(LNET_NID_ANY)) {
+               if (net == LNET_NET_ANY) {
                        snprintf(err_str,
                                 sizeof(err_str),
                                 "\"cannot parse net '%s'\"", nw);
@@ -937,7 +937,7 @@ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
 
        } else {
                /* show all routes without filtering on net */
-               net = LNET_NIDNET(LNET_NID_ANY);
+               net = LNET_NET_ANY;
        }
 
        if (gw != NULL) {
@@ -985,7 +985,7 @@ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
                }
 
                /* filter on provided data */
-               if (net != LNET_NIDNET(LNET_NID_ANY) &&
+               if (net != LNET_NET_ANY &&
                    net != data.cfg_net)
                        continue;
 
@@ -1663,7 +1663,7 @@ int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
                goto out;
        }
 
-       if (nw_descr->nw_id == LNET_NIDNET(LNET_NID_ANY)) {
+       if (nw_descr->nw_id == LNET_NET_ANY) {
                snprintf(err_str,
                        sizeof(err_str),
                        "\"cannot parse net '%s'\"",
@@ -1739,7 +1739,7 @@ int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw_descr,
        if (LNET_NETTYP(nw_descr->nw_id) == LOLND)
                return LUSTRE_CFG_RC_NO_ERR;
 
-       if (nw_descr->nw_id == LNET_NIDNET(LNET_NID_ANY)) {
+       if (nw_descr->nw_id == LNET_NET_ANY) {
                snprintf(err_str,
                         sizeof(err_str),
                         "\"cannot parse net '%s'\"",
@@ -1903,8 +1903,8 @@ int lustre_lnet_show_net(char *nw, int detail, int seq_no,
        struct lnet_ioctl_element_stats *stats;
        struct lnet_ioctl_element_msg_stats msg_stats;
        struct lnet_ioctl_local_ni_hstats hstats;
-       __u32 net = LNET_NIDNET(LNET_NID_ANY);
-       __u32 prev_net = LNET_NIDNET(LNET_NID_ANY);
+       __u32 net = LNET_NET_ANY;
+       __u32 prev_net = LNET_NET_ANY;
        int rc = LUSTRE_CFG_RC_OUT_OF_MEM, i, j;
        int l_errno = 0;
        struct cYAML *root = NULL, *tunables = NULL,
@@ -1928,7 +1928,7 @@ int lustre_lnet_show_net(char *nw, int detail, int seq_no,
 
        if (nw != NULL) {
                net = libcfs_str2net(nw);
-               if (net == LNET_NIDNET(LNET_NID_ANY)) {
+               if (net == LNET_NET_ANY) {
                        snprintf(err_str,
                                 sizeof(err_str),
                                 "\"cannot parse net '%s'\"", nw);
@@ -1967,7 +1967,7 @@ int lustre_lnet_show_net(char *nw, int detail, int seq_no,
                rc_net = LNET_NIDNET(ni_data->lic_nid);
 
                /* filter on provided data */
-               if (net != LNET_NIDNET(LNET_NID_ANY) &&
+               if (net != LNET_NET_ANY &&
                    net != rc_net)
                        continue;
 
index a3386bc..cc7c81a 100644 (file)
@@ -541,7 +541,7 @@ int client_obd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
        if (lustre_cfg_buf(lcfg, 4)) {
                __u32 refnet = libcfs_str2net(lustre_cfg_string(lcfg, 4));
 
-               if (refnet == LNET_NIDNET(LNET_NID_ANY)) {
+               if (refnet == LNET_NET_ANY) {
                        rc = -EINVAL;
                        CERROR("%s: bad mount option 'network=%s': rc = %d\n",
                               obd->obd_name, lustre_cfg_string(lcfg, 4),
index 62d98e3..de08cd0 100644 (file)
@@ -93,7 +93,7 @@ static void seq_show_srpc_rules(struct seq_file *seq, const char *tgtname,
        for (i = 0; i < rset->srs_nrule; i++) {
                r = &rset->srs_rules[i];
 
-               if (r->sr_netid == LNET_NIDNET(LNET_NID_ANY))
+               if (r->sr_netid == LNET_NET_ANY)
                        net = "default";
                else
                        net = libcfs_net2str_r(r->sr_netid, net_buf,
index 630994a..22a230e 100644 (file)
@@ -168,12 +168,12 @@ static void get_default_flavor(struct sptlrpc_flavor *sf)
 
 static void sptlrpc_rule_init(struct sptlrpc_rule *rule)
 {
-        rule->sr_netid = LNET_NIDNET(LNET_NID_ANY);
-        rule->sr_from = LUSTRE_SP_ANY;
-        rule->sr_to = LUSTRE_SP_ANY;
-        rule->sr_padding = 0;
+       rule->sr_netid = LNET_NET_ANY;
+       rule->sr_from = LUSTRE_SP_ANY;
+       rule->sr_to = LUSTRE_SP_ANY;
+       rule->sr_padding = 0;
 
-        get_default_flavor(&rule->sr_flvr);
+       get_default_flavor(&rule->sr_flvr);
 }
 
 /*
@@ -181,57 +181,57 @@ static void sptlrpc_rule_init(struct sptlrpc_rule *rule)
  */
 int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule)
 {
-        char           *flavor, *dir;
-        int             rc;
+       char *flavor, *dir;
+       int rc;
 
-        sptlrpc_rule_init(rule);
+       sptlrpc_rule_init(rule);
 
-        flavor = strchr(param, '=');
-        if (flavor == NULL) {
-                CERROR("invalid param, no '='\n");
-                RETURN(-EINVAL);
-        }
-        *flavor++ = '\0';
-
-        dir = strchr(param, '.');
-        if (dir)
-                *dir++ = '\0';
-
-        /* 1.1 network */
-        if (strcmp(param, "default")) {
-                rule->sr_netid = libcfs_str2net(param);
-                if (rule->sr_netid == LNET_NIDNET(LNET_NID_ANY)) {
-                        CERROR("invalid network name: %s\n", param);
-                        RETURN(-EINVAL);
-                }
-        }
+       flavor = strchr(param, '=');
+       if (flavor == NULL) {
+               CERROR("invalid param, no '='\n");
+               RETURN(-EINVAL);
+       }
+       *flavor++ = '\0';
+
+       dir = strchr(param, '.');
+       if (dir)
+               *dir++ = '\0';
+
+       /* 1.1 network */
+       if (strcmp(param, "default")) {
+               rule->sr_netid = libcfs_str2net(param);
+               if (rule->sr_netid == LNET_NET_ANY) {
+                       CERROR("invalid network name: %s\n", param);
+                       RETURN(-EINVAL);
+               }
+       }
 
-        /* 1.2 direction */
-        if (dir) {
-                if (!strcmp(dir, "mdt2ost")) {
-                        rule->sr_from = LUSTRE_SP_MDT;
-                        rule->sr_to = LUSTRE_SP_OST;
-                } else if (!strcmp(dir, "mdt2mdt")) {
-                        rule->sr_from = LUSTRE_SP_MDT;
-                        rule->sr_to = LUSTRE_SP_MDT;
-                } else if (!strcmp(dir, "cli2ost")) {
-                        rule->sr_from = LUSTRE_SP_CLI;
-                        rule->sr_to = LUSTRE_SP_OST;
-                } else if (!strcmp(dir, "cli2mdt")) {
-                        rule->sr_from = LUSTRE_SP_CLI;
-                        rule->sr_to = LUSTRE_SP_MDT;
-                } else {
-                        CERROR("invalid rule dir segment: %s\n", dir);
-                        RETURN(-EINVAL);
-                }
-        }
+       /* 1.2 direction */
+       if (dir) {
+               if (!strcmp(dir, "mdt2ost")) {
+                       rule->sr_from = LUSTRE_SP_MDT;
+                       rule->sr_to = LUSTRE_SP_OST;
+               } else if (!strcmp(dir, "mdt2mdt")) {
+                       rule->sr_from = LUSTRE_SP_MDT;
+                       rule->sr_to = LUSTRE_SP_MDT;
+               } else if (!strcmp(dir, "cli2ost")) {
+                       rule->sr_from = LUSTRE_SP_CLI;
+                       rule->sr_to = LUSTRE_SP_OST;
+               } else if (!strcmp(dir, "cli2mdt")) {
+                       rule->sr_from = LUSTRE_SP_CLI;
+                       rule->sr_to = LUSTRE_SP_MDT;
+               } else {
+                       CERROR("invalid rule dir segment: %s\n", dir);
+                       RETURN(-EINVAL);
+               }
+       }
 
-        /* 2.1 flavor */
-        rc = sptlrpc_parse_flavor(flavor, &rule->sr_flvr);
-        if (rc)
-                RETURN(-EINVAL);
+       /* 2.1 flavor */
+       rc = sptlrpc_parse_flavor(flavor, &rule->sr_flvr);
+       if (rc)
+               RETURN(-EINVAL);
 
-        RETURN(0);
+       RETURN(0);
 }
 EXPORT_SYMBOL(sptlrpc_parse_rule);
 
@@ -275,29 +275,29 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
                OBD_FREE_PTR_ARRAY(rset->srs_rules, rset->srs_nslot);
        }
 
-        rset->srs_rules = rules;
-        rset->srs_nslot = nslot;
-        return 0;
+       rset->srs_rules = rules;
+       rset->srs_nslot = nslot;
+       return 0;
 }
 
 static inline int rule_spec_dir(struct sptlrpc_rule *rule)
 {
-        return (rule->sr_from != LUSTRE_SP_ANY ||
-                rule->sr_to != LUSTRE_SP_ANY);
+       return (rule->sr_from != LUSTRE_SP_ANY ||
+               rule->sr_to != LUSTRE_SP_ANY);
 }
 static inline int rule_spec_net(struct sptlrpc_rule *rule)
 {
-        return (rule->sr_netid != LNET_NIDNET(LNET_NID_ANY));
+       return (rule->sr_netid != LNET_NET_ANY);
 }
 static inline int rule_match_dir(struct sptlrpc_rule *r1,
                                  struct sptlrpc_rule *r2)
 {
-        return (r1->sr_from == r2->sr_from && r1->sr_to == r2->sr_to);
+       return (r1->sr_from == r2->sr_from && r1->sr_to == r2->sr_to);
 }
 static inline int rule_match_net(struct sptlrpc_rule *r1,
                                  struct sptlrpc_rule *r2)
 {
-        return (r1->sr_netid == r2->sr_netid);
+       return (r1->sr_netid == r2->sr_netid);
 }
 
 /*
@@ -396,35 +396,35 @@ EXPORT_SYMBOL(sptlrpc_rule_set_merge);
  * return 1 if a match found, otherwise return 0.
  */
 int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
-                            enum lustre_sec_part from,
-                            enum lustre_sec_part to,
-                            lnet_nid_t nid,
-                            struct sptlrpc_flavor *sf)
+                           enum lustre_sec_part from,
+                           enum lustre_sec_part to,
+                           lnet_nid_t nid,
+                           struct sptlrpc_flavor *sf)
 {
-        struct sptlrpc_rule    *r;
-        int                     n;
+       struct sptlrpc_rule *r;
+       int n;
 
-        for (n = 0; n < rset->srs_nrule; n++) {
-                r = &rset->srs_rules[n];
+       for (n = 0; n < rset->srs_nrule; n++) {
+               r = &rset->srs_rules[n];
 
-                if (LNET_NIDNET(nid) != LNET_NIDNET(LNET_NID_ANY) &&
-                    r->sr_netid != LNET_NIDNET(LNET_NID_ANY) &&
-                    LNET_NIDNET(nid) != r->sr_netid)
-                        continue;
+               if (LNET_NIDNET(nid) != LNET_NET_ANY &&
+                   r->sr_netid != LNET_NET_ANY &&
+                   LNET_NIDNET(nid) != r->sr_netid)
+                       continue;
 
-                if (from != LUSTRE_SP_ANY && r->sr_from != LUSTRE_SP_ANY &&
-                    from != r->sr_from)
-                        continue;
+               if (from != LUSTRE_SP_ANY && r->sr_from != LUSTRE_SP_ANY &&
+                   from != r->sr_from)
+                       continue;
 
-                if (to != LUSTRE_SP_ANY && r->sr_to != LUSTRE_SP_ANY &&
-                    to != r->sr_to)
-                        continue;
+               if (to != LUSTRE_SP_ANY && r->sr_to != LUSTRE_SP_ANY &&
+                   to != r->sr_to)
+                       continue;
 
-                *sf = r->sr_flvr;
-                return 1;
-        }
+               *sf = r->sr_flvr;
+               return 1;
+       }
 
-        return 0;
+       return 0;
 }
 
 void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *rset)
index a0220a6..1c54f3c 100644 (file)
@@ -292,7 +292,7 @@ int ptl_initialize(int argc, char **argv)
 int jt_ptl_network(int argc, char **argv)
 {
        struct libcfs_ioctl_data data;
-       __u32 net = LNET_NIDNET(LNET_NID_ANY);
+       __u32 net = LNET_NET_ANY;
        int rc;
 
        if (argc != 2) {
@@ -335,7 +335,7 @@ int jt_ptl_network(int argc, char **argv)
        }
 
        net = libcfs_str2net(argv[1]);
-       if (net == LNET_NIDNET(LNET_NID_ANY)) {
+       if (net == LNET_NET_ANY) {
                fprintf(stderr, "Can't parse net %s\n", argv[1]);
                return -1;
        }
@@ -1128,7 +1128,7 @@ jt_ptl_del_route(int argc, char **argv)
        }
 
        LIBCFS_IOC_INIT_V2(data, cfg_hdr);
-       data.cfg_net = g_net_set ? g_net : LNET_NIDNET(LNET_NID_ANY);
+       data.cfg_net = g_net_set ? g_net : LNET_NET_ANY;
        data.cfg_nid = nid;
 
        rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_ROUTE, &data);
@@ -1247,7 +1247,7 @@ fault_attr_nid_parse(char *str, lnet_nid_t *nid_p)
        /* NB: can't support range ipaddress except * and *@net */
        if (strlen(str) > 2 && str[0] == '*' && str[1] == '@') {
                net = libcfs_str2net(str + 2);
-               if (net == LNET_NIDNET(LNET_NID_ANY))
+               if (net == LNET_NET_ANY)
                        goto failed;
 
                nid = LNET_MKNID(net, LNET_NIDADDR(LNET_NID_ANY));