Whamcloud - gitweb
LU-6142 lnet: SPDX for lnet/lnet/
[fs/lustre-release.git] / lnet / lnet / nidstrings.c
index ae28f92..e77c565 100644 (file)
@@ -1,34 +1,12 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+// SPDX-License-Identifier: GPL-2.0
+
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
  * Copyright (c) 2011, 2015, Intel Corporation.
  */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- *
- * lnet/lnet/nidstrings.c
+
+/* This file is part of Lustre, http://www.lustre.org/
  *
  * Author: Phil Schwan <phil@clusterfs.com>
  */
@@ -552,41 +530,32 @@ libcfs_ip_str2addr_size(const char *str, int nob,
 
 /* Used by lnet/config.c so it can't be static */
 int
-cfs_ip_addr_parse(char *str, int len, struct list_head *list)
+cfs_ip_addr_parse(char *str, int len_ignored, struct list_head *list)
 {
        struct cfs_expr_list *el;
-       struct cfs_lstr src;
-       int rc;
-       int i;
-
-       src.ls_str = str;
-       src.ls_len = len;
-       i = 0;
+       int rc = 0;
+       int i = 0;
 
-       while (src.ls_str != NULL) {
-               struct cfs_lstr res;
+       str = strim(str);
+       while (rc == 0 && str) {
+               char *res;
 
-               if (!cfs_gettok(&src, '.', &res)) {
+               res = strsep(&str, ".");
+               res = strim(res);
+               if (!*res) {
                        rc = -EINVAL;
-                       goto out;
+               } else if ((rc = cfs_expr_list_parse(res, strlen(res),
+                                                  0, 255, &el)) == 0) {
+                       list_add_tail(&el->el_link, list);
+                       i++;
                }
-
-               rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
-               if (rc != 0)
-                       goto out;
-
-               list_add_tail(&el->el_link, list);
-               i++;
        }
 
-       if (i == 4)
+       if (rc == 0 && i == 4)
                return 0;
-
-       rc = -EINVAL;
-out:
        cfs_expr_list_free_list(list);
 
-       return rc;
+       return rc ?: -EINVAL;
 }
 
 /**
@@ -1179,6 +1148,10 @@ libcfs_strnid(struct lnet_nid *nid, const char *str)
                if (nf == NULL)
                        return -EINVAL;
        } else {
+               if (strcmp(str, "<?>") == 0) {
+                       memcpy(nid, &LNET_ANY_NID, sizeof(*nid));
+                       return 0;
+               }
                sep = str + strlen(str);
                net = LNET_MKNET(SOCKLND, 0);
                nf = libcfs_lnd2netstrfns(SOCKLND);