diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2020-02-26 16:25:55 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2020-02-26 16:25:55 +0100 |
| commit | ee7b95167028fdbb2a4bd32aa686e27817d8dfe0 (patch) | |
| tree | f7a1abab0400789979f860dda724247a9bbbdef1 /src/dhcp/nm-dhcp-client.c | |
| parent | c1b3616485604f3fddfad9521cb8818cd8eece2b (diff) | |
| parent | e536d40eaea5dcdc0743b0a5e8e17faa46608a50 (diff) | |
Merge branch 'upstream/latest' of https://salsa.debian.org/utopia-team/network-manager into upstream/latest
Diffstat (limited to 'src/dhcp/nm-dhcp-client.c')
| -rw-r--r-- | src/dhcp/nm-dhcp-client.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c index 0a07b26c..81c4ad9c 100644 --- a/src/dhcp/nm-dhcp-client.c +++ b/src/dhcp/nm-dhcp-client.c @@ -317,6 +317,7 @@ nm_dhcp_client_get_use_fqdn (NMDhcpClient *self) static const char *state_table[NM_DHCP_STATE_MAX + 1] = { [NM_DHCP_STATE_UNKNOWN] = "unknown", [NM_DHCP_STATE_BOUND] = "bound", + [NM_DHCP_STATE_EXTENDED] = "extended", [NM_DHCP_STATE_TIMEOUT] = "timeout", [NM_DHCP_STATE_EXPIRE] = "expire", [NM_DHCP_STATE_DONE] = "done", @@ -336,13 +337,14 @@ static NMDhcpState reason_to_state (NMDhcpClient *self, const char *iface, const char *reason) { if (g_ascii_strcasecmp (reason, "bound") == 0 || - g_ascii_strcasecmp (reason, "bound6") == 0 || - g_ascii_strcasecmp (reason, "renew") == 0 || - g_ascii_strcasecmp (reason, "renew6") == 0 || - g_ascii_strcasecmp (reason, "reboot") == 0 || - g_ascii_strcasecmp (reason, "rebind") == 0 || - g_ascii_strcasecmp (reason, "rebind6") == 0) + g_ascii_strcasecmp (reason, "bound6") == 0) return NM_DHCP_STATE_BOUND; + else if (g_ascii_strcasecmp (reason, "renew") == 0 || + g_ascii_strcasecmp (reason, "renew6") == 0 || + g_ascii_strcasecmp (reason, "reboot") == 0 || + g_ascii_strcasecmp (reason, "rebind") == 0 || + g_ascii_strcasecmp (reason, "rebind6") == 0) + return NM_DHCP_STATE_EXTENDED; else if (g_ascii_strcasecmp (reason, "timeout") == 0) return NM_DHCP_STATE_TIMEOUT; else if (g_ascii_strcasecmp (reason, "nak") == 0 || @@ -415,7 +417,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self, NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); gs_free char *event_id = NULL; - if (new_state == NM_DHCP_STATE_BOUND) { + if (NM_IN_SET (new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) { g_return_if_fail (NM_IS_IP_CONFIG (ip_config, priv->addr_family)); g_return_if_fail (options); } else { @@ -430,10 +432,11 @@ nm_dhcp_client_set_state (NMDhcpClient *self, /* The client may send same-state transitions for RENEW/REBIND events and * the lease may have changed, so handle same-state transitions for the - * BOUND state. Ignore same-state transitions for other events since - * the lease won't have changed and the state was already handled. + * EXTENDED and BOUND states. Ignore same-state transitions for other + * events since the lease won't have changed and the state was already handled. */ - if ((priv->state == new_state) && (new_state != NM_DHCP_STATE_BOUND)) + if ( (priv->state == new_state) + && !NM_IN_SET (new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) return; if (_LOGI_ENABLED ()) { @@ -448,7 +451,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self, } if ( priv->addr_family == AF_INET6 - && new_state == NM_DHCP_STATE_BOUND) { + && NM_IN_SET (new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) { char *start, *iaid; iaid = g_hash_table_lookup (options, "iaid"); @@ -877,7 +880,7 @@ nm_dhcp_client_handle_event (gpointer unused, _LOGD ("DHCP state '%s' -> '%s' (reason: '%s')", state_to_string (old_state), state_to_string (new_state), reason); - if (new_state == NM_DHCP_STATE_BOUND) { + if (NM_IN_SET (new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED)) { GVariantIter iter; const char *name; GVariant *value; @@ -918,7 +921,7 @@ nm_dhcp_client_handle_event (gpointer unused, nm_dhcp_client_emit_ipv6_prefix_delegated (self, &prefix); } else { /* Fail if no valid IP config was received */ - if ( new_state == NM_DHCP_STATE_BOUND + if ( NM_IN_SET (new_state, NM_DHCP_STATE_BOUND, NM_DHCP_STATE_EXTENDED) && !ip_config) { _LOGW ("client bound but IP config not received"); new_state = NM_DHCP_STATE_FAIL; @@ -1007,8 +1010,8 @@ set_property (GObject *object, guint prop_id, case PROP_IFACE: /* construct-only */ priv->iface = g_value_dup_string (value); - g_return_if_fail ( priv->iface - && nm_utils_is_valid_iface_name (priv->iface, NULL)); + g_return_if_fail (priv->iface); + nm_assert (nm_utils_ifname_valid_kernel (priv->iface, NULL)); break; case PROP_IFINDEX: /* construct-only */ @@ -1200,6 +1203,7 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + G_STATIC_ASSERT_EXPR (G_MAXINT32 == NM_DHCP_TIMEOUT_INFINITY); obj_properties[PROP_TIMEOUT] = g_param_spec_uint (NM_DHCP_CLIENT_TIMEOUT, "", "", 1, G_MAXINT32, NM_DHCP_TIMEOUT_DEFAULT, |