|
|
613f66 |
From 95c67b5117499c3a31cdb52b81f1cc9bdb091d88 Mon Sep 17 00:00:00 2001
|
|
|
613f66 |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
613f66 |
Date: Tue, 18 Feb 2020 17:04:37 +0100
|
|
|
613f66 |
Subject: [PATCH 1/2] n-dhcp4: fix logging macro
|
|
|
613f66 |
|
|
|
613f66 |
The level can be a complex expression, don't use it directly in the
|
|
|
613f66 |
macro.
|
|
|
613f66 |
|
|
|
613f66 |
(cherry picked from commit 910267cf5f0f163a038ec983bec237c8a8cb1abf)
|
|
|
613f66 |
(cherry picked from commit 84c4920f5d97cc79ca349d035c719ffac3dd5fc3)
|
|
|
613f66 |
---
|
|
|
613f66 |
shared/n-dhcp4/src/n-dhcp4-private.h | 5 +++--
|
|
|
613f66 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
613f66 |
|
|
|
613f66 |
diff --git a/shared/n-dhcp4/src/n-dhcp4-private.h b/shared/n-dhcp4/src/n-dhcp4-private.h
|
|
|
613f66 |
index 436ee8065..f647cb5e2 100644
|
|
|
613f66 |
--- a/shared/n-dhcp4/src/n-dhcp4-private.h
|
|
|
613f66 |
+++ b/shared/n-dhcp4/src/n-dhcp4-private.h
|
|
|
613f66 |
@@ -702,10 +702,11 @@ static inline uint64_t n_dhcp4_gettime(clockid_t clock) {
|
|
|
613f66 |
#define n_dhcp4_c_log(_config, _level, ...) \
|
|
|
613f66 |
do { \
|
|
|
613f66 |
const NDhcp4ClientConfig *__config = _config; \
|
|
|
613f66 |
+ int __level = _level; \
|
|
|
613f66 |
\
|
|
|
613f66 |
- if (_level <= __config->log.level && __config->log.func) { \
|
|
|
613f66 |
+ if (__level <= __config->log.level && __config->log.func) { \
|
|
|
613f66 |
if (1) { \
|
|
|
613f66 |
- _config->log.func(_level, \
|
|
|
613f66 |
+ _config->log.func(__level, \
|
|
|
613f66 |
__config->log.data, \
|
|
|
613f66 |
__VA_ARGS__); \
|
|
|
613f66 |
} else { \
|
|
|
613f66 |
--
|
|
|
613f66 |
2.24.1
|
|
|
613f66 |
|
|
|
613f66 |
From 539bb87ca200faaba7d1ccb96aae5eaf15349173 Mon Sep 17 00:00:00 2001
|
|
|
613f66 |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
613f66 |
Date: Mon, 24 Feb 2020 09:55:13 +0100
|
|
|
613f66 |
Subject: [PATCH 2/2] n-dhcp4: keep trying after a failure in send()
|
|
|
613f66 |
|
|
|
613f66 |
Currently if an error is encountered during a send() of a message, the
|
|
|
613f66 |
client fails and there is no possibility of recover, since no timers
|
|
|
613f66 |
are armed after a failed event dispatch. An easy way to reproduce a
|
|
|
613f66 |
failure is to add a firewall rule like:
|
|
|
613f66 |
|
|
|
613f66 |
iptables -A OUTPUT -p udp --dport 67 -j REJECT
|
|
|
613f66 |
|
|
|
613f66 |
which makes the send() fail with EPERM during the renew. In such case,
|
|
|
613f66 |
the client should continue (failing) until it reaches the rebind phase
|
|
|
613f66 |
at T2, when it will be able to renew the lease using the packet
|
|
|
613f66 |
socket.
|
|
|
613f66 |
|
|
|
613f66 |
In general, a failure to send a packet should not cause the failure of
|
|
|
613f66 |
the client.
|
|
|
613f66 |
|
|
|
613f66 |
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/419
|
|
|
613f66 |
https://bugzilla.redhat.com/show_bug.cgi?id=1806516
|
|
|
613f66 |
(cherry picked from commit 5a7b83ea0a2eb3cb0bb39c8219490c704024b5f5)
|
|
|
613f66 |
(cherry picked from commit 932b4538aee7da9a1fe75d115358bb943872e3fd)
|
|
|
613f66 |
---
|
|
|
613f66 |
shared/n-dhcp4/src/n-dhcp4-c-connection.c | 25 ++++++++++++-----------
|
|
|
613f66 |
1 file changed, 13 insertions(+), 12 deletions(-)
|
|
|
613f66 |
|
|
|
613f66 |
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c
|
|
|
613f66 |
index d4354467d..a5c8ea66f 100644
|
|
|
613f66 |
--- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c
|
|
|
613f66 |
+++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c
|
|
|
613f66 |
@@ -1006,6 +1006,7 @@ static int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection,
|
|
|
613f66 |
uint64_t timestamp) {
|
|
|
613f66 |
char server_addr[INET_ADDRSTRLEN];
|
|
|
613f66 |
char client_addr[INET_ADDRSTRLEN];
|
|
|
613f66 |
+ char error_msg[128];
|
|
|
613f66 |
int r;
|
|
|
613f66 |
bool broadcast = false;
|
|
|
613f66 |
|
|
|
613f66 |
@@ -1045,45 +1046,45 @@ static int n_dhcp4_c_connection_send_request(NDhcp4CConnection *connection,
|
|
|
613f66 |
case N_DHCP4_C_MESSAGE_REBIND:
|
|
|
613f66 |
broadcast = true;
|
|
|
613f66 |
r = n_dhcp4_c_connection_packet_broadcast(connection, request);
|
|
|
613f66 |
- if (r)
|
|
|
613f66 |
- return r;
|
|
|
613f66 |
break;
|
|
|
613f66 |
case N_DHCP4_C_MESSAGE_INFORM:
|
|
|
613f66 |
broadcast = true;
|
|
|
613f66 |
r = n_dhcp4_c_connection_udp_broadcast(connection, request);
|
|
|
613f66 |
- if (r)
|
|
|
613f66 |
- return r;
|
|
|
613f66 |
-
|
|
|
613f66 |
break;
|
|
|
613f66 |
case N_DHCP4_C_MESSAGE_RENEW:
|
|
|
613f66 |
case N_DHCP4_C_MESSAGE_RELEASE:
|
|
|
613f66 |
r = n_dhcp4_c_connection_udp_send(connection, request);
|
|
|
613f66 |
- if (r)
|
|
|
613f66 |
- return r;
|
|
|
613f66 |
-
|
|
|
613f66 |
break;
|
|
|
613f66 |
default:
|
|
|
613f66 |
c_assert(0);
|
|
|
613f66 |
}
|
|
|
613f66 |
|
|
|
613f66 |
+ if (r) {
|
|
|
613f66 |
+ snprintf(error_msg, sizeof(error_msg), ": error %d", r);
|
|
|
613f66 |
+ } else {
|
|
|
613f66 |
+ error_msg[0] = '\0';
|
|
|
613f66 |
+ }
|
|
|
613f66 |
+
|
|
|
613f66 |
if (request->userdata.client_addr == INADDR_ANY) {
|
|
|
613f66 |
n_dhcp4_c_log(connection->client_config, LOG_INFO,
|
|
|
613f66 |
- "sent %s to %s",
|
|
|
613f66 |
+ "send %s to %s%s",
|
|
|
613f66 |
message_type_to_str(request->userdata.message_type),
|
|
|
613f66 |
broadcast ?
|
|
|
613f66 |
"255.255.255.255" :
|
|
|
613f66 |
inet_ntop(AF_INET, &connection->server_ip,
|
|
|
613f66 |
- server_addr, sizeof(server_addr)));
|
|
|
613f66 |
+ server_addr, sizeof(server_addr)),
|
|
|
613f66 |
+ error_msg);
|
|
|
613f66 |
} else {
|
|
|
613f66 |
n_dhcp4_c_log(connection->client_config, LOG_INFO,
|
|
|
613f66 |
- "sent %s of %s to %s",
|
|
|
613f66 |
+ "send %s of %s to %s%s",
|
|
|
613f66 |
message_type_to_str(request->userdata.message_type),
|
|
|
613f66 |
inet_ntop(AF_INET, &request->userdata.client_addr,
|
|
|
613f66 |
client_addr, sizeof(client_addr)),
|
|
|
613f66 |
broadcast ?
|
|
|
613f66 |
"255.255.255.255" :
|
|
|
613f66 |
inet_ntop(AF_INET, &connection->server_ip,
|
|
|
613f66 |
- server_addr, sizeof(server_addr)));
|
|
|
613f66 |
+ server_addr, sizeof(server_addr)),
|
|
|
613f66 |
+ error_msg);
|
|
|
613f66 |
}
|
|
|
613f66 |
|
|
|
613f66 |
++request->userdata.n_send;
|
|
|
613f66 |
--
|
|
|
613f66 |
2.24.1
|
|
|
613f66 |
|