tunneling: Internal dev vport can be NULL.
authorJesse Gross <jesse@nicira.com>
Wed, 6 Oct 2010 02:14:21 +0000 (19:14 -0700)
committerJesse Gross <jesse@nicira.com>
Fri, 8 Oct 2010 22:43:38 +0000 (15:43 -0700)
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 <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/tunnel.c
datapath/vport-internal_dev.c

index ad45228087e65b6cab5d84b549399431b1e721cb..cf742125e3618e08ea995d4f9713d76e1a35da86 100644 (file)
@@ -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;
index 514d00cb3b9d488614103eac7386e4ca27bffe0a..84b90b57191a508b33c09d01704a966705101ed8 100644 (file)
@@ -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);
 }