dhcp: downgrade warning about unhandled DHCP event in case of terminated client
When we kill a client, we usually get a DHCP event afterwards that cannot be associated with the client anymore (because we forgot about its PID). Do not log a warning in that case, but only a debug message. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include "nm-config.h"
|
#include "nm-config.h"
|
||||||
#include "nm-dbus-glib-types.h"
|
#include "nm-dbus-glib-types.h"
|
||||||
#include "nm-glib-compat.h"
|
#include "nm-glib-compat.h"
|
||||||
|
#include "NetworkManagerUtils.h"
|
||||||
|
|
||||||
GQuark
|
GQuark
|
||||||
nm_dhcp_manager_error_quark (void)
|
nm_dhcp_manager_error_quark (void)
|
||||||
@@ -198,41 +199,41 @@ nm_dhcp_manager_handle_event (DBusGProxy *proxy,
|
|||||||
char *iface = NULL;
|
char *iface = NULL;
|
||||||
char *pid_str = NULL;
|
char *pid_str = NULL;
|
||||||
char *reason = NULL;
|
char *reason = NULL;
|
||||||
unsigned long temp;
|
long pid;
|
||||||
|
|
||||||
iface = get_option (options, "interface");
|
iface = get_option (options, "interface");
|
||||||
if (iface == NULL) {
|
if (iface == NULL) {
|
||||||
nm_log_warn (LOGD_DHCP, "DHCP event didn't have associated interface.");
|
nm_log_warn (LOGD_DHCP, "DHCP event: didn't have associated interface.");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_str = get_option (options, "pid");
|
pid_str = get_option (options, "pid");
|
||||||
if (pid_str == NULL) {
|
pid = nm_utils_ascii_str_to_int64 (pid_str, 10, 0, LONG_MAX, -1);
|
||||||
nm_log_warn (LOGD_DHCP, "DHCP event didn't have associated PID.");
|
if (pid == -1 || pid != (GPid)pid) {
|
||||||
|
nm_log_warn (LOGD_DHCP, "DHCP event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp = strtoul (pid_str, NULL, 10);
|
reason = get_option (options, "reason");
|
||||||
if ((temp == ULONG_MAX) && (errno == ERANGE)) {
|
client = get_client_for_pid (manager, (GPid) pid);
|
||||||
nm_log_warn (LOGD_DHCP, "couldn't convert PID");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
client = get_client_for_pid (manager, (GPid) temp);
|
|
||||||
if (client == NULL) {
|
if (client == NULL) {
|
||||||
nm_log_warn (LOGD_DHCP, "(pid %ld) unhandled DHCP event for interface %s", temp, iface);
|
if (reason && g_ascii_strcasecmp (reason, "RELEASE") == 0) {
|
||||||
|
/* This happens regularly, when the dhcp client gets killed and we receive its last message.
|
||||||
|
* Don't log a warning in this case. */
|
||||||
|
nm_log_dbg (LOGD_DHCP, "(pid %ld) unhandled RELEASE DHCP event for interface %s", pid, iface);
|
||||||
|
} else
|
||||||
|
nm_log_warn (LOGD_DHCP, "(pid %ld) unhandled DHCP event for interface %s", pid, iface);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (iface, nm_dhcp_client_get_iface (client))) {
|
if (strcmp (iface, nm_dhcp_client_get_iface (client))) {
|
||||||
nm_log_warn (LOGD_DHCP, "(pid %ld) received DHCP event from unexpected interface '%s' (expected '%s')",
|
nm_log_warn (LOGD_DHCP, "(pid %ld) received DHCP event from unexpected interface '%s' (expected '%s')",
|
||||||
temp, iface, nm_dhcp_client_get_iface (client));
|
pid, iface, nm_dhcp_client_get_iface (client));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
reason = get_option (options, "reason");
|
|
||||||
if (reason == NULL) {
|
if (reason == NULL) {
|
||||||
nm_log_warn (LOGD_DHCP, "(pid %ld) DHCP event didn't have a reason", temp);
|
nm_log_warn (LOGD_DHCP, "(pid %ld) DHCP event didn't have a reason", pid);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user