4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * libcfs/libcfs/nidstrings.c
38 * Author: Phil Schwan <phil@clusterfs.com>
41 #define DEBUG_SUBSYSTEM S_LNET
43 #include <libcfs/libcfs.h>
44 #include <lnet/lnet.h>
46 #ifdef HAVE_GETHOSTBYNAME
51 /* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids
52 * consistent in all conversion functions. Some code fragments are copied
53 * around for the sake of clarity...
56 /* CAVEAT EMPTOR! Racey temporary buffer allocation!
57 * Choose the number of nidstrings to support the MAXIMUM expected number of
58 * concurrent users. If there are more, the returned string will be volatile.
59 * NB this number must allow for a process to be descheduled for a timeslice
60 * between getting its string and using it.
63 static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE];
64 static int libcfs_nidstring_idx = 0;
67 static spinlock_t libcfs_nidstring_lock;
69 void libcfs_init_nidstrings (void)
71 spin_lock_init(&libcfs_nidstring_lock);
74 # define NIDSTR_LOCK(f) spin_lock_irqsave(&libcfs_nidstring_lock, f)
75 # define NIDSTR_UNLOCK(f) spin_unlock_irqrestore(&libcfs_nidstring_lock, f)
77 # define NIDSTR_LOCK(f) (f=sizeof(f)) /* avoid set-but-unused warnings */
78 # define NIDSTR_UNLOCK(f) (f=sizeof(f))
82 libcfs_next_nidstring (void)
89 str = libcfs_nidstrings[libcfs_nidstring_idx++];
90 if (libcfs_nidstring_idx ==
91 sizeof(libcfs_nidstrings)/sizeof(libcfs_nidstrings[0]))
92 libcfs_nidstring_idx = 0;
98 static int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr);
99 static void libcfs_ip_addr2str(__u32 addr, char *str);
100 static int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr);
101 static void libcfs_decnum_addr2str(__u32 addr, char *str);
102 static void libcfs_hexnum_addr2str(__u32 addr, char *str);
103 static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr);
104 static int libcfs_num_parse(char *str, int len, cfs_list_t *list);
105 static int libcfs_num_match(__u32 addr, cfs_list_t *list);
111 void (*nf_addr2str)(__u32 addr, char *str);
112 int (*nf_str2addr)(const char *str, int nob, __u32 *addr);
113 int (*nf_parse_addrlist)(char *str, int len,
115 int (*nf_match_addr)(__u32 addr, cfs_list_t *list);
118 static struct netstrfns libcfs_netstrfns[] = {
119 {/* .nf_type */ LOLND,
121 /* .nf_modname */ "klolnd",
122 /* .nf_addr2str */ libcfs_decnum_addr2str,
123 /* .nf_str2addr */ libcfs_lo_str2addr,
124 /* .nf_parse_addr*/ libcfs_num_parse,
125 /* .nf_match_addr*/ libcfs_num_match},
126 {/* .nf_type */ SOCKLND,
127 /* .nf_name */ "tcp",
128 /* .nf_modname */ "ksocklnd",
129 /* .nf_addr2str */ libcfs_ip_addr2str,
130 /* .nf_str2addr */ libcfs_ip_str2addr,
131 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
132 /* .nf_match_addr*/ cfs_ip_addr_match},
133 {/* .nf_type */ O2IBLND,
134 /* .nf_name */ "o2ib",
135 /* .nf_modname */ "ko2iblnd",
136 /* .nf_addr2str */ libcfs_ip_addr2str,
137 /* .nf_str2addr */ libcfs_ip_str2addr,
138 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
139 /* .nf_match_addr*/ cfs_ip_addr_match},
140 {/* .nf_type */ CIBLND,
141 /* .nf_name */ "cib",
142 /* .nf_modname */ "kciblnd",
143 /* .nf_addr2str */ libcfs_ip_addr2str,
144 /* .nf_str2addr */ libcfs_ip_str2addr,
145 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
146 /* .nf_match_addr*/ cfs_ip_addr_match},
147 {/* .nf_type */ OPENIBLND,
148 /* .nf_name */ "openib",
149 /* .nf_modname */ "kopeniblnd",
150 /* .nf_addr2str */ libcfs_ip_addr2str,
151 /* .nf_str2addr */ libcfs_ip_str2addr,
152 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
153 /* .nf_match_addr*/ cfs_ip_addr_match},
154 {/* .nf_type */ IIBLND,
155 /* .nf_name */ "iib",
156 /* .nf_modname */ "kiiblnd",
157 /* .nf_addr2str */ libcfs_ip_addr2str,
158 /* .nf_str2addr */ libcfs_ip_str2addr,
159 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
160 /* .nf_match_addr*/ cfs_ip_addr_match},
161 {/* .nf_type */ VIBLND,
162 /* .nf_name */ "vib",
163 /* .nf_modname */ "kviblnd",
164 /* .nf_addr2str */ libcfs_ip_addr2str,
165 /* .nf_str2addr */ libcfs_ip_str2addr,
166 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
167 /* .nf_match_addr*/ cfs_ip_addr_match},
168 {/* .nf_type */ RALND,
170 /* .nf_modname */ "kralnd",
171 /* .nf_addr2str */ libcfs_ip_addr2str,
172 /* .nf_str2addr */ libcfs_ip_str2addr,
173 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
174 /* .nf_match_addr*/ cfs_ip_addr_match},
175 {/* .nf_type */ QSWLND,
176 /* .nf_name */ "elan",
177 /* .nf_modname */ "kqswlnd",
178 /* .nf_addr2str */ libcfs_decnum_addr2str,
179 /* .nf_str2addr */ libcfs_num_str2addr,
180 /* .nf_parse_addrlist*/ libcfs_num_parse,
181 /* .nf_match_addr*/ libcfs_num_match},
182 {/* .nf_type */ GMLND,
184 /* .nf_modname */ "kgmlnd",
185 /* .nf_addr2str */ libcfs_hexnum_addr2str,
186 /* .nf_str2addr */ libcfs_num_str2addr,
187 /* .nf_parse_addrlist*/ libcfs_num_parse,
188 /* .nf_match_addr*/ libcfs_num_match},
189 {/* .nf_type */ MXLND,
191 /* .nf_modname */ "kmxlnd",
192 /* .nf_addr2str */ libcfs_ip_addr2str,
193 /* .nf_str2addr */ libcfs_ip_str2addr,
194 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
195 /* .nf_match_addr*/ cfs_ip_addr_match},
196 {/* .nf_type */ PTLLND,
197 /* .nf_name */ "ptl",
198 /* .nf_modname */ "kptllnd",
199 /* .nf_addr2str */ libcfs_decnum_addr2str,
200 /* .nf_str2addr */ libcfs_num_str2addr,
201 /* .nf_parse_addrlist*/ libcfs_num_parse,
202 /* .nf_match_addr*/ libcfs_num_match},
203 {/* .nf_type */ GNILND,
204 /* .nf_name */ "gni",
205 /* .nf_modname */ "kgnilnd",
206 /* .nf_addr2str */ libcfs_decnum_addr2str,
207 /* .nf_str2addr */ libcfs_num_str2addr,
208 /* .nf_parse_addrlist*/ libcfs_num_parse,
209 /* .nf_match_addr*/ libcfs_num_match},
210 /* placeholder for net0 alias. It MUST BE THE LAST ENTRY */
214 const int libcfs_nnetstrfns = sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]);
217 libcfs_lo_str2addr(const char *str, int nob, __u32 *addr)
224 libcfs_ip_addr2str(__u32 addr, char *str)
226 #if 0 /* never lookup */
227 #if !defined(__KERNEL__) && defined HAVE_GETHOSTBYNAME
228 __u32 netip = htonl(addr);
229 struct hostent *he = gethostbyaddr(&netip, sizeof(netip), AF_INET);
232 snprintf(str, LNET_NIDSTR_SIZE, "%s", he->h_name);
237 snprintf(str, LNET_NIDSTR_SIZE, "%u.%u.%u.%u",
238 (addr >> 24) & 0xff, (addr >> 16) & 0xff,
239 (addr >> 8) & 0xff, addr & 0xff);
242 /* CAVEAT EMPTOR XscanfX
243 * I use "%n" at the end of a sscanf format to detect trailing junk. However
244 * sscanf may return immediately if it sees the terminating '0' in a string, so
245 * I initialise the %n variable to the expected length. If sscanf sets it;
246 * fine, if it doesn't, then the scan ended at the end of the string, which is
250 libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
256 int n = nob; /* XscanfX */
259 if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
261 (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
262 (c & ~0xff) == 0 && (d & ~0xff) == 0) {
263 *addr = ((a<<24)|(b<<16)|(c<<8)|d);
267 #if !defined(__KERNEL__) && defined HAVE_GETHOSTBYNAME
268 /* known hostname? */
269 if (('a' <= str[0] && str[0] <= 'z') ||
270 ('A' <= str[0] && str[0] <= 'Z')) {
273 LIBCFS_ALLOC(tmp, nob + 1);
277 memcpy(tmp, str, nob);
280 he = gethostbyname(tmp);
282 LIBCFS_FREE(tmp, nob);
285 __u32 ip = *(__u32 *)he->h_addr;
297 libcfs_decnum_addr2str(__u32 addr, char *str)
299 snprintf(str, LNET_NIDSTR_SIZE, "%u", addr);
303 libcfs_hexnum_addr2str(__u32 addr, char *str)
305 snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr);
309 libcfs_num_str2addr(const char *str, int nob, __u32 *addr)
314 if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob)
318 if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob)
322 if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob)
329 libcfs_lnd2netstrfns(int lnd)
334 for (i = 0; i < libcfs_nnetstrfns; i++)
335 if (lnd == libcfs_netstrfns[i].nf_type)
336 return &libcfs_netstrfns[i];
342 libcfs_namenum2netstrfns(const char *name)
344 struct netstrfns *nf;
347 for (i = 0; i < libcfs_nnetstrfns; i++) {
348 nf = &libcfs_netstrfns[i];
349 if (nf->nf_type >= 0 &&
350 !strncmp(name, nf->nf_name, strlen(nf->nf_name)))
357 libcfs_name2netstrfns(const char *name)
361 for (i = 0; i < libcfs_nnetstrfns; i++)
362 if (libcfs_netstrfns[i].nf_type >= 0 &&
363 !strcmp(libcfs_netstrfns[i].nf_name, name))
364 return &libcfs_netstrfns[i];
370 libcfs_isknown_lnd(int type)
372 return libcfs_lnd2netstrfns(type) != NULL;
376 libcfs_lnd2modname(int lnd)
378 struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
380 return (nf == NULL) ? NULL : nf->nf_modname;
384 libcfs_lnd2str(int lnd)
387 struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
392 str = libcfs_next_nidstring();
393 snprintf(str, LNET_NIDSTR_SIZE, "?%u?", lnd);
398 libcfs_str2lnd(const char *str)
400 struct netstrfns *nf = libcfs_name2netstrfns(str);
409 libcfs_net2str(__u32 net)
411 int lnd = LNET_NETTYP(net);
412 int num = LNET_NETNUM(net);
413 struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
414 char *str = libcfs_next_nidstring();
417 snprintf(str, LNET_NIDSTR_SIZE, "<%u:%u>", lnd, num);
419 snprintf(str, LNET_NIDSTR_SIZE, "%s", nf->nf_name);
421 snprintf(str, LNET_NIDSTR_SIZE, "%s%u", nf->nf_name, num);
427 libcfs_nid2str(lnet_nid_t nid)
429 __u32 addr = LNET_NIDADDR(nid);
430 __u32 net = LNET_NIDNET(nid);
431 int lnd = LNET_NETTYP(net);
432 int nnum = LNET_NETNUM(net);
433 struct netstrfns *nf;
437 if (nid == LNET_NID_ANY)
440 nf = libcfs_lnd2netstrfns(lnd);
441 str = libcfs_next_nidstring();
444 snprintf(str, LNET_NIDSTR_SIZE, "%x@<%u:%u>", addr, lnd, nnum);
446 nf->nf_addr2str(addr, str);
449 snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s",
452 snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s%u",
459 static struct netstrfns *
460 libcfs_str2net_internal(const char *str, __u32 *net)
462 struct netstrfns *nf;
467 for (i = 0; i < libcfs_nnetstrfns; i++) {
468 nf = &libcfs_netstrfns[i];
469 if (nf->nf_type >= 0 &&
470 !strncmp(str, nf->nf_name, strlen(nf->nf_name)))
474 if (i == libcfs_nnetstrfns)
477 nob = strlen(nf->nf_name);
479 if (strlen(str) == (unsigned int)nob) {
482 if (nf->nf_type == LOLND) /* net number not allowed */
487 if (sscanf(str, "%u%n", &netnum, &i) < 1 ||
488 i != (int)strlen(str))
492 *net = LNET_MKNET(nf->nf_type, netnum);
497 libcfs_str2net(const char *str)
501 if (libcfs_str2net_internal(str, &net) != NULL)
504 return LNET_NIDNET(LNET_NID_ANY);
508 libcfs_str2nid(const char *str)
510 const char *sep = strchr(str, '@');
511 struct netstrfns *nf;
516 nf = libcfs_str2net_internal(sep + 1, &net);
520 sep = str + strlen(str);
521 net = LNET_MKNET(SOCKLND, 0);
522 nf = libcfs_lnd2netstrfns(SOCKLND);
523 LASSERT (nf != NULL);
526 if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
529 return LNET_MKNID(net, addr);
533 libcfs_id2str(lnet_process_id_t id)
535 char *str = libcfs_next_nidstring();
537 if (id.pid == LNET_PID_ANY) {
538 snprintf(str, LNET_NIDSTR_SIZE,
539 "LNET_PID_ANY-%s", libcfs_nid2str(id.nid));
543 snprintf(str, LNET_NIDSTR_SIZE, "%s%u-%s",
544 ((id.pid & LNET_PID_USERFLAG) != 0) ? "U" : "",
545 (id.pid & ~LNET_PID_USERFLAG), libcfs_nid2str(id.nid));
550 libcfs_str2anynid(lnet_nid_t *nidp, const char *str)
552 if (!strcmp(str, "*")) {
553 *nidp = LNET_NID_ANY;
557 *nidp = libcfs_str2nid(str);
558 return *nidp != LNET_NID_ANY;
562 * Nid range list syntax.
565 * <nidlist> :== <nidrange> [ ' ' <nidrange> ]
566 * <nidrange> :== <addrrange> '@' <net>
567 * <addrrange> :== '*' |
570 * <ipaddr_range> :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
572 * <cfs_expr_list> :== <number> |
574 * <expr_list> :== '[' <range_expr> [ ',' <range_expr>] ']'
575 * <range_expr> :== <number> |
576 * <number> '-' <number> |
577 * <number> '-' <number> '/' <number>
578 * <net> :== <netname> | <netname><number>
579 * <netname> :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
580 * "vib" | "ra" | "elan" | "mx" | "ptl"
585 * Structure to represent \<nidrange\> token of the syntax.
587 * One of this is created for each \<net\> parsed.
591 * Link to list of this structures which is built on nid range
596 * List head for addrrange::ar_link.
598 cfs_list_t nr_addrranges;
600 * Flag indicating that *@<net> is found.
604 * Pointer to corresponding element of libcfs_netstrfns.
606 struct netstrfns *nr_netstrfns;
608 * Number of network. E.g. 5 if \<net\> is "elan5".
614 * Structure to represent \<addrrange\> token of the syntax.
618 * Link to nidrange::nr_addrranges.
622 * List head for cfs_expr_list::el_list.
624 cfs_list_t ar_numaddr_ranges;
628 * Nf_parse_addrlist method for networks using numeric addresses.
630 * Examples of such networks are gm and elan.
632 * \retval 0 if \a str parsed to numeric address
633 * \retval errno otherwise
636 libcfs_num_parse(char *str, int len, cfs_list_t *list)
638 struct cfs_expr_list *el;
641 rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el);
643 cfs_list_add_tail(&el->el_link, list);
649 * Parses \<addrrange\> token on the syntax.
651 * Allocates struct addrrange and links to \a nidrange via
652 * (nidrange::nr_addrranges)
654 * \retval 1 if \a src parses to '*' | \<ipaddr_range\> | \<cfs_expr_list\>
655 * \retval 0 otherwise
658 parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange)
660 struct addrrange *addrrange;
662 if (src->ls_len == 1 && src->ls_str[0] == '*') {
663 nidrange->nr_all = 1;
667 LIBCFS_ALLOC(addrrange, sizeof(struct addrrange));
668 if (addrrange == NULL)
670 cfs_list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges);
671 CFS_INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges);
673 return nidrange->nr_netstrfns->nf_parse_addrlist(src->ls_str,
675 &addrrange->ar_numaddr_ranges);
679 * Finds or creates struct nidrange.
681 * Checks if \a src is a valid network name, looks for corresponding
682 * nidrange on the ist of nidranges (\a nidlist), creates new struct
683 * nidrange if it is not found.
685 * \retval pointer to struct nidrange matching network specified via \a src
686 * \retval NULL if \a src does not match any network
688 static struct nidrange *
689 add_nidrange(const struct cfs_lstr *src,
692 struct netstrfns *nf;
697 if (src->ls_len >= LNET_NIDSTR_SIZE)
700 nf = libcfs_namenum2netstrfns(src->ls_str);
703 endlen = src->ls_len - strlen(nf->nf_name);
705 /* network name only, e.g. "elan" or "tcp" */
708 /* e.g. "elan25" or "tcp23", refuse to parse if
709 * network name is not appended with decimal or
710 * hexadecimal number */
711 if (!cfs_str2num_check(src->ls_str + strlen(nf->nf_name),
712 endlen, &netnum, 0, MAX_NUMERIC_VALUE))
716 cfs_list_for_each_entry(nr, nidlist, nr_link) {
717 if (nr->nr_netstrfns != nf)
719 if (nr->nr_netnum != netnum)
724 LIBCFS_ALLOC(nr, sizeof(struct nidrange));
727 cfs_list_add_tail(&nr->nr_link, nidlist);
728 CFS_INIT_LIST_HEAD(&nr->nr_addrranges);
729 nr->nr_netstrfns = nf;
731 nr->nr_netnum = netnum;
737 * Parses \<nidrange\> token of the syntax.
739 * \retval 1 if \a src parses to \<addrrange\> '@' \<net\>
740 * \retval 0 otherwise
743 parse_nidrange(struct cfs_lstr *src, cfs_list_t *nidlist)
745 struct cfs_lstr addrrange;
751 if (cfs_gettok(src, '@', &addrrange) == 0)
754 if (cfs_gettok(src, '@', &net) == 0 || src->ls_str != NULL)
757 nr = add_nidrange(&net, nidlist);
761 if (parse_addrange(&addrrange, nr) != 0)
766 CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
771 * Frees addrrange structures of \a list.
773 * For each struct addrrange structure found on \a list it frees
774 * cfs_expr_list list attached to it and frees the addrrange itself.
779 free_addrranges(cfs_list_t *list)
781 while (!cfs_list_empty(list)) {
782 struct addrrange *ar;
784 ar = cfs_list_entry(list->next, struct addrrange, ar_link);
786 cfs_expr_list_free_list(&ar->ar_numaddr_ranges);
787 cfs_list_del(&ar->ar_link);
788 LIBCFS_FREE(ar, sizeof(struct addrrange));
793 * Frees nidrange strutures of \a list.
795 * For each struct nidrange structure found on \a list it frees
796 * addrrange list attached to it and frees the nidrange itself.
801 cfs_free_nidlist(cfs_list_t *list)
803 cfs_list_t *pos, *next;
806 cfs_list_for_each_safe(pos, next, list) {
807 nr = cfs_list_entry(pos, struct nidrange, nr_link);
808 free_addrranges(&nr->nr_addrranges);
810 LIBCFS_FREE(nr, sizeof(struct nidrange));
815 * Parses nid range list.
817 * Parses with rigorous syntax and overflow checking \a str into
818 * \<nidrange\> [ ' ' \<nidrange\> ], compiles \a str into set of
819 * structures and links that structure to \a nidlist. The resulting
820 * list can be used to match a NID againts set of NIDS defined by \a
824 * \retval 1 on success
825 * \retval 0 otherwise
828 cfs_parse_nidlist(char *str, int len, cfs_list_t *nidlist)
837 CFS_INIT_LIST_HEAD(nidlist);
839 rc = cfs_gettok(&src, ' ', &res);
841 cfs_free_nidlist(nidlist);
844 rc = parse_nidrange(&res, nidlist);
846 cfs_free_nidlist(nidlist);
854 * Nf_match_addr method for networks using numeric addresses
857 * \retval 0 otherwise
860 libcfs_num_match(__u32 addr, cfs_list_t *numaddr)
862 struct cfs_expr_list *el;
864 LASSERT(!cfs_list_empty(numaddr));
865 el = cfs_list_entry(numaddr->next, struct cfs_expr_list, el_link);
867 return cfs_expr_list_match(addr, el);
871 * Matches a nid (\a nid) against the compiled list of nidranges (\a nidlist).
873 * \see cfs_parse_nidlist()
876 * \retval 0 otherwises
878 int cfs_match_nid(lnet_nid_t nid, cfs_list_t *nidlist)
881 struct addrrange *ar;
884 cfs_list_for_each_entry(nr, nidlist, nr_link) {
885 if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid)))
887 if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid)))
891 cfs_list_for_each_entry(ar, &nr->nr_addrranges, ar_link)
892 if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid),
893 &ar->ar_numaddr_ranges))
901 EXPORT_SYMBOL(libcfs_isknown_lnd);
902 EXPORT_SYMBOL(libcfs_lnd2modname);
903 EXPORT_SYMBOL(libcfs_lnd2str);
904 EXPORT_SYMBOL(libcfs_str2lnd);
905 EXPORT_SYMBOL(libcfs_net2str);
906 EXPORT_SYMBOL(libcfs_nid2str);
907 EXPORT_SYMBOL(libcfs_str2net);
908 EXPORT_SYMBOL(libcfs_str2nid);
909 EXPORT_SYMBOL(libcfs_id2str);
910 EXPORT_SYMBOL(libcfs_str2anynid);
911 EXPORT_SYMBOL(cfs_free_nidlist);
912 EXPORT_SYMBOL(cfs_parse_nidlist);
913 EXPORT_SYMBOL(cfs_match_nid);