summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-11-08 09:48:27 +0100
committerThomas Haller <thaller@redhat.com>2016-11-08 09:48:27 +0100
commit3cab04d518c53cf867b9a55731a1ea4afa7a35bb (patch)
tree5e9ca6646abf1e2409256ac7094fb23636d766c2
parent35c8376f0e3399c8e35e16a29385a47192eeb9cc (diff)
downloadNetworkManager-bg/tui-ip-tunnel-rh1391424.tar.gz
ip-tunnel: avoid crash on missing NMPlatformLnkIp6Tnl lnk partbg/tui-ip-tunnel-rh1391424
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.
-rw-r--r--src/devices/nm-device-ip-tunnel.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index 8732ddf9b5..ee3725434e 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -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: