network: introduce Network::ipv6_accept_ra_route_table_set flag
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 Feb 2019 03:42:10 +0000 (12:42 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 15 Feb 2019 01:58:22 +0000 (10:58 +0900)
It will be used in later commit.

src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h

index 5d8aede..45343f4 100644 (file)
@@ -140,7 +140,7 @@ DHCP.UserClass,                         config_parse_dhcp_user_class,
 DHCP.DUIDType,                          config_parse_duid_type,                         0,                             offsetof(Network, duid)
 DHCP.DUIDRawData,                       config_parse_duid_rawdata,                      0,                             offsetof(Network, duid)
 DHCP.RouteMetric,                       config_parse_unsigned,                          0,                             offsetof(Network, dhcp_route_metric)
-DHCP.RouteTable,                        config_parse_dhcp_route_table,                  0,                             0
+DHCP.RouteTable,                        config_parse_section_route_table,               0,                             0
 DHCP.UseTimezone,                       config_parse_bool,                              0,                             offsetof(Network, dhcp_use_timezone)
 DHCP.IAID,                              config_parse_iaid,                              0,                             0
 DHCP.ListenPort,                        config_parse_uint16,                            0,                             offsetof(Network, dhcp_client_port)
@@ -148,7 +148,7 @@ DHCP.RapidCommit,                       config_parse_bool,
 DHCP.ForceDHCPv6PDOtherInformation,     config_parse_bool,                              0,                             offsetof(Network, dhcp6_force_pd_other_information)
 IPv6AcceptRA.UseDNS,                    config_parse_bool,                              0,                             offsetof(Network, ipv6_accept_ra_use_dns)
 IPv6AcceptRA.UseDomains,                config_parse_dhcp_use_domains,                  0,                             offsetof(Network, ipv6_accept_ra_use_domains)
-IPv6AcceptRA.RouteTable,                config_parse_uint32,                            0,                             offsetof(Network, ipv6_accept_ra_route_table)
+IPv6AcceptRA.RouteTable,                config_parse_section_route_table,               0,                             0
 DHCPServer.MaxLeaseTimeSec,             config_parse_sec,                               0,                             offsetof(Network, dhcp_server_max_lease_time_usec)
 DHCPServer.DefaultLeaseTimeSec,         config_parse_sec,                               0,                             offsetof(Network, dhcp_server_default_lease_time_usec)
 DHCPServer.EmitDNS,                     config_parse_bool,                              0,                             offsetof(Network, dhcp_server_emit_dns)
index 12344ec..097eb0a 100644 (file)
@@ -207,6 +207,7 @@ int network_load_one(Manager *manager, const char *filename) {
                 .allmulticast = -1,
                 .ipv6_accept_ra_use_dns = true,
                 .ipv6_accept_ra_route_table = RT_TABLE_MAIN,
+                .ipv6_accept_ra_route_table_set = false,
         };
 
         r = config_parse_many(filename, network_dirs, dropin_dirname,
@@ -1422,16 +1423,18 @@ int config_parse_dhcp_user_class(
         return 0;
 }
 
-int config_parse_dhcp_route_table(const char *unit,
-                                  const char *filename,
-                                  unsigned line,
-                                  const char *section,
-                                  unsigned section_line,
-                                  const char *lvalue,
-                                  int ltype,
-                                  const char *rvalue,
-                                  void *data,
-                                  void *userdata) {
+int config_parse_section_route_table(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
         Network *network = data;
         uint32_t rt;
         int r;
@@ -1444,12 +1447,17 @@ int config_parse_dhcp_route_table(const char *unit,
         r = safe_atou32(rvalue, &rt);
         if (r < 0) {
                 log_syntax(unit, LOG_ERR, filename, line, r,
-                           "Unable to read RouteTable, ignoring assignment: %s", rvalue);
+                           "Failed to parse RouteTable=%s, ignoring assignment: %m", rvalue);
                 return 0;
         }
 
-        network->dhcp_route_table = rt;
-        network->dhcp_route_table_set = true;
+        if (streq_ptr(section, "DHCP")) {
+                network->dhcp_route_table = rt;
+                network->dhcp_route_table_set = true;
+        } else { /* section is IPv6AcceptRA */
+                network->ipv6_accept_ra_route_table = rt;
+                network->ipv6_accept_ra_route_table_set = true;
+        }
 
         return 0;
 }
index f6e62cd..37c2b35 100644 (file)
@@ -213,6 +213,7 @@ struct Network {
         bool primary_slave;
         DHCPUseDomains ipv6_accept_ra_use_domains;
         uint32_t ipv6_accept_ra_route_table;
+        bool ipv6_accept_ra_route_table_set;
 
         union in_addr_union ipv6_token;
         IPv6PrivacyExtensions ipv6_privacy_extensions;
@@ -308,7 +309,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_ntp);
 CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_domains);
 CONFIG_PARSER_PROTOTYPE(config_parse_lldp_mode);
-CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_table);
+CONFIG_PARSER_PROTOTYPE(config_parse_section_route_table);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_class);
 CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
 CONFIG_PARSER_PROTOTYPE(config_parse_iaid);