diff options
author | Susant Sahani <susant@redhat.com> | 2018-06-14 22:49:25 +0530 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-06-20 08:09:30 +0200 |
commit | 44b598a1c9d11c23420a5ef45ff11bcb0ed195eb (patch) | |
tree | 62c34dbe01db251b0ac8a6eab46c06eb3daec46c /src/network | |
parent | aac5ece3b28ce28c0f5bcbd6a52c135c68a7794c (diff) | |
download | systemd-44b598a1c9d11c23420a5ef45ff11bcb0ed195eb.tar.gz |
networkd: Unify set MTU
Now the setting MTU is embedded into the link_up message which makes it
incapable of setting MTU if link is up. MTU can be set while Link is up.
Closes #9254
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-link.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 562b4759ec..890784ea2e 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1307,6 +1307,24 @@ int link_set_mtu(Link *link, uint32_t mtu) { if (r < 0) return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m"); + /* If IPv6 not configured (no static IPv6 address and IPv6LL autoconfiguration is disabled) + for this interface, or if it is a bridge slave, then disable IPv6 else enable it. */ + (void) link_enable_ipv6(link); + + /* IPv6 protocol requires a minimum MTU of IPV6_MTU_MIN(1280) bytes + on the interface. Bump up MTU bytes to IPV6_MTU_MIN. */ + if (link_ipv6_enabled(link) && link->network->mtu < IPV6_MIN_MTU) { + + log_link_warning(link, "Bumping MTU to " STRINGIFY(IPV6_MIN_MTU) ", as " + "IPv6 is requested and requires a minimum MTU of " STRINGIFY(IPV6_MIN_MTU) " bytes: %m"); + + link->network->mtu = IPV6_MIN_MTU; + } + + r = sd_netlink_message_append_u32(req, IFLA_MTU, link->network->mtu); + if (r < 0) + return log_link_error_errno(link, r, "Could not set MTU: %m"); + r = sd_netlink_message_append_u32(req, IFLA_MTU, mtu); if (r < 0) return log_link_error_errno(link, r, "Could not append MTU: %m"); @@ -1774,26 +1792,6 @@ int link_up(Link *link) { return log_link_error_errno(link, r, "Could not set MAC address: %m"); } - /* If IPv6 not configured (no static IPv6 address and IPv6LL autoconfiguration is disabled) - for this interface, or if it is a bridge slave, then disable IPv6 else enable it. */ - (void) link_enable_ipv6(link); - - if (link->network->mtu != 0) { - /* IPv6 protocol requires a minimum MTU of IPV6_MTU_MIN(1280) bytes - on the interface. Bump up MTU bytes to IPV6_MTU_MIN. */ - if (link_ipv6_enabled(link) && link->network->mtu < IPV6_MIN_MTU) { - - log_link_warning(link, "Bumping MTU to " STRINGIFY(IPV6_MIN_MTU) ", as " - "IPv6 is requested and requires a minimum MTU of " STRINGIFY(IPV6_MIN_MTU) " bytes: %m"); - - link->network->mtu = IPV6_MIN_MTU; - } - - r = sd_netlink_message_append_u32(req, IFLA_MTU, link->network->mtu); - if (r < 0) - return log_link_error_errno(link, r, "Could not set MTU: %m"); - } - r = sd_netlink_message_open_container(req, IFLA_AF_SPEC); if (r < 0) return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m"); @@ -2867,6 +2865,12 @@ static int link_configure(Link *link) { return r; } + if (link->network->mtu > 0) { + r = link_set_mtu(link, link->network->mtu); + if (r < 0) + return r; + } + if (link_has_carrier(link) || link->network->configure_without_carrier) { r = link_acquire_conf(link); if (r < 0) |