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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
33 #define DEBUG_SUBSYSTEM S_LNET
34 #include <linux/nsproxy.h>
35 #include <net/net_namespace.h>
36 #include "../../include/linux/lnet/lib-lnet.h"
38 struct lnet_text_buf { /* tmp struct for parsing routes */
39 struct list_head ltb_list; /* stash on lists */
40 int ltb_size; /* allocated size */
41 char ltb_text[0]; /* text buffer */
44 static int lnet_tbnob; /* track text buf allocation */
45 #define LNET_MAX_TEXTBUF_NOB (64 << 10) /* bound allocation */
46 #define LNET_SINGLE_TEXTBUF_NOB (4 << 10)
49 lnet_syntax(char *name, char *str, int offset, int width)
51 static char dots[LNET_SINGLE_TEXTBUF_NOB];
52 static char dashes[LNET_SINGLE_TEXTBUF_NOB];
54 memset(dots, '.', sizeof(dots));
55 dots[sizeof(dots) - 1] = 0;
56 memset(dashes, '-', sizeof(dashes));
57 dashes[sizeof(dashes) - 1] = 0;
59 LCONSOLE_ERROR_MSG(0x10f, "Error parsing '%s=\"%s\"'\n", name, str);
60 LCONSOLE_ERROR_MSG(0x110, "here...........%.*s..%.*s|%.*s|\n",
61 (int)strlen(name), dots, offset, dots,
62 (width < 1) ? 0 : width - 1, dashes);
79 lnet_net_unique(__u32 net, struct list_head *nilist)
81 struct list_head *tmp;
84 list_for_each(tmp, nilist) {
85 ni = list_entry(tmp, lnet_ni_t, ni_list);
87 if (LNET_NIDNET(ni->ni_nid) == net)
95 lnet_ni_free(struct lnet_ni *ni)
100 cfs_percpt_free(ni->ni_refs);
102 if (ni->ni_tx_queues)
103 cfs_percpt_free(ni->ni_tx_queues);
106 cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
108 if (ni->ni_lnd_tunables)
109 LIBCFS_FREE(ni->ni_lnd_tunables, sizeof(*ni->ni_lnd_tunables));
111 for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++) {
112 LIBCFS_FREE(ni->ni_interfaces[i],
113 strlen(ni->ni_interfaces[i]) + 1);
116 /* release reference to net namespace */
118 put_net(ni->ni_net_ns);
120 LIBCFS_FREE(ni, sizeof(*ni));
124 lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
126 struct lnet_tx_queue *tq;
131 if (!lnet_net_unique(net, nilist)) {
132 LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
133 libcfs_net2str(net));
137 LIBCFS_ALLOC(ni, sizeof(*ni));
139 CERROR("Out of memory creating network %s\n",
140 libcfs_net2str(net));
144 spin_lock_init(&ni->ni_lock);
145 INIT_LIST_HEAD(&ni->ni_cptlist);
146 ni->ni_refs = cfs_percpt_alloc(lnet_cpt_table(),
147 sizeof(*ni->ni_refs[0]));
151 ni->ni_tx_queues = cfs_percpt_alloc(lnet_cpt_table(),
152 sizeof(*ni->ni_tx_queues[0]));
153 if (!ni->ni_tx_queues)
156 cfs_percpt_for_each(tq, i, ni->ni_tx_queues)
157 INIT_LIST_HEAD(&tq->tq_delayed);
161 ni->ni_ncpts = LNET_CPT_NUMBER;
163 rc = cfs_expr_list_values(el, LNET_CPT_NUMBER, &ni->ni_cpts);
165 CERROR("Failed to set CPTs for NI %s: %d\n",
166 libcfs_net2str(net), rc);
170 LASSERT(rc <= LNET_CPT_NUMBER);
171 if (rc == LNET_CPT_NUMBER) {
172 LIBCFS_FREE(ni->ni_cpts, rc * sizeof(ni->ni_cpts[0]));
179 /* LND will fill in the address part of the NID */
180 ni->ni_nid = LNET_MKNID(net, 0);
182 /* Store net namespace in which current ni is being created */
183 if (current->nsproxy->net_ns)
184 ni->ni_net_ns = get_net(current->nsproxy->net_ns);
186 ni->ni_net_ns = NULL;
188 ni->ni_last_alive = ktime_get_real_seconds();
189 list_add_tail(&ni->ni_list, nilist);
197 lnet_parse_networks(struct list_head *nilist, char *networks)
199 struct cfs_expr_list *el = NULL;
207 struct list_head *temp_node;
210 CERROR("networks string is undefined\n");
214 if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
215 /* _WAY_ conservative */
216 LCONSOLE_ERROR_MSG(0x112,
217 "Can't parse networks: string too long\n");
221 tokensize = strlen(networks) + 1;
223 LIBCFS_ALLOC(tokens, tokensize);
225 CERROR("Can't allocate net tokens\n");
229 memcpy(tokens, networks, tokensize);
233 while (str && *str) {
234 char *comma = strchr(str, ',');
235 char *bracket = strchr(str, '(');
236 char *square = strchr(str, '[');
242 * NB we don't check interface conflicts here; it's the LNDs
243 * responsibility (if it cares at all)
245 if (square && (!comma || square < comma)) {
247 * i.e: o2ib0(ib0)[1,2], number between square
248 * brackets are CPTs this NI needs to be bond
250 if (bracket && bracket > square) {
255 tmp = strchr(square, ']');
261 rc = cfs_expr_list_parse(square, tmp - square + 1,
262 0, LNET_CPT_NUMBER - 1, &el);
268 while (square <= tmp)
272 if (!bracket || (comma && comma < bracket)) {
273 /* no interface list specified */
277 net = libcfs_str2net(cfs_trimwhite(str));
279 if (net == LNET_NIDNET(LNET_NID_ANY)) {
280 LCONSOLE_ERROR_MSG(0x113,
281 "Unrecognised network type\n");
286 if (LNET_NETTYP(net) != LOLND && /* LO is implicit */
287 !lnet_ni_alloc(net, el, nilist))
291 cfs_expr_list_free(el);
300 net = libcfs_str2net(cfs_trimwhite(str));
301 if (net == LNET_NIDNET(LNET_NID_ANY)) {
306 ni = lnet_ni_alloc(net, el, nilist);
311 cfs_expr_list_free(el);
318 bracket = strchr(iface, ')');
326 comma = strchr(iface, ',');
330 iface = cfs_trimwhite(iface);
336 if (niface == LNET_MAX_INTERFACES) {
337 LCONSOLE_ERROR_MSG(0x115,
338 "Too many interfaces for net %s\n",
339 libcfs_net2str(net));
344 * Allocate a separate piece of memory and copy
345 * into it the string, so we don't have
346 * a depencency on the tokens string. This way we
347 * can free the tokens at the end of the function.
348 * The newly allocated ni_interfaces[] can be
349 * freed when freeing the NI
351 LIBCFS_ALLOC(ni->ni_interfaces[niface],
353 if (!ni->ni_interfaces[niface]) {
354 CERROR("Can't allocate net interface name\n");
357 strcpy(ni->ni_interfaces[niface], iface);
363 comma = strchr(bracket + 1, ',');
366 str = cfs_trimwhite(str);
375 str = cfs_trimwhite(str);
382 list_for_each(temp_node, nilist)
385 LIBCFS_FREE(tokens, tokensize);
389 lnet_syntax("networks", networks, (int)(tmp - tokens), strlen(tmp));
391 while (!list_empty(nilist)) {
392 ni = list_entry(nilist->next, lnet_ni_t, ni_list);
394 list_del(&ni->ni_list);
399 cfs_expr_list_free(el);
401 LIBCFS_FREE(tokens, tokensize);
406 static struct lnet_text_buf *
407 lnet_new_text_buf(int str_len)
409 struct lnet_text_buf *ltb;
412 /* NB allocate space for the terminating 0 */
413 nob = offsetof(struct lnet_text_buf, ltb_text[str_len + 1]);
414 if (nob > LNET_SINGLE_TEXTBUF_NOB) {
415 /* _way_ conservative for "route net gateway..." */
416 CERROR("text buffer too big\n");
420 if (lnet_tbnob + nob > LNET_MAX_TEXTBUF_NOB) {
421 CERROR("Too many text buffers\n");
425 LIBCFS_ALLOC(ltb, nob);
430 ltb->ltb_text[0] = 0;
436 lnet_free_text_buf(struct lnet_text_buf *ltb)
438 lnet_tbnob -= ltb->ltb_size;
439 LIBCFS_FREE(ltb, ltb->ltb_size);
443 lnet_free_text_bufs(struct list_head *tbs)
445 struct lnet_text_buf *ltb;
447 while (!list_empty(tbs)) {
448 ltb = list_entry(tbs->next, struct lnet_text_buf, ltb_list);
450 list_del(<b->ltb_list);
451 lnet_free_text_buf(ltb);
456 lnet_str2tbs_sep(struct list_head *tbs, char *str)
458 struct list_head pending;
462 struct lnet_text_buf *ltb;
464 INIT_LIST_HEAD(&pending);
466 /* Split 'str' into separate commands */
468 /* skip leading whitespace */
469 while (isspace(*str))
472 /* scan for separator or comment */
473 for (sep = str; *sep; sep++)
474 if (lnet_issep(*sep) || *sep == '#')
477 nob = (int)(sep - str);
479 ltb = lnet_new_text_buf(nob);
481 lnet_free_text_bufs(&pending);
485 for (i = 0; i < nob; i++)
487 ltb->ltb_text[i] = ' ';
489 ltb->ltb_text[i] = str[i];
491 ltb->ltb_text[nob] = 0;
493 list_add_tail(<b->ltb_list, &pending);
497 /* scan for separator */
500 } while (*sep && !lnet_issep(*sep));
509 list_splice(&pending, tbs->prev);
514 lnet_expand1tb(struct list_head *list,
515 char *str, char *sep1, char *sep2,
516 char *item, int itemlen)
518 int len1 = (int)(sep1 - str);
519 int len2 = strlen(sep2 + 1);
520 struct lnet_text_buf *ltb;
522 LASSERT(*sep1 == '[');
523 LASSERT(*sep2 == ']');
525 ltb = lnet_new_text_buf(len1 + itemlen + len2);
529 memcpy(ltb->ltb_text, str, len1);
530 memcpy(<b->ltb_text[len1], item, itemlen);
531 memcpy(<b->ltb_text[len1 + itemlen], sep2 + 1, len2);
532 ltb->ltb_text[len1 + itemlen + len2] = 0;
534 list_add_tail(<b->ltb_list, list);
539 lnet_str2tbs_expand(struct list_head *tbs, char *str)
542 struct list_head pending;
554 INIT_LIST_HEAD(&pending);
556 sep = strchr(str, '[');
557 if (!sep) /* nothing to expand */
560 sep2 = strchr(sep, ']');
564 for (parsed = sep; parsed < sep2; parsed = enditem) {
566 while (enditem < sep2 && *enditem != ',')
569 if (enditem == parsed) /* no empty items */
572 if (sscanf(parsed, "%d-%d/%d%n", &lo, &hi,
573 &stride, &scanned) < 3) {
574 if (sscanf(parsed, "%d-%d%n", &lo, &hi, &scanned) < 2) {
575 /* simple string enumeration */
576 if (lnet_expand1tb(&pending, str, sep, sep2,
578 (int)(enditem - parsed))) {
587 /* range expansion */
589 if (enditem != parsed + scanned) /* no trailing junk */
592 if (hi < 0 || lo < 0 || stride < 0 || hi < lo ||
596 for (i = lo; i <= hi; i += stride) {
597 snprintf(num, sizeof(num), "%d", i);
599 if (nob + 1 == sizeof(num))
602 if (lnet_expand1tb(&pending, str, sep, sep2,
608 list_splice(&pending, tbs->prev);
612 lnet_free_text_bufs(&pending);
617 lnet_parse_hops(char *str, unsigned int *hops)
619 int len = strlen(str);
622 return (sscanf(str, "%u%n", hops, &nob) >= 1 &&
624 *hops > 0 && *hops < 256);
627 #define LNET_PRIORITY_SEPARATOR (':')
630 lnet_parse_priority(char *str, unsigned int *priority, char **token)
636 sep = strchr(str, LNET_PRIORITY_SEPARATOR);
641 len = strlen(sep + 1);
643 if ((sscanf((sep + 1), "%u%n", priority, &nob) < 1) || (len != nob)) {
645 * Update the caller's token pointer so it treats the found
646 * priority as the token to report in the error message.
648 *token += sep - str + 1;
652 CDEBUG(D_NET, "gateway %s, priority %d, nob %d\n", str, *priority, nob);
655 * Change priority separator to \0 to be able to parse NID
662 lnet_parse_route(char *str, int *im_a_router)
664 /* static scratch buffer OK (single threaded) */
665 static char cmd[LNET_SINGLE_TEXTBUF_NOB];
667 struct list_head nets;
668 struct list_head gateways;
669 struct list_head *tmp1;
670 struct list_head *tmp2;
673 struct lnet_text_buf *ltb;
681 unsigned int priority = 0;
683 INIT_LIST_HEAD(&gateways);
684 INIT_LIST_HEAD(&nets);
686 /* save a copy of the string for error messages */
687 strncpy(cmd, str, sizeof(cmd));
688 cmd[sizeof(cmd) - 1] = '\0';
692 /* scan for token start */
693 while (isspace(*sep))
696 if (ntokens < (got_hops ? 3 : 2))
704 /* scan for token end */
705 while (*sep && !isspace(*sep))
711 tmp2 = &nets; /* expanding nets */
712 } else if (ntokens == 2 &&
713 lnet_parse_hops(token, &hops)) {
714 got_hops = 1; /* got a hop count */
717 tmp2 = &gateways; /* expanding gateways */
720 ltb = lnet_new_text_buf(strlen(token));
724 strcpy(ltb->ltb_text, token);
725 tmp1 = <b->ltb_list;
726 list_add_tail(tmp1, tmp2);
728 while (tmp1 != tmp2) {
729 ltb = list_entry(tmp1, struct lnet_text_buf, ltb_list);
731 rc = lnet_str2tbs_expand(tmp1->next, ltb->ltb_text);
737 if (rc > 0) { /* expanded! */
738 list_del(<b->ltb_list);
739 lnet_free_text_buf(ltb);
744 net = libcfs_str2net(ltb->ltb_text);
745 if (net == LNET_NIDNET(LNET_NID_ANY) ||
746 LNET_NETTYP(net) == LOLND)
749 rc = lnet_parse_priority(ltb->ltb_text,
754 nid = libcfs_str2nid(ltb->ltb_text);
755 if (nid == LNET_NID_ANY ||
756 LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
763 * if there are no hops set then we want to flag this value as
764 * unset since hops is an optional parameter
767 hops = LNET_UNDEFINED_HOPS;
769 LASSERT(!list_empty(&nets));
770 LASSERT(!list_empty(&gateways));
772 list_for_each(tmp1, &nets) {
773 ltb = list_entry(tmp1, struct lnet_text_buf, ltb_list);
774 net = libcfs_str2net(ltb->ltb_text);
775 LASSERT(net != LNET_NIDNET(LNET_NID_ANY));
777 list_for_each(tmp2, &gateways) {
778 ltb = list_entry(tmp2, struct lnet_text_buf, ltb_list);
779 nid = libcfs_str2nid(ltb->ltb_text);
780 LASSERT(nid != LNET_NID_ANY);
782 if (lnet_islocalnid(nid)) {
787 rc = lnet_add_route(net, hops, nid, priority);
788 if (rc && rc != -EEXIST && rc != -EHOSTUNREACH) {
789 CERROR("Can't create route to %s via %s\n",
791 libcfs_nid2str(nid));
801 lnet_syntax("routes", cmd, (int)(token - str), strlen(token));
803 lnet_free_text_bufs(&nets);
804 lnet_free_text_bufs(&gateways);
809 lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
811 struct lnet_text_buf *ltb;
813 while (!list_empty(tbs)) {
814 ltb = list_entry(tbs->next, struct lnet_text_buf, ltb_list);
816 if (lnet_parse_route(ltb->ltb_text, im_a_router) < 0) {
817 lnet_free_text_bufs(tbs);
821 list_del(<b->ltb_list);
822 lnet_free_text_buf(ltb);
829 lnet_parse_routes(char *routes, int *im_a_router)
831 struct list_head tbs;
836 INIT_LIST_HEAD(&tbs);
838 if (lnet_str2tbs_sep(&tbs, routes) < 0) {
839 CERROR("Error parsing routes\n");
842 rc = lnet_parse_route_tbs(&tbs, im_a_router);
845 LASSERT(!lnet_tbnob);
850 lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip)
856 rc = cfs_ip_addr_parse(token, len, &list);
860 for (rc = i = 0; !rc && i < nip; i++)
861 rc = cfs_ip_addr_match(ipaddrs[i], &list);
863 cfs_expr_list_free_list(&list);
869 lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
871 static char tokens[LNET_SINGLE_TEXTBUF_NOB];
881 LASSERT(strlen(net_entry) < sizeof(tokens));
883 /* work on a copy of the string */
884 strcpy(tokens, net_entry);
887 /* scan for token start */
888 while (isspace(*sep))
895 /* scan for token end */
896 while (*sep && !isspace(*sep))
908 rc = lnet_match_network_token(token, len, ipaddrs, nip);
910 lnet_syntax("ip2nets", net_entry,
911 (int)(token - tokens), len);
922 strcpy(net_entry, net); /* replace with matched net */
927 lnet_netspec2net(char *netspec)
929 char *bracket = strchr(netspec, '(');
935 net = libcfs_str2net(netspec);
944 lnet_splitnets(char *source, struct list_head *nets)
949 struct lnet_text_buf *tb;
950 struct lnet_text_buf *tb2;
956 LASSERT(!list_empty(nets));
957 LASSERT(nets->next == nets->prev); /* single entry */
959 tb = list_entry(nets->next, struct lnet_text_buf, ltb_list);
962 sep = strchr(tb->ltb_text, ',');
963 bracket = strchr(tb->ltb_text, '(');
965 if (sep && bracket && bracket < sep) {
966 /* netspec lists interfaces... */
968 offset2 = offset + (int)(bracket - tb->ltb_text);
969 len = strlen(bracket);
971 bracket = strchr(bracket + 1, ')');
974 !(bracket[1] == ',' || !bracket[1])) {
975 lnet_syntax("ip2nets", source, offset2, len);
979 sep = !bracket[1] ? NULL : bracket + 1;
985 net = lnet_netspec2net(tb->ltb_text);
986 if (net == LNET_NIDNET(LNET_NID_ANY)) {
987 lnet_syntax("ip2nets", source, offset,
988 strlen(tb->ltb_text));
992 list_for_each(t, nets) {
993 tb2 = list_entry(t, struct lnet_text_buf, ltb_list);
998 if (net == lnet_netspec2net(tb2->ltb_text)) {
999 /* duplicate network */
1000 lnet_syntax("ip2nets", source, offset,
1001 strlen(tb->ltb_text));
1009 offset += (int)(sep - tb->ltb_text);
1011 tb2 = lnet_new_text_buf(len);
1015 strncpy(tb2->ltb_text, sep, len);
1016 tb2->ltb_text[len] = '\0';
1017 list_add_tail(&tb2->ltb_list, nets);
1024 lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
1026 static char networks[LNET_SINGLE_TEXTBUF_NOB];
1027 static char source[LNET_SINGLE_TEXTBUF_NOB];
1029 struct list_head raw_entries;
1030 struct list_head matched_nets;
1031 struct list_head current_nets;
1032 struct list_head *t;
1033 struct list_head *t2;
1034 struct lnet_text_buf *tb;
1035 struct lnet_text_buf *temp;
1036 struct lnet_text_buf *tb2;
1044 INIT_LIST_HEAD(&raw_entries);
1045 if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) {
1046 CERROR("Error parsing ip2nets\n");
1047 LASSERT(!lnet_tbnob);
1051 INIT_LIST_HEAD(&matched_nets);
1052 INIT_LIST_HEAD(¤t_nets);
1058 list_for_each_entry_safe(tb, temp, &raw_entries, ltb_list) {
1059 strncpy(source, tb->ltb_text, sizeof(source));
1060 source[sizeof(source) - 1] = '\0';
1062 /* replace ltb_text with the network(s) add on match */
1063 rc = lnet_match_network_tokens(tb->ltb_text, ipaddrs, nip);
1067 list_del(&tb->ltb_list);
1069 if (!rc) { /* no match */
1070 lnet_free_text_buf(tb);
1074 /* split into separate networks */
1075 INIT_LIST_HEAD(¤t_nets);
1076 list_add(&tb->ltb_list, ¤t_nets);
1077 rc = lnet_splitnets(source, ¤t_nets);
1082 list_for_each(t, ¤t_nets) {
1083 tb = list_entry(t, struct lnet_text_buf, ltb_list);
1084 net1 = lnet_netspec2net(tb->ltb_text);
1085 LASSERT(net1 != LNET_NIDNET(LNET_NID_ANY));
1087 list_for_each(t2, &matched_nets) {
1088 tb2 = list_entry(t2, struct lnet_text_buf,
1090 net2 = lnet_netspec2net(tb2->ltb_text);
1091 LASSERT(net2 != LNET_NIDNET(LNET_NID_ANY));
1104 lnet_free_text_bufs(¤t_nets);
1108 list_for_each_safe(t, t2, ¤t_nets) {
1109 tb = list_entry(t, struct lnet_text_buf, ltb_list);
1111 list_del(&tb->ltb_list);
1112 list_add_tail(&tb->ltb_list, &matched_nets);
1114 len += snprintf(networks + len, sizeof(networks) - len,
1115 "%s%s", !len ? "" : ",",
1118 if (len >= sizeof(networks)) {
1119 CERROR("Too many matched networks\n");
1129 lnet_free_text_bufs(&raw_entries);
1130 lnet_free_text_bufs(&matched_nets);
1131 lnet_free_text_bufs(¤t_nets);
1132 LASSERT(!lnet_tbnob);
1137 *networksp = networks;
1142 lnet_ipaddr_enumerate(__u32 **ipaddrsp)
1150 int nif = lnet_ipif_enumerate(&ifnames);
1157 LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
1159 CERROR("Can't allocate ipaddrs[%d]\n", nif);
1160 lnet_ipif_free_enumeration(ifnames, nif);
1164 for (i = nip = 0; i < nif; i++) {
1165 if (!strcmp(ifnames[i], "lo"))
1168 rc = lnet_ipif_query(ifnames[i], &up, &ipaddrs[nip], &netmask);
1170 CWARN("Can't query interface %s: %d\n",
1176 CWARN("Ignoring interface %s: it's down\n",
1184 lnet_ipif_free_enumeration(ifnames, nif);
1187 *ipaddrsp = ipaddrs;
1190 LIBCFS_ALLOC(ipaddrs2, nip * sizeof(*ipaddrs2));
1192 CERROR("Can't allocate ipaddrs[%d]\n", nip);
1195 memcpy(ipaddrs2, ipaddrs,
1196 nip * sizeof(*ipaddrs));
1197 *ipaddrsp = ipaddrs2;
1201 LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
1207 lnet_parse_ip2nets(char **networksp, char *ip2nets)
1209 __u32 *ipaddrs = NULL;
1210 int nip = lnet_ipaddr_enumerate(&ipaddrs);
1214 LCONSOLE_ERROR_MSG(0x117,
1215 "Error %d enumerating local IP interfaces for ip2nets to match\n",
1221 LCONSOLE_ERROR_MSG(0x118,
1222 "No local IP interfaces for ip2nets to match\n");
1226 rc = lnet_match_networks(networksp, ip2nets, ipaddrs, nip);
1227 LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
1230 LCONSOLE_ERROR_MSG(0x119, "Error %d parsing ip2nets\n", rc);
1235 LCONSOLE_ERROR_MSG(0x11a,
1236 "ip2nets does not match any local IP interfaces\n");