From: Jesse Gross Date: Wed, 6 Oct 2010 02:14:21 +0000 (-0700) Subject: tunneling: Internal dev vport can be NULL. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17a07f9f9d07f07d8dbb33ea1f8c9e53c89639de;p=openvswitch tunneling: Internal dev vport can be NULL. Commit 4bee42 "tunnel: Correctly check for internal device." fixed the call to internal_dev_get_vport() by first checking that the device is in fact an internal device. However, it also accidentally removed the check ensuring that the vport itself was not NULL. This adds that check back by redoing the previous change in a more robust manner. Signed-off-by: Jesse Gross Acked-by: Ben Pfaff --- diff --git a/datapath/tunnel.c b/datapath/tunnel.c index ad452280..cf742125 100644 --- a/datapath/tunnel.c +++ b/datapath/tunnel.c @@ -1266,15 +1266,16 @@ int tnl_send(struct vport *vport, struct sk_buff *skb) if (likely(cache)) { int orig_len = skb->len - cache->len; + struct vport *cache_vport = internal_dev_get_vport(rt_dst(rt).dev); skb->protocol = htons(ETH_P_IP); iph->tot_len = htons(skb->len - skb_network_offset(skb)); ip_send_check(iph); - if (is_internal_dev(rt_dst(rt).dev)) { + if (cache_vport) { OVS_CB(skb)->flow = cache->flow; compute_ip_summed(skb, true); - vport_receive(internal_dev_get_vport(rt_dst(rt).dev), skb); + vport_receive(cache_vport, skb); sent_len += orig_len; } else { int err; diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c index 514d00cb..84b90b57 100644 --- a/datapath/vport-internal_dev.c +++ b/datapath/vport-internal_dev.c @@ -329,6 +329,11 @@ int is_internal_vport(const struct vport *vport) struct vport *internal_dev_get_vport(struct net_device *netdev) { - struct internal_dev *internal_dev = internal_dev_priv(netdev); + struct internal_dev *internal_dev; + + if (!is_internal_dev(netdev)) + return NULL; + + internal_dev = internal_dev_priv(netdev); return rcu_dereference(internal_dev->attached_vport); }