diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index c1618c0f94c..f768844c4e1 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -4229,6 +4229,19 @@ ServerAddress=192.168.0.1/24
+
+ MTUBytes=
+
+ Specifies the size of the router advertisement MTU or one of the special
+ value auto. When suffixed with K, M, or G, the specified
+ size is parsed as Kilobytes, Megabytes, or Gigabytes, respectively, to the base of 1024.
+ When auto, is specified the MTU of the link is automatically taken as
+ router advertisement MTU. Defaults toauto.
+
+
+
+
+
UplinkInterface=
Specifies the name or the index of the uplink interface, or one of the special
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 14cf7197bb6..2c078403cca 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2472,6 +2472,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");
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index c5806cea332..e344ebf506e 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -182,6 +182,7 @@ typedef struct Link {
bool ndisc_configured;
sd_radv *radv;
+ bool have_router_mtu:1;
sd_dhcp6_client *dhcp6_client;
sd_dhcp6_lease *dhcp6_lease;
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index bdbb3ad2c8a..00a6aa48ef1 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -412,6 +412,7 @@ IPv6SendRA.Managed, config_parse_bool,
IPv6SendRA.OtherInformation, config_parse_bool, 0, offsetof(Network, router_other_information)
IPv6SendRA.RouterPreference, config_parse_router_preference, 0, offsetof(Network, router_preference)
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)
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index cec5f98d5bb..c209c33453e 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -253,6 +253,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;
diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c
index 644051d844c..39703453e52 100644
--- a/src/network/networkd-radv.c
+++ b/src/network/networkd-radv.c
@@ -469,6 +469,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;
@@ -1597,3 +1606,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;
+}
diff --git a/src/network/networkd-radv.h b/src/network/networkd-radv.h
index 3f0a374632a..faaf151fff4 100644
--- a/src/network/networkd-radv.h
+++ b/src/network/networkd-radv.h
@@ -77,6 +77,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);