From 55710d3d7ce548c36a337482511cad6bb331572a Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Mon, 16 Dec 2024 10:03:51 -0500 Subject: [PATCH] n-dhcp4: send request directly to avoid unnecessary retransmission timeout Using `n_dhcp4_c_connection_start_request()` will cause staying in `connection->request`, as a result, it will cause the resending of DHCPRELEASE and DHCPDECLINE message, thus, use `n_dhcp4_c_connection_send_request()` directly instead to avoid unnecessary retransmission timeout, as suggested by https://github.com/nettools/n-dhcp4/pull/44/commits/f030927a54b2292f02ab519485997e702749aa54#r1531834009. --- src/n-dhcp4/src/n-dhcp4-c-connection.c | 6 +++--- src/n-dhcp4/src/n-dhcp4-c-probe.c | 4 ++-- src/n-dhcp4/src/n-dhcp4-private.h | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/n-dhcp4/src/n-dhcp4-c-connection.c b/src/n-dhcp4/src/n-dhcp4-c-connection.c index 7024b71ac..e76ea1659 100644 --- a/src/n-dhcp4/src/n-dhcp4-c-connection.c +++ b/src/n-dhcp4/src/n-dhcp4-c-connection.c @@ -1010,9 +1010,9 @@ static const char *message_type_to_str(uint8_t type) { } } -static int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection, - NDhcp4Outgoing *request, - uint64_t timestamp) { +int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection, + NDhcp4Outgoing *request, + uint64_t timestamp) { char server_addr[INET_ADDRSTRLEN]; char client_addr[INET_ADDRSTRLEN]; char error_msg[128]; diff --git a/src/n-dhcp4/src/n-dhcp4-c-probe.c b/src/n-dhcp4/src/n-dhcp4-c-probe.c index c37f1e207..7a6def340 100644 --- a/src/n-dhcp4/src/n-dhcp4-c-probe.c +++ b/src/n-dhcp4/src/n-dhcp4-c-probe.c @@ -1137,7 +1137,7 @@ int n_dhcp4_client_probe_transition_decline(NDhcp4ClientProbe *probe, NDhcp4Inco if (r) return r; - r = n_dhcp4_c_connection_start_request(&probe->connection, request, ns_now); + r = n_dhcp4_c_connection_send_request(&probe->connection, request, ns_now); if (r) return r; else @@ -1340,7 +1340,7 @@ int n_dhcp4_client_probe_release(NDhcp4ClientProbe *probe) { if (r) return r; - r = n_dhcp4_c_connection_start_request(&probe->connection, request_out, 0); + r = n_dhcp4_c_connection_send_request(&probe->connection, request_out, 0); if (r) return r; diff --git a/src/n-dhcp4/src/n-dhcp4-private.h b/src/n-dhcp4/src/n-dhcp4-private.h index 40404001a..dbfe9b4ad 100644 --- a/src/n-dhcp4/src/n-dhcp4-private.h +++ b/src/n-dhcp4/src/n-dhcp4-private.h @@ -642,6 +642,9 @@ int n_dhcp4_c_connection_release_new(NDhcp4CConnection *connection, int n_dhcp4_c_connection_start_request(NDhcp4CConnection *connection, NDhcp4Outgoing *request, uint64_t timestamp); +int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection, + NDhcp4Outgoing *request, + uint64_t timestamp); int n_dhcp4_c_connection_dispatch_timer(NDhcp4CConnection *connection, uint64_t timestamp); int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection,