datapath: Check that netdev vport is fully initialized.
authorJesse Gross <jesse@nicira.com>
Thu, 19 May 2011 20:17:39 +0000 (13:17 -0700)
committerJesse Gross <jesse@nicira.com>
Thu, 19 May 2011 21:02:44 +0000 (14:02 -0700)
Starting in 2.6.37 we have our own flag for identifying net_devices
as being attached to OVS.  However, it's possible to receive packets
before this flag has been applied, resulting in a NULL vport when
processing the packet.  This checks to make sure that the vport is
valid instead of crashing.

Bug #5675

Reported-by: Brad Hall <brad@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/vport-netdev.c

index 18fc5feeaee6751e712117b31ce8527a6edc675a..3bab666c888132a9936812f4a331e9ed90ff42ac 100644 (file)
@@ -268,6 +268,11 @@ int netdev_get_mtu(const struct vport *vport)
 /* Must be called with rcu_read_lock. */
 static void netdev_port_receive(struct vport *vport, struct sk_buff *skb)
 {
+       if (unlikely(!vport)) {
+               kfree_skb(skb);
+               return;
+       }
+
        /* Make our own copy of the packet.  Otherwise we will mangle the
         * packet for anyone who came before us (e.g. tcpdump via AF_PACKET).
         * (No one comes after us, since we tell handle_bridge() that we took