]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: also assume Table=local for ipv6 route if Type=local, broadcast, anycast...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Nov 2019 03:41:54 +0000 (12:41 +0900)
committerGitHub <noreply@github.com>
Tue, 26 Nov 2019 03:41:54 +0000 (12:41 +0900)
Also, if Type=multicast and scope is not set, then assume Scope=link.

Fixes #14122.

man/systemd.network.xml
src/network/networkd-route.c

index 8b401eeaf9454a5cf078d37fbdcbbf551444ef91..f06ce2eb7924259bce29b2fd05a3ccb155d99a82 100644 (file)
         <varlistentry>
           <term><varname>Scope=</varname></term>
           <listitem>
-            <para>The scope of the route, which can be <literal>global</literal>,
-            <literal>link</literal> or <literal>host</literal>. Defaults to
-            <literal>global</literal>.</para>
+            <para>The scope of the route, which can be <literal>global</literal>, <literal>site</literal>,
+            <literal>link</literal>, <literal>host</literal>, or <literal>nowhere</literal>. For IPv4 route,
+            defaults to <literal>host</literal> if <varname>Type=</varname> is <literal>local</literal>
+            or <literal>nat</literal>, and <literal>link</literal> if <varname>Type=</varname> is
+            <literal>broadcast</literal>, <literal>multicast</literal>, or <literal>anycast</literal>.
+            In other cases, defaults to <literal>global</literal>.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><varname>Table=<replaceable>num</replaceable></varname></term>
+          <term><varname>Table=</varname></term>
           <listitem>
-          <para>The table identifier for the route (a number between 1 and 4294967295, or 0 to unset).
-          The table can be retrieved using <command>ip route show table <replaceable>num</replaceable></command>.
+            <para>The table identifier for the route. Takes <literal>default</literal>,
+            <literal>main</literal>, <literal>local</literal> or a number between 1 and 4294967295.
+            The table can be retrieved using <command>ip route show table <replaceable>num</replaceable></command>.
+            If unset and <varname>Type=</varname> is <literal>local</literal>, <literal>broadcast</literal>,
+            <literal>anycast</literal>, or <literal>nat</literal>, then <literal>local</literal> is used.
+            In other cases, defaults to <literal>main</literal>.
           </para>
           </listitem>
         </varlistentry>
index 85df5d9395f4e2d56fa8400fe944f237a48c5ed7..592de4e430ac03b17149a542827480f075f71988 100644 (file)
@@ -1494,16 +1494,14 @@ int route_section_verify(Route *route, Network *network) {
                                          route->section->filename, route->section->line);
         }
 
-        if (route->family != AF_INET6) {
-                if (!route->table_set && IN_SET(route->type, RTN_LOCAL, RTN_BROADCAST, RTN_ANYCAST, RTN_NAT))
-                        route->table = RT_TABLE_LOCAL;
-
-                if (!route->scope_set) {
-                        if (IN_SET(route->type, RTN_LOCAL, RTN_NAT))
-                                route->scope = RT_SCOPE_HOST;
-                        else if (IN_SET(route->type, RTN_BROADCAST, RTN_ANYCAST))
-                                route->scope = RT_SCOPE_LINK;
-                }
+        if (!route->table_set && IN_SET(route->type, RTN_LOCAL, RTN_BROADCAST, RTN_ANYCAST, RTN_NAT))
+                route->table = RT_TABLE_LOCAL;
+
+        if (!route->scope_set && route->family != AF_INET6) {
+                if (IN_SET(route->type, RTN_LOCAL, RTN_NAT))
+                        route->scope = RT_SCOPE_HOST;
+                else if (IN_SET(route->type, RTN_BROADCAST, RTN_ANYCAST, RTN_MULTICAST))
+                        route->scope = RT_SCOPE_LINK;
         }
 
         if (network->n_static_addresses == 0 &&