]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: shorten code a bit 22899/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Mar 2022 16:04:26 +0000 (01:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 31 Mar 2022 00:29:42 +0000 (09:29 +0900)
Currently, there exist only two MTU sources, static and DHCPv4, and they
are exclusive. Hence, it is not necessary to check the existence of the
MTU option in the acquired DHCP lease. Let's unconditionally reset the
MTU. Note that, if the current and original MTU are equivalent, then
link_request_to_set_mtu() handles that gracefully.

src/network/networkd-dhcp4.c

index 6bfcf67dd953181da720d95710c9930b7cf77620..d3fd2571e0db29c70f950817a1ea301c7d43ce7c 100644 (file)
@@ -735,7 +735,6 @@ static int dhcp4_request_routes(Link *link) {
 }
 
 static int dhcp_reset_mtu(Link *link) {
-        uint16_t mtu;
         int r;
 
         assert(link);
@@ -743,18 +742,9 @@ static int dhcp_reset_mtu(Link *link) {
         if (!link->network->dhcp_use_mtu)
                 return 0;
 
-        r = sd_dhcp_lease_get_mtu(link->dhcp_lease, &mtu);
-        if (r == -ENODATA)
-                return 0;
-        if (r < 0)
-                return log_link_error_errno(link, r, "DHCP error: failed to get MTU from lease: %m");
-
-        if (link->original_mtu == mtu)
-                return 0;
-
         r = link_request_to_set_mtu(link, link->original_mtu);
         if (r < 0)
-                return log_link_error_errno(link, r, "DHCP error: could not reset MTU: %m");
+                return log_link_error_errno(link, r, "DHCP error: Could not queue request to reset MTU: %m");
 
         return 0;
 }