mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
network: ndisc: introduce UseGateway= and UseRoutePrefix= settings
Closes #21263.
This commit is contained in:
parent
ad0b2df635
commit
610c0db126
@ -2295,6 +2295,22 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>UseGateway=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>When true (the default), the router address will be configured as the default gateway.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>UseRoutePrefix=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>When true (the default), the routes corresponding to the route prefixes received in
|
||||||
|
the Router Advertisement will be configured.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>UseAutonomousPrefix=</varname></term>
|
<term><varname>UseAutonomousPrefix=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -290,7 +290,6 @@ static int ndisc_request_address(Address *in, Link *link, sd_ndisc_router *rt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
||||||
_cleanup_(route_freep) Route *route = NULL;
|
|
||||||
usec_t lifetime_usec, timestamp_usec;
|
usec_t lifetime_usec, timestamp_usec;
|
||||||
struct in6_addr gateway;
|
struct in6_addr gateway;
|
||||||
uint16_t lifetime_sec;
|
uint16_t lifetime_sec;
|
||||||
@ -299,8 +298,13 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(link);
|
assert(link);
|
||||||
|
assert(link->network);
|
||||||
assert(rt);
|
assert(rt);
|
||||||
|
|
||||||
|
if (!link->network->ipv6_accept_ra_use_gateway &&
|
||||||
|
hashmap_isempty(link->network->routes_by_section))
|
||||||
|
return 0;
|
||||||
|
|
||||||
r = sd_ndisc_router_get_lifetime(rt, &lifetime_sec);
|
r = sd_ndisc_router_get_lifetime(rt, &lifetime_sec);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_link_error_errno(link, r, "Failed to get gateway lifetime from RA: %m");
|
return log_link_error_errno(link, r, "Failed to get gateway lifetime from RA: %m");
|
||||||
@ -339,23 +343,29 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
|||||||
return log_link_error_errno(link, r, "Failed to get default router MTU from RA: %m");
|
return log_link_error_errno(link, r, "Failed to get default router MTU from RA: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
r = route_new(&route);
|
if (link->network->ipv6_accept_ra_use_gateway) {
|
||||||
if (r < 0)
|
_cleanup_(route_freep) Route *route = NULL;
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
route->family = AF_INET6;
|
r = route_new(&route);
|
||||||
route->pref = preference;
|
if (r < 0)
|
||||||
route->gw_family = AF_INET6;
|
return log_oom();
|
||||||
route->gw.in6 = gateway;
|
|
||||||
route->lifetime_usec = lifetime_usec;
|
|
||||||
route->mtu = mtu;
|
|
||||||
|
|
||||||
r = ndisc_request_route(TAKE_PTR(route), link, rt);
|
route->family = AF_INET6;
|
||||||
if (r < 0)
|
route->pref = preference;
|
||||||
return log_link_error_errno(link, r, "Could not request default route: %m");
|
route->gw_family = AF_INET6;
|
||||||
|
route->gw.in6 = gateway;
|
||||||
|
route->lifetime_usec = lifetime_usec;
|
||||||
|
route->mtu = mtu;
|
||||||
|
|
||||||
|
r = ndisc_request_route(TAKE_PTR(route), link, rt);
|
||||||
|
if (r < 0)
|
||||||
|
return log_link_error_errno(link, r, "Could not request default route: %m");
|
||||||
|
}
|
||||||
|
|
||||||
Route *route_gw;
|
Route *route_gw;
|
||||||
HASHMAP_FOREACH(route_gw, link->network->routes_by_section) {
|
HASHMAP_FOREACH(route_gw, link->network->routes_by_section) {
|
||||||
|
_cleanup_(route_freep) Route *route = NULL;
|
||||||
|
|
||||||
if (!route_gw->gateway_from_dhcp_or_ra)
|
if (!route_gw->gateway_from_dhcp_or_ra)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -584,6 +594,9 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
|
|||||||
|
|
||||||
assert(link);
|
assert(link);
|
||||||
|
|
||||||
|
if (!link->network->ipv6_accept_ra_use_route_prefix)
|
||||||
|
return 0;
|
||||||
|
|
||||||
r = sd_ndisc_router_route_get_lifetime(rt, &lifetime_sec);
|
r = sd_ndisc_router_route_get_lifetime(rt, &lifetime_sec);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_link_error_errno(link, r, "Failed to get route lifetime from RA: %m");
|
return log_link_error_errno(link, r, "Failed to get route lifetime from RA: %m");
|
||||||
|
@ -255,6 +255,8 @@ DHCPv6.IAID, config_parse_iaid,
|
|||||||
DHCPv6.DUIDType, config_parse_duid_type, 0, offsetof(Network, dhcp6_duid)
|
DHCPv6.DUIDType, config_parse_duid_type, 0, offsetof(Network, dhcp6_duid)
|
||||||
DHCPv6.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, dhcp6_duid)
|
DHCPv6.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, dhcp6_duid)
|
||||||
DHCPv6.RouteTable, config_parse_dhcp_or_ra_route_table, (RTPROT_DHCP<<16) | AF_INET6, 0
|
DHCPv6.RouteTable, config_parse_dhcp_or_ra_route_table, (RTPROT_DHCP<<16) | AF_INET6, 0
|
||||||
|
IPv6AcceptRA.UseGateway, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_gateway)
|
||||||
|
IPv6AcceptRA.UseRoutePrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_route_prefix)
|
||||||
IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix)
|
IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix)
|
||||||
IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix)
|
IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix)
|
||||||
IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns)
|
IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns)
|
||||||
|
@ -464,6 +464,8 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
|||||||
|
|
||||||
.ipv6_accept_ra = -1,
|
.ipv6_accept_ra = -1,
|
||||||
.ipv6_accept_ra_use_dns = true,
|
.ipv6_accept_ra_use_dns = true,
|
||||||
|
.ipv6_accept_ra_use_gateway = true,
|
||||||
|
.ipv6_accept_ra_use_route_prefix = true,
|
||||||
.ipv6_accept_ra_use_autonomous_prefix = true,
|
.ipv6_accept_ra_use_autonomous_prefix = true,
|
||||||
.ipv6_accept_ra_use_onlink_prefix = true,
|
.ipv6_accept_ra_use_onlink_prefix = true,
|
||||||
.ipv6_accept_ra_use_mtu = true,
|
.ipv6_accept_ra_use_mtu = true,
|
||||||
|
@ -301,6 +301,8 @@ struct Network {
|
|||||||
/* IPv6 accept RA */
|
/* IPv6 accept RA */
|
||||||
int ipv6_accept_ra;
|
int ipv6_accept_ra;
|
||||||
bool ipv6_accept_ra_use_dns;
|
bool ipv6_accept_ra_use_dns;
|
||||||
|
bool ipv6_accept_ra_use_gateway;
|
||||||
|
bool ipv6_accept_ra_use_route_prefix;
|
||||||
bool ipv6_accept_ra_use_autonomous_prefix;
|
bool ipv6_accept_ra_use_autonomous_prefix;
|
||||||
bool ipv6_accept_ra_use_onlink_prefix;
|
bool ipv6_accept_ra_use_onlink_prefix;
|
||||||
bool ipv6_accept_ra_use_mtu;
|
bool ipv6_accept_ra_use_mtu;
|
||||||
|
@ -352,6 +352,8 @@ RouteTable=
|
|||||||
RouteMetric=
|
RouteMetric=
|
||||||
UseDNS=
|
UseDNS=
|
||||||
DHCPv6Client=
|
DHCPv6Client=
|
||||||
|
UseGateway=
|
||||||
|
UseRoutePrefix=
|
||||||
UseAutonomousPrefix=
|
UseAutonomousPrefix=
|
||||||
UseOnLinkPrefix=
|
UseOnLinkPrefix=
|
||||||
RouterAllowList=
|
RouterAllowList=
|
||||||
|
Loading…
Reference in New Issue
Block a user