From f5c38922666a4b5a2012edb67837238a48c9e4ba Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 26 Nov 2019 12:41:54 +0900 Subject: [PATCH] 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. --- man/systemd.network.xml | 19 +++++++++++++------ src/network/networkd-route.c | 16 +++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 8b401eeaf9..f06ce2eb79 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1263,9 +1263,12 @@ Scope= - The scope of the route, which can be global, - link or host. Defaults to - global. + The scope of the route, which can be global, site, + link, host, or nowhere. For IPv4 route, + defaults to host if Type= is local + or nat, and link if Type= is + broadcast, multicast, or anycast. + In other cases, defaults to global. @@ -1277,10 +1280,14 @@ - Table=num + Table= - The table identifier for the route (a number between 1 and 4294967295, or 0 to unset). - The table can be retrieved using ip route show table num. + The table identifier for the route. Takes default, + main, local or a number between 1 and 4294967295. + The table can be retrieved using ip route show table num. + If unset and Type= is local, broadcast, + anycast, or nat, then local is used. + In other cases, defaults to main. diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 85df5d9395..592de4e430 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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 &&