diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-02-24 09:55:13 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-02-24 14:58:33 +0100 |
commit | 5a7b83ea0a2eb3cb0bb39c8219490c704024b5f5 (patch) | |
tree | a8c57ed064f5ac756ea189633734ad9a557677e1 /shared | |
parent | 910267cf5f0f163a038ec983bec237c8a8cb1abf (diff) | |
download | NetworkManager-5a7b83ea0a2eb3cb0bb39c8219490c704024b5f5.tar.gz |
n-dhcp4: keep trying after a failure in send()
Currently if an error is encountered during a send() of a message, the
client fails and there is no possibility of recover, since no timers
are armed after a failed event dispatch. An easy way to reproduce a
failure is to add a firewall rule like:
iptables -A OUTPUT -p udp --dport 67 -j REJECT
which makes the send() fail with EPERM during the renew. In such case,
the client should continue (failing) until it reaches the rebind phase
at T2, when it will be able to renew the lease using the packet
socket.
In general, a failure to send a packet should not cause the failure of
the client.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/419
https://bugzilla.redhat.com/show_bug.cgi?id=1806516
Diffstat (limited to 'shared')
-rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-c-connection.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c index d4354467d1..a5c8ea66fe 100644 --- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c +++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c @@ -1006,6 +1006,7 @@ static int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection, uint64_t timestamp) { char server_addr[INET_ADDRSTRLEN]; char client_addr[INET_ADDRSTRLEN]; + char error_msg[128]; int r; bool broadcast = false; @@ -1045,45 +1046,45 @@ static int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection, case N_DHCP4_C_MESSAGE_REBIND: broadcast = true; r = n_dhcp4_c_connection_packet_broadcast(connection, request); - if (r) - return r; break; case N_DHCP4_C_MESSAGE_INFORM: broadcast = true; r = n_dhcp4_c_connection_udp_broadcast(connection, request); - if (r) - return r; - break; case N_DHCP4_C_MESSAGE_RENEW: case N_DHCP4_C_MESSAGE_RELEASE: r = n_dhcp4_c_connection_udp_send(connection, request); - if (r) - return r; - break; default: c_assert(0); } + if (r) { + snprintf(error_msg, sizeof(error_msg), ": error %d", r); + } else { + error_msg[0] = '\0'; + } + if (request->userdata.client_addr == INADDR_ANY) { n_dhcp4_c_log(connection->client_config, LOG_INFO, - "sent %s to %s", + "send %s to %s%s", message_type_to_str(request->userdata.message_type), broadcast ? "255.255.255.255" : inet_ntop(AF_INET, &connection->server_ip, - server_addr, sizeof(server_addr))); + server_addr, sizeof(server_addr)), + error_msg); } else { n_dhcp4_c_log(connection->client_config, LOG_INFO, - "sent %s of %s to %s", + "send %s of %s to %s%s", message_type_to_str(request->userdata.message_type), inet_ntop(AF_INET, &request->userdata.client_addr, client_addr, sizeof(client_addr)), broadcast ? "255.255.255.255" : inet_ntop(AF_INET, &connection->server_ip, - server_addr, sizeof(server_addr))); + server_addr, sizeof(server_addr)), + error_msg); } ++request->userdata.n_send; |