summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-08-01 15:42:08 +0200
committerTom Gundersen <teg@jklm.no>2014-08-01 16:34:50 +0200
commitafe7fd56f5b5b81294dcb794214f97fc5e39dfea (patch)
treecf575e778b793be3999ab51b918f43921df81473 /src
parent324f818781a250b60f2fcfa74ff1c9101d2d1315 (diff)
networkd: track the MTU of each link
And inform the DHCPv4 clients about it.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c27
-rw-r--r--src/network/networkd.h1
2 files changed, 24 insertions, 4 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index ec1a97a7c9..172be64a7e 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1835,6 +1835,12 @@ static int link_configure(Link *link) {
if (r < 0)
return r;
+ if (link->mtu) {
+ r = sd_dhcp_client_set_mtu(link->dhcp_client, link->mtu);
+ if (r < 0)
+ return r;
+ }
+
if (link->network->dhcp_mtu) {
r = sd_dhcp_client_set_request_option(link->dhcp_client, DHCP_OPTION_INTERFACE_MTU);
if (r < 0)
@@ -2174,6 +2180,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
int link_update(Link *link, sd_rtnl_message *m) {
struct ether_addr mac;
const char *ifname;
+ uint32_t mtu;
int r;
assert(link);
@@ -2196,11 +2203,23 @@ int link_update(Link *link, sd_rtnl_message *m) {
return -ENOMEM;
}
- if (!link->original_mtu) {
- r = sd_rtnl_message_read_u16(m, IFLA_MTU, &link->original_mtu);
- if (r >= 0)
+ r = sd_rtnl_message_read_u32(m, IFLA_MTU, &mtu);
+ if (r >= 0 && mtu > 0) {
+ link->mtu = mtu;
+ if (!link->original_mtu) {
+ link->original_mtu = mtu;
log_debug_link(link, "saved original MTU: %"
- PRIu16, link->original_mtu);
+ PRIu32, link->original_mtu);
+ }
+
+ if (link->dhcp_client) {
+ r = sd_dhcp_client_set_mtu(link->dhcp_client, link->mtu);
+ if (r < 0) {
+ log_warning_link(link, "Could not update MTU in DHCP client: %s",
+ strerror(-r));
+ return r;
+ }
+ }
}
/* The kernel may broadcast NEWLINK messages without the MAC address
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 766297cffa..5d7a08be0c 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -174,6 +174,7 @@ struct Link {
char *ifname;
char *state_file;
struct ether_addr mac;
+ uint32_t mtu;
struct udev_device *udev_device;
unsigned flags;