summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-10-14 19:53:53 +0200
committerLubomir Rintel <lkundrak@v3.sk>2016-11-09 17:23:31 +0100
commitaed2106d3e37d835d3b80f28f626a489e67cd400 (patch)
treeab2c41049ee6a778496575140a229a6d8cd0fa78 /src
parent679f8dfc7d0e064dee26218f6aa914df0a0bddef (diff)
downloadNetworkManager-aed2106d3e37d835d3b80f28f626a489e67cd400.tar.gz
ndisc: avoid calling start() multiple times
It hooks on ndp event callbacks and we'll end up in them being done redundantly, leaking them on dispose and potentially even calling them.
Diffstat (limited to 'src')
-rw-r--r--src/devices/nm-device.c4
-rw-r--r--src/ndisc/nm-lndp-ndisc.c3
-rw-r--r--src/ndisc/nm-ndisc.c8
3 files changed, 8 insertions, 7 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 83a0774708..72417afc44 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1897,10 +1897,8 @@ device_link_changed (NMDevice *self)
}
if (priv->ndisc && info.inet6_token.id) {
- if (nm_ndisc_set_iid (priv->ndisc, info.inet6_token)) {
+ if (nm_ndisc_set_iid (priv->ndisc, info.inet6_token))
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
- nm_ndisc_start (priv->ndisc);
- }
}
if (klass->link_changed)
diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c
index b86aad2cc2..d01c128fb0 100644
--- a/src/ndisc/nm-lndp-ndisc.c
+++ b/src/ndisc/nm-lndp-ndisc.c
@@ -323,6 +323,9 @@ start (NMNDisc *ndisc)
NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc);
int fd = ndp_get_eventfd (priv->ndp);
+ g_return_if_fail (!priv->event_channel);
+ g_return_if_fail (!priv->event_id);
+
priv->event_channel = g_io_channel_unix_new (fd);
priv->event_id = g_io_add_watch (priv->event_channel, G_IO_IN, (GIOFunc) event_ready, ndisc);
diff --git a/src/ndisc/nm-ndisc.c b/src/ndisc/nm-ndisc.c
index f78c4fd453..a7f0dd8589 100644
--- a/src/ndisc/nm-ndisc.c
+++ b/src/ndisc/nm-ndisc.c
@@ -531,6 +531,7 @@ nm_ndisc_set_iid (NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid)
_LOGD ("IPv6 interface identifier changed, flushing addresses");
g_array_remove_range (rdata->addresses, 0, rdata->addresses->len);
_emit_config_change (ndisc, NM_NDISC_CONFIG_ADDRESSES);
+ solicit (ndisc);
}
return TRUE;
}
@@ -556,21 +557,20 @@ nm_ndisc_start (NMNDisc *ndisc)
NMNDiscClass *klass = NM_NDISC_GET_CLASS (ndisc);
gint64 ra_wait_secs;
- g_assert (klass->start);
+ g_return_if_fail (klass->start);
+ g_return_if_fail (!priv->ra_timeout_id);
_LOGD ("starting neighbor discovery: %d", priv->ifindex);
if (!nm_ndisc_netns_push (ndisc, &netns))
return;
- nm_clear_g_source (&priv->ra_timeout_id);
ra_wait_secs = (((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1;
ra_wait_secs = CLAMP (ra_wait_secs, 30, 120);
priv->ra_timeout_id = g_timeout_add_seconds (ra_wait_secs, ndisc_ra_timeout_cb, ndisc);
_LOGD ("scheduling RA timeout in %d seconds", (int) ra_wait_secs);
- if (klass->start)
- klass->start (ndisc);
+ klass->start (ndisc);
solicit (ndisc);
}