mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 04:58:01 +02:00
dhcp: move code in nm_dhcp_client_handle_event()
(cherry picked from commit9097679aad) (cherry picked from commitd0fcd690dc)
This commit is contained in:
parent
0c1a2f9408
commit
5686f7aa50
1 changed files with 22 additions and 30 deletions
|
|
@ -910,7 +910,6 @@ nm_dhcp_client_handle_event(gpointer unused,
|
||||||
NMPlatformIP6Address prefix = {
|
NMPlatformIP6Address prefix = {
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
gboolean reason_is_bound;
|
|
||||||
|
|
||||||
g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE);
|
g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE);
|
||||||
g_return_val_if_fail(iface != NULL, FALSE);
|
g_return_val_if_fail(iface != NULL, FALSE);
|
||||||
|
|
@ -930,17 +929,24 @@ nm_dhcp_client_handle_event(gpointer unused,
|
||||||
if (NM_IN_STRSET_ASCII_CASE(reason, "preinit"))
|
if (NM_IN_STRSET_ASCII_CASE(reason, "preinit"))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
reason_is_bound = NM_IN_STRSET_ASCII_CASE(reason,
|
if (NM_IN_STRSET_ASCII_CASE(reason, "bound", "bound6", "static"))
|
||||||
"bound",
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_BOUND;
|
||||||
"bound6",
|
else if (NM_IN_STRSET_ASCII_CASE(reason, "renew", "renew6", "reboot", "rebind", "rebind6"))
|
||||||
"static",
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_EXTENDED;
|
||||||
"renew",
|
else if (NM_IN_STRSET_ASCII_CASE(reason, "timeout"))
|
||||||
"renew6",
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_TIMEOUT;
|
||||||
"reboot",
|
else if (NM_IN_STRSET_ASCII_CASE(reason, "nak", "expire", "expire6"))
|
||||||
"rebind",
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_EXPIRE;
|
||||||
"rebind6");
|
else if (NM_IN_STRSET_ASCII_CASE(reason, "end", "stop", "stopped"))
|
||||||
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_TERMINATED;
|
||||||
|
else if (NM_IN_STRSET_ASCII_CASE(reason, "fail", "abend"))
|
||||||
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_FAIL;
|
||||||
|
else
|
||||||
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_UNSPECIFIED;
|
||||||
|
|
||||||
if (reason_is_bound) {
|
if (NM_IN_SET(client_event_type,
|
||||||
|
NM_DHCP_CLIENT_EVENT_TYPE_BOUND,
|
||||||
|
NM_DHCP_CLIENT_EVENT_TYPE_EXTENDED)) {
|
||||||
gs_unref_hashtable GHashTable *str_options = NULL;
|
gs_unref_hashtable GHashTable *str_options = NULL;
|
||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
@ -989,27 +995,13 @@ nm_dhcp_client_handle_event(gpointer unused,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fail if no valid IP config was received */
|
if (NM_IN_SET(client_event_type,
|
||||||
if (reason_is_bound && !l3cd) {
|
NM_DHCP_CLIENT_EVENT_TYPE_BOUND,
|
||||||
|
NM_DHCP_CLIENT_EVENT_TYPE_EXTENDED)
|
||||||
|
&& !l3cd) {
|
||||||
|
/* Fail if no valid IP config was received */
|
||||||
_LOGW("client bound but IP config not received");
|
_LOGW("client bound but IP config not received");
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_FAIL;
|
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_FAIL;
|
||||||
} else {
|
|
||||||
if (NM_IN_STRSET_ASCII_CASE(reason, "bound", "bound6", "static"))
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_BOUND;
|
|
||||||
else if (NM_IN_STRSET_ASCII_CASE(reason, "renew", "renew6", "reboot", "rebind", "rebind6"))
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_EXTENDED;
|
|
||||||
else if (NM_IN_STRSET_ASCII_CASE(reason, "timeout"))
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_TIMEOUT;
|
|
||||||
else if (NM_IN_STRSET_ASCII_CASE(reason, "nak", "expire", "expire6"))
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_EXPIRE;
|
|
||||||
else if (NM_IN_STRSET_ASCII_CASE(reason, "end", "stop", "stopped"))
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_TERMINATED;
|
|
||||||
else if (NM_IN_STRSET_ASCII_CASE(reason, "fail", "abend"))
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_FAIL;
|
|
||||||
else if (NM_IN_STRSET_ASCII_CASE(reason, "preinit"))
|
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
client_event_type = NM_DHCP_CLIENT_EVENT_TYPE_UNSPECIFIED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_nm_dhcp_client_notify(self, client_event_type, l3cd);
|
_nm_dhcp_client_notify(self, client_event_type, l3cd);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue