summary refs log tree commit diff
path: root/src/rdisc/nm-rdisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rdisc/nm-rdisc.c')
-rw-r--r--src/rdisc/nm-rdisc.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/rdisc/nm-rdisc.c b/src/rdisc/nm-rdisc.c
index 07271a89..a73ab7d0 100644
--- a/src/rdisc/nm-rdisc.c
+++ b/src/rdisc/nm-rdisc.c
@@ -83,7 +83,7 @@ nm_rdisc_add_gateway (NMRDisc *rdisc, const NMRDiscGateway *new)
 	}
 
 	if (new->lifetime)
-		g_array_insert_val (rdisc->gateways, CLAMP (insert_idx, 0, G_MAXINT), *new);
+		g_array_insert_val (rdisc->gateways, MAX (insert_idx, 0), *new);
 	return !!new->lifetime;
 }
 
@@ -241,12 +241,38 @@ clear_rs_timeout (NMRDisc *rdisc)
 	}
 }
 
-void
+/**
+ * nm_rdisc_set_iid:
+ * @rdisc: the #NMRDisc
+ * @iid: the new interface ID
+ *
+ * Sets the "Modified EUI-64" interface ID to be used when generating
+ * IPv6 addresses using received prefixes. Identifiers are either generated
+ * from the hardware addresses or manually set by the operator with
+ * "ip token" command.
+ *
+ * Upon token change (or initial setting) all addresses generated using
+ * the old identifier are removed. The caller should ensure the addresses
+ * will be reset by soliciting router advertisements.
+ *
+ * Returns: %TRUE if the token was changed, %FALSE otherwise.
+ **/
+gboolean
 nm_rdisc_set_iid (NMRDisc *rdisc, const NMUtilsIPv6IfaceId iid)
 {
-	g_return_if_fail (NM_IS_RDISC (rdisc));
+	g_return_val_if_fail (NM_IS_RDISC (rdisc), FALSE);
+
+	if (rdisc->iid.id != iid.id) {
+		rdisc->iid = iid;
+		if (rdisc->addresses->len) {
+			debug ("(%s) IPv6 interface identifier changed, flushing addresses", rdisc->ifname);
+			g_array_remove_range (rdisc->addresses, 0, rdisc->addresses->len);
+			g_signal_emit_by_name (rdisc, NM_RDISC_CONFIG_CHANGED, NM_RDISC_CONFIG_ADDRESSES);
+		}
+		return TRUE;
+	}
 
-	rdisc->iid = iid;
+	return FALSE;
 }
 
 static gboolean