]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce AddPrefixRoute= and deprecate PrefixRoute=
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 7 Dec 2019 15:32:36 +0000 (00:32 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 18 Dec 2019 15:32:31 +0000 (16:32 +0100)
PrefixRoute= was added by e63be0847c39bfdca45c25c505922814374581a7,
but unfortunately, the meaning of PrefixRoute= is inverted; when true
IFA_F_NOPREFIXROUTE flag is added. This introduces AddPrefixRoute=
setting.

man/systemd.network.xml
src/network/networkd-address.c
src/network/networkd-dhcp4.c
src/network/networkd-network-gperf.gperf
test/fuzz/fuzz-network-parser/directives.network

index 958511176123d3dc1e55ab22185ad6a292560007..24471adaa9b5dac21f322360b90d52d3f3d6e66c 100644 (file)
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><varname>PrefixRoute=</varname></term>
+          <term><varname>AddPrefixRoute=</varname></term>
           <listitem>
-            <para>Takes a boolean. When adding or modifying an IPv6 address, the userspace
-            application needs a way to suppress adding a prefix route. This is for example relevant
-            together with IFA_F_MANAGERTEMPADDR, where userspace creates autoconf generated addresses,
-            but depending on on-link, no route for the prefix should be added. Defaults to false.</para>
+            <para>Takes a boolean. When true, the prefix route for the address is automatically added.
+            Defaults to true.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
index 886a8c0665e5717b605495eb6c0ff21bb3f928a3..169d0e4829e0612e06c86869f57d7452519784f0 100644 (file)
@@ -33,6 +33,7 @@ int address_new(Address **ret) {
                 .cinfo.ifa_prefered = CACHE_INFO_INFINITY_LIFE_TIME,
                 .cinfo.ifa_valid = CACHE_INFO_INFINITY_LIFE_TIME,
                 .duplicate_address_detection = ADDRESS_FAMILY_IPV6,
+                .prefix_route = true,
         };
 
         *ret = TAKE_PTR(address);
@@ -596,7 +597,7 @@ int address_configure(
         if (address->manage_temporary_address)
                 address->flags |= IFA_F_MANAGETEMPADDR;
 
-        if (address->prefix_route)
+        if (!address->prefix_route)
                 address->flags |= IFA_F_NOPREFIXROUTE;
 
         if (address->autojoin)
@@ -1001,6 +1002,8 @@ int config_parse_address_flags(const char *unit,
         else if (streq(lvalue, "ManageTemporaryAddress"))
                 n->manage_temporary_address = r;
         else if (streq(lvalue, "PrefixRoute"))
+                n->prefix_route = !r;
+        else if (streq(lvalue, "AddPrefixRoute"))
                 n->prefix_route = r;
         else if (streq(lvalue, "AutoJoin"))
                 n->autojoin = r;
index d430115f561f16647fc9497d4da0d5bb3ef91b0a..0694ffc939f12c0f8c85b7f8c13156812d2ccbed 100644 (file)
@@ -111,10 +111,10 @@ static int route_scope_from_address(const Route *route, const struct in_addr *se
                 return RT_SCOPE_UNIVERSE;
 }
 
-static bool link_noprefixroute(Link *link) {
-        return link->network->dhcp_route_table_set &&
-                link->network->dhcp_route_table != RT_TABLE_MAIN &&
-                !link->manager->dhcp4_prefix_root_cannot_set_table;
+static bool link_prefixroute(Link *link) {
+        return !link->network->dhcp_route_table_set ||
+                link->network->dhcp_route_table == RT_TABLE_MAIN ||
+                link->manager->dhcp4_prefix_root_cannot_set_table;
 }
 
 static int dhcp_route_configure(Route **route, Link *link) {
@@ -254,7 +254,7 @@ static int link_set_dhcp_routes(Link *link) {
         if (r < 0)
                 return log_link_warning_errno(link, r, "DHCP error: could not get address: %m");
 
-        if (link_noprefixroute(link)) {
+        if (!link_prefixroute(link)) {
                 _cleanup_(route_freep) Route *prefix_route = NULL;
 
                 r = dhcp_prefix_route_from_lease(link->dhcp_lease, table, &address, &prefix_route);
@@ -516,7 +516,7 @@ static int dhcp_remove_dns_routes(Link *link, sd_dhcp_lease *lease, const struct
                 (void) route_remove(route, link, NULL);
         }
 
-        if (link_noprefixroute(link)) {
+        if (!link_prefixroute(link)) {
                 _cleanup_(route_freep) Route *prefix_route = NULL;
 
                 r = dhcp_prefix_route_from_lease(lease, table, address, &prefix_route);
@@ -719,7 +719,7 @@ static int dhcp4_update_address(Link *link,
         addr->cinfo.ifa_valid = lifetime;
         addr->prefixlen = prefixlen;
         addr->broadcast.s_addr = address->s_addr | ~netmask->s_addr;
-        addr->prefix_route = link_noprefixroute(link);
+        addr->prefix_route = link_prefixroute(link);
 
         /* allow reusing an existing address and simply update its lifetime
          * in case it already exists */
index b06d32ec6d3ee2cfcf7b12e6ae22afd5dca1bc16..29a05b2f3019f37c6233905de2c68dc4379ea10c 100644 (file)
@@ -106,7 +106,8 @@ Address.Label,                          config_parse_label,
 Address.PreferredLifetime,              config_parse_lifetime,                           0,                             0
 Address.HomeAddress,                    config_parse_address_flags,                      0,                             0
 Address.ManageTemporaryAddress,         config_parse_address_flags,                      0,                             0
-Address.PrefixRoute,                    config_parse_address_flags,                      0,                             0
+Address.PrefixRoute,                    config_parse_address_flags,                      0,                             0 /* deprecated */
+Address.AddPrefixRoute,                 config_parse_address_flags,                      0,                             0
 Address.AutoJoin,                       config_parse_address_flags,                      0,                             0
 Address.DuplicateAddressDetection,      config_parse_duplicate_address_detection,        0,                             0
 Address.Scope,                          config_parse_address_scope,                      0,                             0
index 4513bbb529e06a5e6cba3744bd3f8613fa790f34..0c76bd5f910ed3d6ac83e784dc3d681cbf5a6e85 100644 (file)
@@ -202,6 +202,7 @@ Address=
 Scope=
 HomeAddress=
 PrefixRoute=
+AddPrefixRoute=
 ManageTemporaryAddress=
 Broadcast=
 Peer=