network: also assume Table=local for ipv6 route if Type=local, broadcast, anycast or nat (#14148)

Also, if Type=multicast and scope is not set, then assume Scope=link.

Fixes #14122.
This commit is contained in:
Yu Watanabe 2019-11-26 12:41:54 +09:00 committed by GitHub
parent cfbb1c6def
commit f5c3892266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View File

@ -1263,9 +1263,12 @@
<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>
@ -1277,10 +1280,14 @@
</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>

View 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->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->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 &&