X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=datapath%2Fvport-netdev.c;h=78f149341ad3353defa2aaf264319ed2cb6e52a9;hb=5ca1ba484bd9ade5116a49cf241cb98219d7d696;hp=e24e5883b1a39551f604ef80e4268009b651fbaa;hpb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;p=sliver-openvswitch.git diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c index e24e5883b..78f149341 100644 --- a/datapath/vport-netdev.c +++ b/datapath/vport-netdev.c @@ -173,6 +173,15 @@ error: return ERR_PTR(err); } +static void free_port_rcu(struct rcu_head *rcu) +{ + struct netdev_vport *netdev_vport = container_of(rcu, + struct netdev_vport, rcu); + + dev_put(netdev_vport->dev); + ovs_vport_free(vport_from_priv(netdev_vport)); +} + static void netdev_destroy(struct vport *vport) { struct netdev_vport *netdev_vport = netdev_vport_priv(vport); @@ -181,10 +190,7 @@ static void netdev_destroy(struct vport *vport) netdev_rx_handler_unregister(netdev_vport->dev); dev_set_promiscuity(netdev_vport->dev, -1); - synchronize_rcu(); - - dev_put(netdev_vport->dev); - ovs_vport_free(vport); + call_rcu(&netdev_vport->rcu, free_port_rcu); } int ovs_netdev_set_addr(struct vport *vport, const unsigned char *addr) @@ -210,42 +216,12 @@ const unsigned char *ovs_netdev_get_addr(const struct vport *vport) return netdev_vport->dev->dev_addr; } -struct kobject *ovs_netdev_get_kobj(const struct vport *vport) -{ - const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); - return &netdev_vport->dev->NETDEV_DEV_MEMBER.kobj; -} - -unsigned ovs_netdev_get_dev_flags(const struct vport *vport) -{ - const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); - return dev_get_flags(netdev_vport->dev); -} - -int ovs_netdev_is_running(const struct vport *vport) -{ - const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); - return netif_running(netdev_vport->dev); -} - -unsigned char ovs_netdev_get_operstate(const struct vport *vport) -{ - const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); - return netdev_vport->dev->operstate; -} - int ovs_netdev_get_ifindex(const struct vport *vport) { const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); return netdev_vport->dev->ifindex; } -int ovs_netdev_get_mtu(const struct vport *vport) -{ - const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); - return netdev_vport->dev->mtu; -} - /* Must be called with rcu_read_lock. */ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) { @@ -273,9 +249,9 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) ovs_vport_receive(vport, skb); } -static unsigned packet_length(const struct sk_buff *skb) +static unsigned int packet_length(const struct sk_buff *skb) { - unsigned length = skb->len - ETH_HLEN; + unsigned int length = skb->len - ETH_HLEN; if (skb->protocol == htons(ETH_P_8021Q)) length -= VLAN_HLEN; @@ -303,9 +279,9 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) int len; if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) { - if (net_ratelimit()) - pr_warn("%s: dropped over-mtu packet: %d > %d\n", - ovs_dp_name(vport->dp), packet_length(skb), mtu); + net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n", + netdev_vport->dev->name, + packet_length(skb), mtu); goto error; } @@ -409,21 +385,25 @@ const struct vport_ops ovs_netdev_vport_ops = { .set_addr = ovs_netdev_set_addr, .get_name = ovs_netdev_get_name, .get_addr = ovs_netdev_get_addr, - .get_kobj = ovs_netdev_get_kobj, - .get_dev_flags = ovs_netdev_get_dev_flags, - .is_running = ovs_netdev_is_running, - .get_operstate = ovs_netdev_get_operstate, .get_ifindex = ovs_netdev_get_ifindex, - .get_mtu = ovs_netdev_get_mtu, .send = netdev_send, }; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) /* - * In kernels earlier than 2.6.36, Open vSwitch cannot safely coexist with the - * Linux bridge module, because there is only a single bridge hook function and - * only a single br_port member in struct net_device, so this prevents loading - * both bridge and openvswitch at the same time. + * Enforces, mutual exclusion with the Linux bridge module, by declaring and + * exporting br_should_route_hook. Because the bridge module also exports the + * same symbol, the module loader will refuse to load both modules at the same + * time (e.g. "bridge: exports duplicate symbol br_should_route_hook (owned by + * openvswitch)"). + * + * Before Linux 2.6.36, Open vSwitch cannot safely coexist with the Linux + * bridge module, so openvswitch uses this macro in those versions. In + * Linux 2.6.36 and later, Open vSwitch can coexist with the bridge module. + * + * The use of "typeof" here avoids the need to track changes in the type of + * br_should_route_hook over various kernel versions. */ -BRIDGE_MUTUAL_EXCLUSION; +typeof(br_should_route_hook) br_should_route_hook; +EXPORT_SYMBOL(br_should_route_hook); #endif