ip-tunnel: avoid crash on missing NMPlatformLnkIp6Tnl lnk part

You cannot assume that we are always able to lookup a corresponding
lnk object. In fact, there is no guarantee that link->ifindex still
exists in the platform cache at all.
This commit is contained in:
Thomas Haller 2016-11-08 09:48:27 +01:00 committed by Beniamino Galvani
parent a6416cbd13
commit 602247e8e3

View file

@ -557,12 +557,13 @@ platform_link_to_tunnel_mode (const NMPlatformLink *link)
return NM_IP_TUNNEL_MODE_GRE;
case NM_LINK_TYPE_IP6TNL:
lnk = nm_platform_link_get_lnk_ip6tnl (NM_PLATFORM_GET, link->ifindex, NULL);
if (lnk->proto == IPPROTO_IPIP)
return NM_IP_TUNNEL_MODE_IPIP6;
else if (lnk->proto == IPPROTO_IPV6)
return NM_IP_TUNNEL_MODE_IP6IP6;
else
return NM_IP_TUNNEL_MODE_UNKNOWN;
if (lnk) {
if (lnk->proto == IPPROTO_IPIP)
return NM_IP_TUNNEL_MODE_IPIP6;
if (lnk->proto == IPPROTO_IPV6)
return NM_IP_TUNNEL_MODE_IP6IP6;
}
return NM_IP_TUNNEL_MODE_UNKNOWN;
case NM_LINK_TYPE_IPIP:
return NM_IP_TUNNEL_MODE_IPIP;
case NM_LINK_TYPE_SIT: