mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 02:28:18 +02:00
rdisc: do not crash on NDP init failures (rh #1012151)
ndp_open() can fail, do not assume it cannot. When 'ipv6.disable=1' kernel parameter is used, the whole IPv6 stack is disabled and the attempt to create PF_INET6 socket fails. https://bugzilla.redhat.com/show_bug.cgi?id=1012151
This commit is contained in:
parent
e69727bf8a
commit
469febc0d9
2 changed files with 16 additions and 7 deletions
|
|
@ -50,13 +50,23 @@ G_DEFINE_TYPE (NMLNDPRDisc, nm_lndp_rdisc, NM_TYPE_RDISC)
|
||||||
NMRDisc *
|
NMRDisc *
|
||||||
nm_lndp_rdisc_new (int ifindex, const char *ifname)
|
nm_lndp_rdisc_new (int ifindex, const char *ifname)
|
||||||
{
|
{
|
||||||
NMRDisc *rdisc = g_object_new (NM_TYPE_LNDP_RDISC, NULL);
|
NMRDisc *rdisc;
|
||||||
|
NMLNDPRDiscPrivate *priv;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
rdisc = g_object_new (NM_TYPE_LNDP_RDISC, NULL);
|
||||||
g_assert (rdisc);
|
g_assert (rdisc);
|
||||||
|
|
||||||
rdisc->ifindex = ifindex;
|
rdisc->ifindex = ifindex;
|
||||||
rdisc->ifname = g_strdup (ifname);
|
rdisc->ifname = g_strdup (ifname);
|
||||||
|
|
||||||
|
priv = NM_LNDP_RDISC_GET_PRIVATE (rdisc);
|
||||||
|
error = ndp_open (&priv->ndp);
|
||||||
|
if (error != 0) {
|
||||||
|
g_object_unref (rdisc);
|
||||||
|
debug ("(%s): error creating socket for NDP; errno=%d", ifname, -error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return rdisc;
|
return rdisc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -594,11 +604,6 @@ start (NMRDisc *rdisc)
|
||||||
static void
|
static void
|
||||||
nm_lndp_rdisc_init (NMLNDPRDisc *lndp_rdisc)
|
nm_lndp_rdisc_init (NMLNDPRDisc *lndp_rdisc)
|
||||||
{
|
{
|
||||||
NMLNDPRDiscPrivate *priv = NM_LNDP_RDISC_GET_PRIVATE (lndp_rdisc);
|
|
||||||
int error;
|
|
||||||
|
|
||||||
error = ndp_open (&priv->ndp);
|
|
||||||
g_assert (!error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -615,7 +620,8 @@ nm_lndp_rdisc_finalize (GObject *object)
|
||||||
if (priv->event_id)
|
if (priv->event_id)
|
||||||
g_source_remove (priv->event_id);
|
g_source_remove (priv->event_id);
|
||||||
|
|
||||||
ndp_close (priv->ndp);
|
if (priv->ndp)
|
||||||
|
ndp_close (priv->ndp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
rdisc = new (ifindex, ifname);
|
rdisc = new (ifindex, ifname);
|
||||||
|
if (!rdisc)
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
nm_rdisc_set_lladdr (rdisc, mac, 6);
|
nm_rdisc_set_lladdr (rdisc, mac, 6);
|
||||||
|
|
||||||
nm_rdisc_start (rdisc);
|
nm_rdisc_start (rdisc);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue