1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-21 02:50:18 +03:00

network: sd-radv - Allow to set the MTU option is used in Router RA

closes https://github.com/systemd/systemd/issues/33160
This commit is contained in:
Susant Sahani 2024-06-15 14:42:57 -04:00
parent 2a00e92598
commit f620d26d87
7 changed files with 53 additions and 0 deletions

View File

@ -4080,6 +4080,19 @@ ServerAddress=192.168.0.1/24</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MTUBytes=</varname></term>
<listitem>
<para>Specifies the size of the router advertisement MTU or one of the special
value <literal>auto</literal>. When suffixed with K, M, or G, the specified
size is parsed as Kilobytes, Megabytes, or Gigabytes, respectively, to the base of 1024.
When <literal>auto</literal>, is specified the MTU of the link is automatically taken as
router advertisement MTU. Defaults to<literal>auto</literal>.</para>
<xi:include href="version-info.xml" xpointer="v257"/>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UplinkInterface=</varname></term>
<listitem><para>Specifies the name or the index of the uplink interface, or one of the special

View File

@ -2448,6 +2448,9 @@ static int link_update_mtu(Link *link, sd_netlink_message *message) {
}
if (link->radv) {
if (link->have_router_mtu)
return 0;
r = sd_radv_set_mtu(link->radv, link->mtu);
if (r < 0)
return log_link_debug_errno(link, r, "Could not set MTU for Router Advertisement: %m");

View File

@ -172,6 +172,7 @@ typedef struct Link {
bool ndisc_configured:1;
sd_radv *radv;
bool have_router_mtu:1;
sd_dhcp6_client *dhcp6_client;
sd_dhcp6_lease *dhcp6_lease;

View File

@ -401,6 +401,7 @@ IPv6SendRA.Managed, config_parse_bool,
IPv6SendRA.OtherInformation, config_parse_bool, 0, offsetof(Network, router_other_information)
IPv6SendRA.RouterPreference, config_parse_router_preference, 0, 0
IPv6SendRA.HopLimit, config_parse_uint8, 0, offsetof(Network, router_hop_limit)
IPv6SendRA.MTUBytes, config_parse_router_mtu, AF_INET6, offsetof(Network, router_mtu)
IPv6SendRA.EmitDNS, config_parse_bool, 0, offsetof(Network, router_emit_dns)
IPv6SendRA.DNS, config_parse_radv_dns, 0, 0
IPv6SendRA.EmitDomains, config_parse_bool, 0, offsetof(Network, router_emit_domains)

View File

@ -249,6 +249,8 @@ struct Network {
usec_t router_reachable_usec;
usec_t router_retransmit_usec;
uint8_t router_hop_limit;
uint32_t router_mtu;
bool router_mtu_auto;
bool router_managed;
bool router_other_information;
bool router_emit_dns;

View File

@ -542,6 +542,15 @@ static int radv_configure(Link *link) {
if (r < 0)
return r;
if (link->network->router_mtu > 0 || link->network->router_mtu_auto) {
r = sd_radv_set_mtu(link->radv, link->network->router_mtu_auto ? link->mtu : link->network->router_mtu);
if (r < 0)
return r;
if (link->network->router_mtu > 0)
link->have_router_mtu = true;
}
r = sd_radv_set_preference(link->radv, link->network->router_preference);
if (r < 0)
return r;
@ -1625,3 +1634,26 @@ int config_parse_router_home_agent_lifetime(
*home_agent_lifetime_usec = usec;
return 0;
}
int config_parse_router_mtu(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Network *network = userdata;
assert(rvalue);
if (streq(rvalue, "auto"))
network->router_mtu_auto = true;
else
return config_parse_mtu(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata);
return 1;
}

View File

@ -76,6 +76,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation);
CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime);
CONFIG_PARSER_PROTOTYPE(config_parse_router_uint32_msec_usec);
CONFIG_PARSER_PROTOTYPE(config_parse_router_preference);
CONFIG_PARSER_PROTOTYPE(config_parse_router_mtu);
CONFIG_PARSER_PROTOTYPE(config_parse_prefix);
CONFIG_PARSER_PROTOTYPE(config_parse_prefix_boolean);
CONFIG_PARSER_PROTOTYPE(config_parse_prefix_lifetime);