]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: address: use route_scope_from_string()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Nov 2021 06:11:15 +0000 (15:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Nov 2021 07:01:18 +0000 (16:01 +0900)
src/network/networkd-address.c

index 5ef38bc476973135eefb9ee4840492bc8858e948..e0f3bd3b1b023c107fea4340328152017017fa35 100644 (file)
@@ -14,6 +14,7 @@
 #include "networkd-manager.h"
 #include "networkd-network.h"
 #include "networkd-queue.h"
+#include "networkd-route-util.h"
 #include "networkd-route.h"
 #include "parse-util.h"
 #include "string-util.h"
@@ -1770,21 +1771,14 @@ int config_parse_address_scope(
                 return 0;
         }
 
-        if (streq(rvalue, "host"))
-                n->scope = RT_SCOPE_HOST;
-        else if (streq(rvalue, "link"))
-                n->scope = RT_SCOPE_LINK;
-        else if (streq(rvalue, "global"))
-                n->scope = RT_SCOPE_UNIVERSE;
-        else {
-                r = safe_atou8(rvalue , &n->scope);
-                if (r < 0) {
-                        log_syntax(unit, LOG_WARNING, filename, line, r,
-                                   "Could not parse address scope \"%s\", ignoring assignment: %m", rvalue);
-                        return 0;
-                }
+        r = route_scope_from_string(rvalue);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Could not parse address scope \"%s\", ignoring assignment: %m", rvalue);
+                return 0;
         }
 
+        n->scope = r;
         n->scope_set = true;
         TAKE_PTR(n);
         return 0;