From 7db98bc938398b8465d1daab2a96c3a6272bb2c6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 28 Oct 2022 11:06:27 +0900 Subject: [PATCH] network: make RouteTable= also accept route table name --- man/systemd.network.xml | 20 +++++++++++++------- src/network/networkd-dhcp-common.c | 3 ++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index e35da7bd4c..ffed2ee066 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -2008,9 +2008,11 @@ allow my_server_t localnet_peer_t:peer recv; RouteTable=num - The table identifier for DHCP routes (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 DHCP routes. Takes one of predefined names + default, main, and local, and names + defined in RouteTable= in + networkd.conf5, + or a number between 1…4294967295. When used in combination with VRF=, the VRF's routing table is used when this parameter is not specified. @@ -2502,10 +2504,14 @@ Token=prefixstable:2002:da8:1:: RouteTable=num - 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 ip route show table num. - + The table identifier for the routes received in the Router Advertisement. Takes one of + predefined names default, main, and local, + and names defined in RouteTable= in + networkd.conf5, + or a number between 1…4294967295. + + When used in combination with VRF=, the VRF's routing table is + used when this parameter is not specified. diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c index 6526d3378f..7b0b2dea85 100644 --- a/src/network/networkd-dhcp-common.c +++ b/src/network/networkd-dhcp-common.c @@ -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);