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, Whamcloud, Inc.
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>
42 # define EXPORT_SYMTAB
45 #define DEBUG_SUBSYSTEM S_LNET
47 #include <libcfs/libcfs.h>
48 #include <lnet/lnet.h>
50 #ifdef HAVE_GETHOSTBYNAME
55 /* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids
56 * consistent in all conversion functions. Some code fragments are copied
57 * around for the sake of clarity...
60 /* CAVEAT EMPTOR! Racey temporary buffer allocation!
61 * Choose the number of nidstrings to support the MAXIMUM expected number of
62 * concurrent users. If there are more, the returned string will be volatile.
63 * NB this number must allow for a process to be descheduled for a timeslice
64 * between getting its string and using it.
67 static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE];
68 static int libcfs_nidstring_idx = 0;
71 static cfs_spinlock_t libcfs_nidstring_lock;
73 void libcfs_init_nidstrings (void)
75 cfs_spin_lock_init(&libcfs_nidstring_lock);
78 # define NIDSTR_LOCK(f) cfs_spin_lock_irqsave(&libcfs_nidstring_lock, f)
79 # define NIDSTR_UNLOCK(f) cfs_spin_unlock_irqrestore(&libcfs_nidstring_lock, f)
81 # define NIDSTR_LOCK(f) (f=sizeof(f)) /* avoid set-but-unused warnings */
82 # define NIDSTR_UNLOCK(f) (f=sizeof(f))
86 libcfs_next_nidstring (void)
93 str = libcfs_nidstrings[libcfs_nidstring_idx++];
94 if (libcfs_nidstring_idx ==
95 sizeof(libcfs_nidstrings)/sizeof(libcfs_nidstrings[0]))
96 libcfs_nidstring_idx = 0;
102 static int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr);
103 static void libcfs_ip_addr2str(__u32 addr, char *str);
104 static int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr);
105 static void libcfs_decnum_addr2str(__u32 addr, char *str);
106 static void libcfs_hexnum_addr2str(__u32 addr, char *str);
107 static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr);
108 static int libcfs_num_parse(char *str, int len, cfs_list_t *list);
109 static int libcfs_num_match(__u32 addr, cfs_list_t *list);
115 void (*nf_addr2str)(__u32 addr, char *str);
116 int (*nf_str2addr)(const char *str, int nob, __u32 *addr);
117 int (*nf_parse_addrlist)(char *str, int len,
119 int (*nf_match_addr)(__u32 addr, cfs_list_t *list);
122 static struct netstrfns libcfs_netstrfns[] = {
123 {/* .nf_type */ LOLND,
125 /* .nf_modname */ "klolnd",
126 /* .nf_addr2str */ libcfs_decnum_addr2str,
127 /* .nf_str2addr */ libcfs_lo_str2addr,
128 /* .nf_parse_addr*/ libcfs_num_parse,
129 /* .nf_match_addr*/ libcfs_num_match},
130 {/* .nf_type */ SOCKLND,
131 /* .nf_name */ "tcp",
132 /* .nf_modname */ "ksocklnd",
133 /* .nf_addr2str */ libcfs_ip_addr2str,
134 /* .nf_str2addr */ libcfs_ip_str2addr,
135 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
136 /* .nf_match_addr*/ cfs_ip_addr_match},
137 {/* .nf_type */ O2IBLND,
138 /* .nf_name */ "o2ib",
139 /* .nf_modname */ "ko2iblnd",
140 /* .nf_addr2str */ libcfs_ip_addr2str,
141 /* .nf_str2addr */ libcfs_ip_str2addr,
142 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
143 /* .nf_match_addr*/ cfs_ip_addr_match},
144 {/* .nf_type */ CIBLND,
145 /* .nf_name */ "cib",
146 /* .nf_modname */ "kciblnd",
147 /* .nf_addr2str */ libcfs_ip_addr2str,
148 /* .nf_str2addr */ libcfs_ip_str2addr,
149 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
150 /* .nf_match_addr*/ cfs_ip_addr_match},
151 {/* .nf_type */ OPENIBLND,
152 /* .nf_name */ "openib",
153 /* .nf_modname */ "kopeniblnd",
154 /* .nf_addr2str */ libcfs_ip_addr2str,
155 /* .nf_str2addr */ libcfs_ip_str2addr,
156 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
157 /* .nf_match_addr*/ cfs_ip_addr_match},
158 {/* .nf_type */ IIBLND,
159 /* .nf_name */ "iib",
160 /* .nf_modname */ "kiiblnd",
161 /* .nf_addr2str */ libcfs_ip_addr2str,
162 /* .nf_str2addr */ libcfs_ip_str2addr,
163 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
164 /* .nf_match_addr*/ cfs_ip_addr_match},
165 {/* .nf_type */ VIBLND,
166 /* .nf_name */ "vib",
167 /* .nf_modname */ "kviblnd",
168 /* .nf_addr2str */ libcfs_ip_addr2str,
169 /* .nf_str2addr */ libcfs_ip_str2addr,
170 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
171 /* .nf_match_addr*/ cfs_ip_addr_match},
172 {/* .nf_type */ RALND,
174 /* .nf_modname */ "kralnd",
175 /* .nf_addr2str */ libcfs_ip_addr2str,
176 /* .nf_str2addr */ libcfs_ip_str2addr,
177 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
178 /* .nf_match_addr*/ cfs_ip_addr_match},
179 {/* .nf_type */ QSWLND,
180 /* .nf_name */ "elan",
181 /* .nf_modname */ "kqswlnd",
182 /* .nf_addr2str */ libcfs_decnum_addr2str,
183 /* .nf_str2addr */ libcfs_num_str2addr,
184 /* .nf_parse_addrlist*/ libcfs_num_parse,
185 /* .nf_match_addr*/ libcfs_num_match},
186 {/* .nf_type */ GMLND,
188 /* .nf_modname */ "kgmlnd",
189 /* .nf_addr2str */ libcfs_hexnum_addr2str,
190 /* .nf_str2addr */ libcfs_num_str2addr,
191 /* .nf_parse_addrlist*/ libcfs_num_parse,
192 /* .nf_match_addr*/ libcfs_num_match},
193 {/* .nf_type */ MXLND,
195 /* .nf_modname */ "kmxlnd",
196 /* .nf_addr2str */ libcfs_ip_addr2str,
197 /* .nf_str2addr */ libcfs_ip_str2addr,
198 /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
199 /* .nf_match_addr*/ cfs_ip_addr_match},
200 {/* .nf_type */ PTLLND,
201 /* .nf_name */ "ptl",
202 /* .nf_modname */ "kptllnd",
203 /* .nf_addr2str */ libcfs_decnum_addr2str,
204 /* .nf_str2addr */ libcfs_num_str2addr,
205 /* .nf_parse_addrlist*/ libcfs_num_parse,
206 /* .nf_match_addr*/ libcfs_num_match},
207 {/* .nf_type */ GNILND,
208 /* .nf_name */ "gni",
209 /* .nf_modname */ "kgnilnd",
210 /* .nf_addr2str */ libcfs_decnum_addr2str,
211 /* .nf_str2addr */ libcfs_num_str2addr,
212 /* .nf_parse_addrlist*/ libcfs_num_parse,
213 /* .nf_match_addr*/ libcfs_num_match},
214 /* placeholder for net0 alias. It MUST BE THE LAST ENTRY */
218 const int libcfs_nnetstrfns = sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]);
221 libcfs_lo_str2addr(const char *str, int nob, __u32 *addr)
228 libcfs_ip_addr2str(__u32 addr, char *str)
230 #if 0 /* never lookup */
231 #if !defined(__KERNEL__) && defined HAVE_GETHOSTBYNAME
232 __u32 netip = htonl(addr);
233 struct hostent *he = gethostbyaddr(&netip, sizeof(netip), AF_INET);
236 snprintf(str, LNET_NIDSTR_SIZE, "%s", he->h_name);
241 snprintf(str, LNET_NIDSTR_SIZE, "%u.%u.%u.%u",
242 (addr >> 24) & 0xff, (addr >> 16) & 0xff,
243 (addr >> 8) & 0xff, addr & 0xff);
246 /* CAVEAT EMPTOR XscanfX
247 * I use "%n" at the end of a sscanf format to detect trailing junk. However
248 * sscanf may return immediately if it sees the terminating '0' in a string, so
249 * I initialise the %n variable to the expected length. If sscanf sets it;
250 * fine, if it doesn't, then the scan ended at the end of the string, which is
254 libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
260 int n = nob; /* XscanfX */
263 if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
265 (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
266 (c & ~0xff) == 0 && (d & ~0xff) == 0) {
267 *addr = ((a<<24)|(b<<16)|(c<<8)|d);
271 #if !defined(__KERNEL__) && defined HAVE_GETHOSTBYNAME
272 /* known hostname? */
273 if (('a' <= str[0] && str[0] <= 'z') ||
274 ('A' <= str[0] && str[0] <= 'Z')) {
277 LIBCFS_ALLOC(tmp, nob + 1);
281 memcpy(tmp, str, nob);
284 he = gethostbyname(tmp);
286 LIBCFS_FREE(tmp, nob);
289 __u32 ip = *(__u32 *)he->h_addr;
301 libcfs_decnum_addr2str(__u32 addr, char *str)
303 snprintf(str, LNET_NIDSTR_SIZE, "%u", addr);
307 libcfs_hexnum_addr2str(__u32 addr, char *str)
309 snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr);
313 libcfs_num_str2addr(const char *str, int nob, __u32 *addr)
318 if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob)
322 if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob)
326 if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob)
333 libcfs_lnd2netstrfns(int lnd)
338 for (i = 0; i < libcfs_nnetstrfns; i++)
339 if (lnd == libcfs_netstrfns[i].nf_type)
340 return &libcfs_netstrfns[i];
346 libcfs_namenum2netstrfns(const char *name)
348 struct netstrfns *nf;
351 for (i = 0; i < libcfs_nnetstrfns; i++) {
352 nf = &libcfs_netstrfns[i];
353 if (nf->nf_type >= 0 &&
354 !strncmp(name, nf->nf_name, strlen(nf->nf_name)))
361 libcfs_name2netstrfns(const char *name)
365 for (i = 0; i < libcfs_nnetstrfns; i++)
366 if (libcfs_netstrfns[i].nf_type >= 0 &&
367 !strcmp(libcfs_netstrfns[i].nf_name, name))
368 return &libcfs_netstrfns[i];
374 libcfs_isknown_lnd(int type)
376 return libcfs_lnd2netstrfns(type) != NULL;
380 libcfs_lnd2modname(int lnd)
382 struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
384 return (nf == NULL) ? NULL : nf->nf_modname;
388 libcfs_lnd2str(int lnd)
391 struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
396 str = libcfs_next_nidstring();
397 snprintf(str, LNET_NIDSTR_SIZE, "?%u?", lnd);
402 libcfs_str2lnd(const char *str)
404 struct netstrfns *nf = libcfs_name2netstrfns(str);
413 libcfs_net2str(__u32 net)
415 int lnd = LNET_NETTYP(net);
416 int num = LNET_NETNUM(net);
417 struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
418 char *str = libcfs_next_nidstring();
421 snprintf(str, LNET_NIDSTR_SIZE, "<%u:%u>", lnd, num);
423 snprintf(str, LNET_NIDSTR_SIZE, "%s", nf->nf_name);
425 snprintf(str, LNET_NIDSTR_SIZE, "%s%u", nf->nf_name, num);
431 libcfs_nid2str(lnet_nid_t nid)
433 __u32 addr = LNET_NIDADDR(nid);
434 __u32 net = LNET_NIDNET(nid);
435 int lnd = LNET_NETTYP(net);
436 int nnum = LNET_NETNUM(net);
437 struct netstrfns *nf;
441 if (nid == LNET_NID_ANY)
444 nf = libcfs_lnd2netstrfns(lnd);
445 str = libcfs_next_nidstring();
448 snprintf(str, LNET_NIDSTR_SIZE, "%x@<%u:%u>", addr, lnd, nnum);
450 nf->nf_addr2str(addr, str);
453 snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s",
456 snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s%u",
463 static struct netstrfns *
464 libcfs_str2net_internal(const char *str, __u32 *net)
466 struct netstrfns *nf;
471 for (i = 0; i < libcfs_nnetstrfns; i++) {
472 nf = &libcfs_netstrfns[i];
473 if (nf->nf_type >= 0 &&
474 !strncmp(str, nf->nf_name, strlen(nf->nf_name)))
478 if (i == libcfs_nnetstrfns)
481 nob = strlen(nf->nf_name);
483 if (strlen(str) == (unsigned int)nob) {
486 if (nf->nf_type == LOLND) /* net number not allowed */
491 if (sscanf(str, "%u%n", &netnum, &i) < 1 ||
492 i != (int)strlen(str))
496 *net = LNET_MKNET(nf->nf_type, netnum);
501 libcfs_str2net(const char *str)
505 if (libcfs_str2net_internal(str, &net) != NULL)
508 return LNET_NIDNET(LNET_NID_ANY);
512 libcfs_str2nid(const char *str)
514 const char *sep = strchr(str, '@');
515 struct netstrfns *nf;
520 nf = libcfs_str2net_internal(sep + 1, &net);
524 sep = str + strlen(str);
525 net = LNET_MKNET(SOCKLND, 0);
526 nf = libcfs_lnd2netstrfns(SOCKLND);
527 LASSERT (nf != NULL);
530 if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
533 return LNET_MKNID(net, addr);
537 libcfs_id2str(lnet_process_id_t id)
539 char *str = libcfs_next_nidstring();
541 if (id.pid == LNET_PID_ANY) {
542 snprintf(str, LNET_NIDSTR_SIZE,
543 "LNET_PID_ANY-%s", libcfs_nid2str(id.nid));
547 snprintf(str, LNET_NIDSTR_SIZE, "%s%u-%s",
548 ((id.pid & LNET_PID_USERFLAG) != 0) ? "U" : "",
549 (id.pid & ~LNET_PID_USERFLAG), libcfs_nid2str(id.nid));
554 libcfs_str2anynid(lnet_nid_t *nidp, const char *str)
556 if (!strcmp(str, "*")) {
557 *nidp = LNET_NID_ANY;
561 *nidp = libcfs_str2nid(str);
562 return *nidp != LNET_NID_ANY;
566 * Nid range list syntax.
569 * <nidlist> :== <nidrange> [ ' ' <nidrange> ]
570 * <nidrange> :== <addrrange> '@' <net>
571 * <addrrange> :== '*' |
574 * <ipaddr_range> :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
576 * <cfs_expr_list> :== <number> |
578 * <expr_list> :== '[' <range_expr> [ ',' <range_expr>] ']'
579 * <range_expr> :== <number> |
580 * <number> '-' <number> |
581 * <number> '-' <number> '/' <number>
582 * <net> :== <netname> | <netname><number>
583 * <netname> :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
584 * "vib" | "ra" | "elan" | "mx" | "ptl"
589 * Structure to represent \<nidrange\> token of the syntax.
591 * One of this is created for each \<net\> parsed.
595 * Link to list of this structures which is built on nid range
600 * List head for addrrange::ar_link.
602 cfs_list_t nr_addrranges;
604 * Flag indicating that *@<net> is found.
608 * Pointer to corresponding element of libcfs_netstrfns.
610 struct netstrfns *nr_netstrfns;
612 * Number of network. E.g. 5 if \<net\> is "elan5".
618 * Structure to represent \<addrrange\> token of the syntax.
622 * Link to nidrange::nr_addrranges.
626 * List head for cfs_expr_list::el_list.
628 cfs_list_t ar_numaddr_ranges;
632 * Nf_parse_addrlist method for networks using numeric addresses.
634 * Examples of such networks are gm and elan.
636 * \retval 0 if \a str parsed to numeric address
637 * \retval errno otherwise
640 libcfs_num_parse(char *str, int len, cfs_list_t *list)
642 struct cfs_expr_list *el;
645 rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el);
647 cfs_list_add_tail(&el->el_link, list);
653 * Parses \<addrrange\> token on the syntax.
655 * Allocates struct addrrange and links to \a nidrange via
656 * (nidrange::nr_addrranges)
658 * \retval 1 if \a src parses to '*' | \<ipaddr_range\> | \<cfs_expr_list\>
659 * \retval 0 otherwise
662 parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange)
664 struct addrrange *addrrange;
666 if (src->ls_len == 1 && src->ls_str[0] == '*') {
667 nidrange->nr_all = 1;
671 LIBCFS_ALLOC(addrrange, sizeof(struct addrrange));
672 if (addrrange == NULL)
674 cfs_list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges);
675 CFS_INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges);
677 return nidrange->nr_netstrfns->nf_parse_addrlist(src->ls_str,
679 &addrrange->ar_numaddr_ranges);
683 * Finds or creates struct nidrange.
685 * Checks if \a src is a valid network name, looks for corresponding
686 * nidrange on the ist of nidranges (\a nidlist), creates new struct
687 * nidrange if it is not found.
689 * \retval pointer to struct nidrange matching network specified via \a src
690 * \retval NULL if \a src does not match any network
692 static struct nidrange *
693 add_nidrange(const struct cfs_lstr *src,
696 struct netstrfns *nf;
701 if (src->ls_len >= LNET_NIDSTR_SIZE)
704 nf = libcfs_namenum2netstrfns(src->ls_str);
707 endlen = src->ls_len - strlen(nf->nf_name);
709 /* network name only, e.g. "elan" or "tcp" */
712 /* e.g. "elan25" or "tcp23", refuse to parse if
713 * network name is not appended with decimal or
714 * hexadecimal number */
715 if (!cfs_str2num_check(src->ls_str + strlen(nf->nf_name),
716 endlen, &netnum, 0, MAX_NUMERIC_VALUE))
720 cfs_list_for_each_entry(nr, nidlist, nr_link) {
721 if (nr->nr_netstrfns != nf)
723 if (nr->nr_netnum != netnum)
728 LIBCFS_ALLOC(nr, sizeof(struct nidrange));
731 cfs_list_add_tail(&nr->nr_link, nidlist);
732 CFS_INIT_LIST_HEAD(&nr->nr_addrranges);
733 nr->nr_netstrfns = nf;
735 nr->nr_netnum = netnum;
741 * Parses \<nidrange\> token of the syntax.
743 * \retval 1 if \a src parses to \<addrrange\> '@' \<net\>
744 * \retval 0 otherwise
747 parse_nidrange(struct cfs_lstr *src, cfs_list_t *nidlist)
749 struct cfs_lstr addrrange;
755 if (cfs_gettok(src, '@', &addrrange) == 0)
758 if (cfs_gettok(src, '@', &net) == 0 || src->ls_str != NULL)
761 nr = add_nidrange(&net, nidlist);
765 if (parse_addrange(&addrrange, nr) != 0)
770 CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
775 * Frees addrrange structures of \a list.
777 * For each struct addrrange structure found on \a list it frees
778 * cfs_expr_list list attached to it and frees the addrrange itself.
783 free_addrranges(cfs_list_t *list)
785 while (!cfs_list_empty(list)) {
786 struct addrrange *ar;
788 ar = cfs_list_entry(list->next, struct addrrange, ar_link);
790 cfs_expr_list_free_list(&ar->ar_numaddr_ranges);
791 cfs_list_del(&ar->ar_link);
792 LIBCFS_FREE(ar, sizeof(struct addrrange));
797 * Frees nidrange strutures of \a list.
799 * For each struct nidrange structure found on \a list it frees
800 * addrrange list attached to it and frees the nidrange itself.
805 cfs_free_nidlist(cfs_list_t *list)
807 cfs_list_t *pos, *next;
810 cfs_list_for_each_safe(pos, next, list) {
811 nr = cfs_list_entry(pos, struct nidrange, nr_link);
812 free_addrranges(&nr->nr_addrranges);
814 LIBCFS_FREE(nr, sizeof(struct nidrange));
819 * Parses nid range list.
821 * Parses with rigorous syntax and overflow checking \a str into
822 * \<nidrange\> [ ' ' \<nidrange\> ], compiles \a str into set of
823 * structures and links that structure to \a nidlist. The resulting
824 * list can be used to match a NID againts set of NIDS defined by \a
828 * \retval 1 on success
829 * \retval 0 otherwise
832 cfs_parse_nidlist(char *str, int len, cfs_list_t *nidlist)
841 CFS_INIT_LIST_HEAD(nidlist);
843 rc = cfs_gettok(&src, ' ', &res);
845 cfs_free_nidlist(nidlist);
848 rc = parse_nidrange(&res, nidlist);
850 cfs_free_nidlist(nidlist);
858 * Nf_match_addr method for networks using numeric addresses
861 * \retval 0 otherwise
864 libcfs_num_match(__u32 addr, cfs_list_t *numaddr)
866 struct cfs_expr_list *el;
868 LASSERT(!cfs_list_empty(numaddr));
869 el = cfs_list_entry(numaddr->next, struct cfs_expr_list, el_link);
871 return cfs_expr_list_match(addr, el);
875 * Matches a nid (\a nid) against the compiled list of nidranges (\a nidlist).
877 * \see cfs_parse_nidlist()
880 * \retval 0 otherwises
882 int cfs_match_nid(lnet_nid_t nid, cfs_list_t *nidlist)
885 struct addrrange *ar;
888 cfs_list_for_each_entry(nr, nidlist, nr_link) {
889 if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid)))
891 if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid)))
895 cfs_list_for_each_entry(ar, &nr->nr_addrranges, ar_link)
896 if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid),
897 &ar->ar_numaddr_ranges))
905 EXPORT_SYMBOL(libcfs_isknown_lnd);
906 EXPORT_SYMBOL(libcfs_lnd2modname);
907 EXPORT_SYMBOL(libcfs_lnd2str);
908 EXPORT_SYMBOL(libcfs_str2lnd);
909 EXPORT_SYMBOL(libcfs_net2str);
910 EXPORT_SYMBOL(libcfs_nid2str);
911 EXPORT_SYMBOL(libcfs_str2net);
912 EXPORT_SYMBOL(libcfs_str2nid);
913 EXPORT_SYMBOL(libcfs_id2str);
914 EXPORT_SYMBOL(libcfs_str2anynid);
915 EXPORT_SYMBOL(cfs_free_nidlist);
916 EXPORT_SYMBOL(cfs_parse_nidlist);
917 EXPORT_SYMBOL(cfs_match_nid);