ofp-util: Work on decoding OF1.1 flow_mods.
[openvswitch] / datapath / vport-internal_dev.c
index c56f3b2954530582f36475b660dd57eeadd750c4..4dc2eb479d7024586f9d85538ace6a48e119d6f0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2011 Nicira Networks.
+ * Copyright (c) 2007-2012 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -25,6 +25,9 @@
 #include <linux/skbuff.h>
 #include <linux/version.h>
 
+#include <net/dst.h>
+#include <net/xfrm.h>
+
 #include "checksum.h"
 #include "datapath.h"
 #include "vlan.h"
@@ -87,6 +90,9 @@ static int internal_dev_mac_addr(struct net_device *dev, void *p)
 
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
+#ifdef NET_ADDR_RANDOM
+       dev->addr_assign_type &= ~NET_ADDR_RANDOM;
+#endif
        memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
        return 0;
 }
@@ -203,7 +209,7 @@ static void do_setup(struct net_device *netdev)
        netdev->tx_queue_len = 0;
 
        netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST |
-                               NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO;
+                          NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
        netdev->vlan_features = netdev->features;
@@ -213,7 +219,7 @@ static void do_setup(struct net_device *netdev)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
        netdev->hw_features = netdev->features & ~NETIF_F_LLTX;
 #endif
-       random_ether_addr(netdev->dev_addr);
+       eth_hw_addr_random(netdev);
 }
 
 static struct vport *internal_dev_create(const struct vport_parms *parms)
@@ -239,9 +245,14 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
                goto error_free_vport;
        }
 
+       dev_net_set(netdev_vport->dev, ovs_dp_get_net(vport->dp));
        internal_dev = internal_dev_priv(netdev_vport->dev);
        internal_dev->vport = vport;
 
+       /* Restrict bridge port to current netns. */
+       if (vport->port_no == OVSP_LOCAL)
+               netdev_vport->dev->features |= NETIF_F_NETNS_LOCAL;
+
        err = register_netdevice(netdev_vport->dev);
        if (err)
                goto error_free_netdev;
@@ -281,6 +292,11 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb)
 #endif
 
        len = skb->len;
+
+       skb_dst_drop(skb);
+       nf_reset(skb);
+       secpath_reset(skb);
+
        skb->dev = netdev;
        skb->pkt_type = PACKET_HOST;
        skb->protocol = eth_type_trans(skb, netdev);