mirror of
https://github.com/systemd/systemd.git
synced 2025-02-03 17:47:28 +03:00
network: make Route.Type= support local, broadcast, anycast, multicast, nat, and xresolve
Closes #12975.
This commit is contained in:
parent
7a22312d68
commit
94d6e29963
@ -1232,7 +1232,11 @@
|
||||
<varlistentry>
|
||||
<term><varname>Type=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the type for the route. If <literal>unicast</literal>, a regular route is defined, i.e. a
|
||||
<para>Specifies the type for the route. Takes one of <literal>unicast</literal>,
|
||||
<literal>local</literal>, <literal>broadcast</literal>, <literal>anycast</literal>,
|
||||
<literal>multicast</literal>, <literal>blackhole</literal>, <literal>unreachable</literal>,
|
||||
<literal>prohibit</literal>, <literal>throw</literal>, <literal>nat</literal>, and
|
||||
<literal>xresolve</literal>. If <literal>unicast</literal>, a regular route is defined, i.e. a
|
||||
route indicating the path to take to a destination network address. If <literal>blackhole</literal>, packets
|
||||
to the defined route are discarded silently. If <literal>unreachable</literal>, packets to the defined route
|
||||
are discarded and the ICMP message "Host Unreachable" is generated. If <literal>prohibit</literal>, packets
|
||||
|
@ -719,6 +719,8 @@ int network_add_ipv4ll_route(Network *network) {
|
||||
n->family = AF_INET;
|
||||
n->dst_prefixlen = 16;
|
||||
n->scope = RT_SCOPE_LINK;
|
||||
n->scope_set = true;
|
||||
n->table_set = true;
|
||||
n->priority = IPV4LL_ROUTE_METRIC;
|
||||
n->protocol = RTPROT_STATIC;
|
||||
|
||||
@ -752,10 +754,16 @@ int network_add_default_route_on_device(Network *network) {
|
||||
|
||||
static const char * const route_type_table[__RTN_MAX] = {
|
||||
[RTN_UNICAST] = "unicast",
|
||||
[RTN_LOCAL] = "local",
|
||||
[RTN_BROADCAST] = "broadcast",
|
||||
[RTN_ANYCAST] = "anycast",
|
||||
[RTN_MULTICAST] = "multicast",
|
||||
[RTN_BLACKHOLE] = "blackhole",
|
||||
[RTN_UNREACHABLE] = "unreachable",
|
||||
[RTN_PROHIBIT] = "prohibit",
|
||||
[RTN_THROW] = "throw",
|
||||
[RTN_NAT] = "nat",
|
||||
[RTN_XRESOLVE] = "xresolve",
|
||||
};
|
||||
|
||||
assert_cc(__RTN_MAX <= UCHAR_MAX);
|
||||
@ -971,6 +979,7 @@ int config_parse_route_scope(
|
||||
return 0;
|
||||
}
|
||||
|
||||
n->scope_set = true;
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
@ -1008,6 +1017,7 @@ int config_parse_route_table(
|
||||
return 0;
|
||||
}
|
||||
|
||||
n->table_set = true;
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
@ -1371,6 +1381,18 @@ 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 (network->n_static_addresses == 0 &&
|
||||
in_addr_is_null(route->family, &route->gw) == 0 &&
|
||||
route->gateway_onlink < 0) {
|
||||
|
@ -23,11 +23,13 @@ struct Route {
|
||||
unsigned char dst_prefixlen;
|
||||
unsigned char src_prefixlen;
|
||||
unsigned char scope;
|
||||
bool scope_set;
|
||||
unsigned char protocol; /* RTPROT_* */
|
||||
unsigned char type; /* RTN_* */
|
||||
unsigned char tos;
|
||||
uint32_t priority; /* note that ip(8) calls this 'metric' */
|
||||
uint32_t table;
|
||||
bool table_set;
|
||||
uint32_t mtu;
|
||||
uint32_t initcwnd;
|
||||
uint32_t initrwnd;
|
||||
|
Loading…
x
Reference in New Issue
Block a user