]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-client: do not trigger assertion when running on interface with small MTU 42123/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 13 Apr 2026 23:57:47 +0000 (08:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 16 May 2026 13:34:25 +0000 (22:34 +0900)
This also drops spurious default value. If mtu is unset, now the correct
default value is set in client_new_message() in dhcp-client-send.c.

src/libsystemd-network/sd-dhcp-client.c

index d16ffc0655255f83c29384fe4a4a5c26911ddd13..10161148a4d79d268d8e02c731b3c3475fab9c23 100644 (file)
@@ -487,13 +487,14 @@ int sd_dhcp_client_set_port(
 
 int sd_dhcp_client_set_mtu(sd_dhcp_client *client, uint32_t mtu) {
         assert_return(client, -EINVAL);
-        assert_return(mtu >= DHCP_MIN_PACKET_SIZE, -ERANGE);
 
         /* MTU may be changed by the acquired lease. Hence, we cannot require that the client is stopped here.
          * Please do not add assertion for !sd_dhcp_client_is_running(client) here. */
 
-        client->mtu = mtu;
+        if (mtu < IPV4_MIN_MTU)
+                return -ERANGE;
 
+        client->mtu = mtu;
         return 0;
 }
 
@@ -1441,7 +1442,6 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
                 .n_ref = 1,
                 .state = DHCP_STATE_STOPPED,
                 .ifindex = -1,
-                .mtu = DHCP_MIN_PACKET_SIZE,
                 .port = DHCP_PORT_CLIENT,
                 .server_port = DHCP_PORT_SERVER,
                 .anonymize = !!anonymize,