]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/radv: merge two boolean flags for prefix into one 32424/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Apr 2024 03:45:18 +0000 (12:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 Apr 2024 03:26:25 +0000 (12:26 +0900)
src/network/networkd-network-gperf.gperf
src/network/networkd-radv.c
src/network/networkd-radv.h

index 4124b3270fe2b49f991a03bbc076b1769d4853c3..23e25ffc1fb284c4c6b0e6d0a92d8e72aaef96ff 100644 (file)
@@ -3,7 +3,9 @@
 #if __GNUC__ >= 7
 _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
 #endif
+#include <netinet/icmp6.h>
 #include <stddef.h>
+
 #include "conf-parser.h"
 #include "in-addr-prefix-util.h"
 #include "netem.h"
@@ -409,8 +411,8 @@ IPv6SendRA.HomeAgent,                        config_parse_bool,
 IPv6SendRA.HomeAgentLifetimeSec,             config_parse_router_home_agent_lifetime,                  0,                             offsetof(Network, home_agent_lifetime_usec)
 IPv6SendRA.HomeAgentPreference,              config_parse_uint16,                                      0,                             offsetof(Network, router_home_agent_preference)
 IPv6Prefix.Prefix,                           config_parse_prefix,                                      0,                             0
-IPv6Prefix.OnLink,                           config_parse_prefix_boolean,                              0,                             0
-IPv6Prefix.AddressAutoconfiguration,         config_parse_prefix_boolean,                              0,                             0
+IPv6Prefix.OnLink,                           config_parse_prefix_boolean,                              ND_OPT_PI_FLAG_ONLINK,         0
+IPv6Prefix.AddressAutoconfiguration,         config_parse_prefix_boolean,                              ND_OPT_PI_FLAG_AUTO,           0
 IPv6Prefix.ValidLifetimeSec,                 config_parse_prefix_lifetime,                             0,                             0
 IPv6Prefix.PreferredLifetimeSec,             config_parse_prefix_lifetime,                             0,                             0
 IPv6Prefix.Assign,                           config_parse_prefix_boolean,                              0,                             0
index a7f89adbdaf58675169d1450fe2ae129ba002f2b..3d6e9a128faa63bd3fcc826921668c2b40d016fc 100644 (file)
@@ -80,10 +80,9 @@ static int prefix_new_static(Network *network, const char *filename, unsigned se
                 .network = network,
                 .section = TAKE_PTR(n),
 
+                .flags = ND_OPT_PI_FLAG_ONLINK | ND_OPT_PI_FLAG_AUTO,
                 .preferred_lifetime = RADV_DEFAULT_PREFERRED_LIFETIME_USEC,
                 .valid_lifetime = RADV_DEFAULT_VALID_LIFETIME_USEC,
-                .onlink = true,
-                .address_auto_configuration = true,
         };
 
         r = hashmap_ensure_put(&network->prefixes_by_section, &config_section_hash_ops, prefix->section, prefix);
@@ -298,11 +297,11 @@ static int radv_set_prefix(Link *link, Prefix *prefix) {
         if (r < 0)
                 return r;
 
-        r = sd_radv_prefix_set_onlink(p, prefix->onlink);
+        r = sd_radv_prefix_set_onlink(p, FLAGS_SET(prefix->flags, ND_OPT_PI_FLAG_ONLINK));
         if (r < 0)
                 return r;
 
-        r = sd_radv_prefix_set_address_autoconfiguration(p, prefix->address_auto_configuration);
+        r = sd_radv_prefix_set_address_autoconfiguration(p, FLAGS_SET(prefix->flags, ND_OPT_PI_FLAG_AUTO));
         if (r < 0)
                 return r;
 
@@ -962,14 +961,12 @@ int config_parse_prefix_boolean(
                 return 0;
         }
 
-        if (streq(lvalue, "OnLink"))
-                p->onlink = r;
-        else if (streq(lvalue, "AddressAutoconfiguration"))
-                p->address_auto_configuration = r;
-        else if (streq(lvalue, "Assign"))
+        if (ltype != 0)
+                SET_FLAG(p->flags, ltype, r);
+        else {
+                assert(streq(lvalue, "Assign"));
                 p->assign = r;
-        else
-                assert_not_reached();
+        }
 
         TAKE_PTR(p);
         return 0;
index 569ca9e62b142cddccd0fde98cc1cbbffab5c5ad..c1ec6453ce068c8659ba3f722e6bb3de9fa2af55 100644 (file)
@@ -30,14 +30,12 @@ typedef struct Prefix {
         Network *network;
         ConfigSection *section;
 
-        struct in6_addr prefix;
+        uint8_t flags;
         uint8_t prefixlen;
+        struct in6_addr prefix;
         usec_t preferred_lifetime;
         usec_t valid_lifetime;
 
-        bool onlink;
-        bool address_auto_configuration;
-
         bool assign;
         uint32_t route_metric;
         Set *tokens;