X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=datapath%2Fvport-internal_dev.c;h=b503b877ad438f83e8edc1989026ad4c8286f48c;hb=a5d6fc245ed1e3e0796a82e947f5ce638becd4ef;hp=63f3f69ce81b55eccede464225a53d416f5240cd;hpb=8338302d5cecb0a082104a8ff09544c2909d4308;p=openvswitch diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c index 63f3f69c..b503b877 100644 --- a/datapath/vport-internal_dev.c +++ b/datapath/vport-internal_dev.c @@ -6,6 +6,7 @@ * kernel, by Linus Torvalds and others. */ +#include #include #include #include @@ -31,16 +32,14 @@ static inline struct internal_dev *internal_dev_priv(struct net_device *netdev) return netdev_priv(netdev); } -/* This function is only called by the kernel network layer. It is not a vport - * get_stats() function. If a vport get_stats() function is defined that - * results in this being called it will cause infinite recursion. */ +/* This function is only called by the kernel network layer.*/ static struct net_device_stats *internal_dev_sys_stats(struct net_device *netdev) { struct vport *vport = internal_dev_get_vport(netdev); struct net_device_stats *stats = &internal_dev_priv(netdev)->stats; if (vport) { - struct rtnl_link_stats64 vport_stats; + struct ovs_vport_stats vport_stats; vport_get_stats(vport, &vport_stats); @@ -54,7 +53,6 @@ static struct net_device_stats *internal_dev_sys_stats(struct net_device *netdev stats->tx_errors = vport_stats.rx_errors; stats->rx_dropped = vport_stats.tx_dropped; stats->tx_dropped = vport_stats.rx_dropped; - stats->collisions = vport_stats.collisions; } return stats; @@ -70,14 +68,20 @@ static int internal_dev_mac_addr(struct net_device *dev, void *p) return 0; } -/* Called with rcu_read_lock and bottom-halves disabled. */ +/* Called with rcu_read_lock_bh. */ static int internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev) { - compute_ip_summed(skb, true); + if (unlikely(compute_ip_summed(skb, true))) { + kfree_skb(skb); + return 0; + } + vlan_copy_skb_tci(skb); OVS_CB(skb)->flow = NULL; + rcu_read_lock(); vport_receive(internal_dev_priv(netdev)->vport, skb); + rcu_read_unlock(); return 0; } @@ -112,14 +116,9 @@ static const struct ethtool_ops internal_dev_ethtool_ops = { static int internal_dev_change_mtu(struct net_device *netdev, int new_mtu) { - struct vport *vport = internal_dev_get_vport(netdev); - if (new_mtu < 68) return -EINVAL; - if (new_mtu > dp_min_mtu(vport->dp)) - return -EINVAL; - netdev->mtu = new_mtu; return 0; } @@ -176,6 +175,11 @@ static void do_setup(struct net_device *netdev) netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) + netdev->vlan_features = netdev->features; + netdev->features |= NETIF_F_HW_VLAN_TX; +#endif + vport_gen_rand_ether_addr(netdev->dev_addr); } @@ -220,7 +224,7 @@ error: return ERR_PTR(err); } -static int internal_dev_destroy(struct vport *vport) +static void internal_dev_destroy(struct vport *vport) { struct netdev_vport *netdev_vport = netdev_vport_priv(vport); @@ -229,8 +233,6 @@ static int internal_dev_destroy(struct vport *vport) /* unregister_netdevice() waits for an RCU grace period. */ unregister_netdevice(netdev_vport->dev); - - return 0; } static int internal_dev_recv(struct vport *vport, struct sk_buff *skb) @@ -247,11 +249,9 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb) skb->dev = netdev; skb->pkt_type = PACKET_HOST; skb->protocol = eth_type_trans(skb, netdev); + forward_ip_summed(skb, false); - if (in_interrupt()) - netif_rx(skb); - else - netif_rx_ni(skb); + netif_rx(skb); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) netdev->last_rx = jiffies; @@ -261,11 +261,10 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb) } const struct vport_ops internal_vport_ops = { - .type = ODP_VPORT_TYPE_INTERNAL, - .flags = VPORT_F_REQUIRED | VPORT_F_GEN_STATS | VPORT_F_FLOW, + .type = OVS_VPORT_TYPE_INTERNAL, + .flags = VPORT_F_REQUIRED | VPORT_F_FLOW, .create = internal_dev_create, .destroy = internal_dev_destroy, - .set_mtu = netdev_set_mtu, .set_addr = netdev_set_addr, .get_name = netdev_get_name, .get_addr = netdev_get_addr, @@ -274,7 +273,6 @@ const struct vport_ops internal_vport_ops = { .is_running = netdev_is_running, .get_operstate = netdev_get_operstate, .get_ifindex = netdev_get_ifindex, - .get_iflink = netdev_get_iflink, .get_mtu = netdev_get_mtu, .send = internal_dev_recv, };