From: Cédric Bosdonnat Date: Tue, 28 Mar 2017 14:00:24 +0000 (+0200) Subject: virNetDevIPCheckIPv6ForwardingCallback fixes X-Git-Tag: v3.3.0-rc1~300 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b202c39;p=thirdparty%2Flibvirt.git virNetDevIPCheckIPv6ForwardingCallback fixes Add check for more than one RTA_OIF, even though this is rather unlikely. Get rid of the buggy switch / break as this code won't need to handle more attributes. Use VIR_WARNINGS_NO_CAST_ALIGN to fix impossible to fix util/virnetdevip.c:560:17: error: cast increases required alignment of target type [-Werror=cast-align] --- diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index c9ac6baf73..726fa6c3e3 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -556,15 +556,24 @@ virNetDevIPCheckIPv6ForwardingCallback(const struct nlmsghdr *resp, if (resp->nlmsg_type != RTM_NEWROUTE) return ret; - /* Extract a few attributes */ + /* Extract a device ID attribute */ + VIR_WARNINGS_NO_CAST_ALIGN for (rta = RTM_RTA(rtmsg); RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) { - switch (rta->rta_type) { - case RTA_OIF: + VIR_WARNINGS_RESET + if (rta->rta_type == RTA_OIF) { oif = *(int *)RTA_DATA(rta); + /* Should never happen: netlink message would be broken */ + if (ifname) { + char *ifname2 = virNetDevGetName(oif); + VIR_WARN("Single route has unexpected 2nd interface " + "- '%s' and '%s'", ifname, ifname2); + VIR_FREE(ifname2); + break; + } + if (!(ifname = virNetDevGetName(oif))) goto error; - break; } }