mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 10:25:37 +03:00
Merge pull request #25164 from yuwata/network-route-table-0
network: fix handling of route table 0
This commit is contained in:
commit
60e9a39ac7
@ -2008,9 +2008,11 @@ allow my_server_t localnet_peer_t:peer recv;</programlisting>
|
||||
<varlistentry>
|
||||
<term><varname>RouteTable=<replaceable>num</replaceable></varname></term>
|
||||
<listitem>
|
||||
<para>The table identifier for DHCP routes (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>
|
||||
<para>The table identifier for DHCP routes. Takes one of predefined names
|
||||
<literal>default</literal>, <literal>main</literal>, and <literal>local</literal>, and names
|
||||
defined in <varname>RouteTable=</varname> in
|
||||
<citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
or a number between 1…4294967295.</para>
|
||||
|
||||
<para>When used in combination with <varname>VRF=</varname>, the VRF's routing table is
|
||||
used when this parameter is not specified.</para>
|
||||
@ -2502,10 +2504,14 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
|
||||
<varlistentry>
|
||||
<term><varname>RouteTable=<replaceable>num</replaceable></varname></term>
|
||||
<listitem>
|
||||
<para>The table identifier for the routes received in the Router Advertisement
|
||||
(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>
|
||||
<para>The table identifier for the routes received in the Router Advertisement. Takes one of
|
||||
predefined names <literal>default</literal>, <literal>main</literal>, and <literal>local</literal>,
|
||||
and names defined in <varname>RouteTable=</varname> in
|
||||
<citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
or a number between 1…4294967295.</para>
|
||||
|
||||
<para>When used in combination with <varname>VRF=</varname>, the VRF's routing table is
|
||||
used when this parameter is not specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "networkd-link.h"
|
||||
#include "networkd-manager.h"
|
||||
#include "networkd-network.h"
|
||||
#include "networkd-route-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-table.h"
|
||||
@ -529,7 +530,7 @@ int config_parse_dhcp_or_ra_route_table(
|
||||
assert(IN_SET(ltype, AF_INET, AF_INET6));
|
||||
assert(rvalue);
|
||||
|
||||
r = safe_atou32(rvalue, &rt);
|
||||
r = manager_get_route_table_from_string(network->manager, rvalue, &rt);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse RouteTable=%s, ignoring assignment: %m", rvalue);
|
||||
|
@ -417,8 +417,8 @@ int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **r
|
||||
assert(m);
|
||||
assert(ret);
|
||||
|
||||
if (table == 0)
|
||||
return -EINVAL;
|
||||
/* Unlike manager_get_route_table_from_string(), this accepts 0, as the kernel may create routes with
|
||||
* table 0. See issue #25089. */
|
||||
|
||||
s = route_table_to_string(table);
|
||||
if (!s)
|
||||
|
@ -2351,7 +2351,7 @@ int config_parse_route_table(
|
||||
r = manager_get_route_table_from_string(network->manager, rvalue, &n->table);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Could not parse route table number \"%s\", ignoring assignment: %m", rvalue);
|
||||
"Could not parse route table \"%s\", ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ int config_parse_routing_policy_rule_table(
|
||||
r = manager_get_route_table_from_string(network->manager, rvalue, &n->table);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Could not parse RPDB rule route table number \"%s\", ignoring assignment: %m", rvalue);
|
||||
"Could not parse RPDB rule route table \"%s\", ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2618,18 +2618,18 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
self.assertIn('anycast 149.10.123.2 proto static scope link', output)
|
||||
self.assertIn('broadcast 149.10.123.3 proto static scope link', output)
|
||||
|
||||
print('### ip route show type blackhole')
|
||||
output = check_output('ip route show type blackhole')
|
||||
print('### ip -4 route show type blackhole')
|
||||
output = check_output('ip -4 route show type blackhole')
|
||||
print(output)
|
||||
self.assertIn('blackhole 202.54.1.2 proto static', output)
|
||||
|
||||
print('### ip route show type unreachable')
|
||||
output = check_output('ip route show type unreachable')
|
||||
print('### ip -4 route show type unreachable')
|
||||
output = check_output('ip -4 route show type unreachable')
|
||||
print(output)
|
||||
self.assertIn('unreachable 202.54.1.3 proto static', output)
|
||||
|
||||
print('### ip route show type prohibit')
|
||||
output = check_output('ip route show type prohibit')
|
||||
print('### ip -4 route show type prohibit')
|
||||
output = check_output('ip -4 route show type prohibit')
|
||||
print(output)
|
||||
self.assertIn('prohibit 202.54.1.4 proto static', output)
|
||||
|
||||
@ -2680,18 +2680,18 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
self.wait_online(['dummy98:routable'])
|
||||
|
||||
# check all routes managed by Manager are removed
|
||||
print('### ip route show type blackhole')
|
||||
output = check_output('ip route show type blackhole')
|
||||
print('### ip -4 route show type blackhole')
|
||||
output = check_output('ip -4 route show type blackhole')
|
||||
print(output)
|
||||
self.assertEqual(output, '')
|
||||
|
||||
print('### ip route show type unreachable')
|
||||
output = check_output('ip route show type unreachable')
|
||||
print('### ip -4 route show type unreachable')
|
||||
output = check_output('ip -4 route show type unreachable')
|
||||
print(output)
|
||||
self.assertEqual(output, '')
|
||||
|
||||
print('### ip route show type prohibit')
|
||||
output = check_output('ip route show type prohibit')
|
||||
print('### ip -4 route show type prohibit')
|
||||
output = check_output('ip -4 route show type prohibit')
|
||||
print(output)
|
||||
self.assertEqual(output, '')
|
||||
|
||||
@ -2715,18 +2715,18 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
self.wait_online(['dummy98:routable'])
|
||||
|
||||
# check all routes managed by Manager are reconfigured
|
||||
print('### ip route show type blackhole')
|
||||
output = check_output('ip route show type blackhole')
|
||||
print('### ip -4 route show type blackhole')
|
||||
output = check_output('ip -4 route show type blackhole')
|
||||
print(output)
|
||||
self.assertIn('blackhole 202.54.1.2 proto static', output)
|
||||
|
||||
print('### ip route show type unreachable')
|
||||
output = check_output('ip route show type unreachable')
|
||||
print('### ip -4 route show type unreachable')
|
||||
output = check_output('ip -4 route show type unreachable')
|
||||
print(output)
|
||||
self.assertIn('unreachable 202.54.1.3 proto static', output)
|
||||
|
||||
print('### ip route show type prohibit')
|
||||
output = check_output('ip route show type prohibit')
|
||||
print('### ip -4 route show type prohibit')
|
||||
output = check_output('ip -4 route show type prohibit')
|
||||
print(output)
|
||||
self.assertIn('prohibit 202.54.1.4 proto static', output)
|
||||
|
||||
@ -2749,18 +2749,18 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
time.sleep(2)
|
||||
|
||||
# check all routes managed by Manager are removed
|
||||
print('### ip route show type blackhole')
|
||||
output = check_output('ip route show type blackhole')
|
||||
print('### ip -4 route show type blackhole')
|
||||
output = check_output('ip -4 route show type blackhole')
|
||||
print(output)
|
||||
self.assertEqual(output, '')
|
||||
|
||||
print('### ip route show type unreachable')
|
||||
output = check_output('ip route show type unreachable')
|
||||
print('### ip -4 route show type unreachable')
|
||||
output = check_output('ip -4 route show type unreachable')
|
||||
print(output)
|
||||
self.assertEqual(output, '')
|
||||
|
||||
print('### ip route show type prohibit')
|
||||
output = check_output('ip route show type prohibit')
|
||||
print('### ip -4 route show type prohibit')
|
||||
output = check_output('ip -4 route show type prohibit')
|
||||
print(output)
|
||||
self.assertEqual(output, '')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user