diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-08-04 11:30:03 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2015-08-04 14:11:08 +0200 |
commit | 0322d129848836c0500047d1a75261436ebf5b28 (patch) | |
tree | 01232d8d20f23e3260189f6ed8f8e095648b2210 /src/dhcp-manager/nm-dhcp-client.c | |
parent | 7c38b784632ecc490f7440a286dc81b452dc6213 (diff) | |
download | NetworkManager-bg/dhcp6-multiple-addrs-bgo681764.tar.gz |
device: accept multiple addresses in a DHCPv6 leasebg/dhcp6-multiple-addrs-bgo681764
When the DHCPv6 lease received from the server contains multiple
addresses, dhclient generates a new BOUND event for each of
them. Instead of overwriting the previous IP6 configuration for each
BOUND event, we should try to detect if the new configuration belongs
to the same lease and merge its addresses with the existing one in
such case.
This allows NetworkManager to configure multiple addresses on an
interface via DHCPv6.
https://bugzilla.gnome.org/show_bug.cgi?id=681764
Diffstat (limited to 'src/dhcp-manager/nm-dhcp-client.c')
-rw-r--r-- | src/dhcp-manager/nm-dhcp-client.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index c00782f963..caeba85b60 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -36,6 +36,7 @@ #include "nm-dhcp-client.h" #include "nm-dhcp-utils.h" #include "nm-platform.h" +#include "gsystem-local-alloc.h" typedef struct { char * iface; @@ -284,6 +285,7 @@ nm_dhcp_client_set_state (NMDhcpClient *self, GHashTable *options) { NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + gs_free char *event_id = NULL; if (new_state >= NM_DHCP_STATE_BOUND) timeout_cleanup (self); @@ -308,19 +310,30 @@ nm_dhcp_client_set_state (NMDhcpClient *self, if ((priv->state == new_state) && (new_state != NM_DHCP_STATE_BOUND)) return; + if (priv->ipv6 && new_state == NM_DHCP_STATE_BOUND) { + char *start, *iaid; + + iaid = g_hash_table_lookup (options, "iaid"); + start = g_hash_table_lookup (options, "life_starts"); + if (iaid && start) + event_id = g_strdup_printf ("%s|%s", iaid, start); + } + nm_log_info (priv->ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, - "(%s): DHCPv%c state changed %s -> %s", + "(%s): DHCPv%c state changed %s -> %s%s%s%s", priv->iface, priv->ipv6 ? '6' : '4', state_to_string (priv->state), - state_to_string (new_state)); + state_to_string (new_state), + NM_PRINT_FMT_QUOTED (event_id, ", event ID=\"", event_id, "\"", "")); priv->state = new_state; g_signal_emit (G_OBJECT (self), signals[SIGNAL_STATE_CHANGED], 0, new_state, ip_config, - options); + options, + event_id); } static gboolean @@ -979,6 +992,6 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMDhcpClientClass, state_changed), NULL, NULL, NULL, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE); + G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE, G_TYPE_STRING); } |