From 8e4e1713e4978447c5f799aa668dcc6d2cb0dee9 Mon Sep 17 00:00:00 2001 From: Pravin B Shelar Date: Mon, 15 Apr 2013 13:23:03 -0700 Subject: openvswitch: Simplify datapath locking. Currently OVS uses combination of genl and rtnl lock to protect datapath state. This was done due to networking stack locking. But this has complicated locking and there are few lock ordering issues with new tunneling protocols. Following patch simplifies locking by introducing new ovs mutex and now this lock is used to protect entire ovs state. Signed-off-by: Pravin B Shelar Signed-off-by: Jesse Gross --- net/openvswitch/vport-netdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'net/openvswitch/vport-netdev.c') diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 2130d61c384..40a89ae8e19 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -100,16 +100,20 @@ static struct vport *netdev_create(const struct vport_parms *parms) goto error_put; } + rtnl_lock(); err = netdev_rx_handler_register(netdev_vport->dev, netdev_frame_hook, vport); if (err) - goto error_put; + goto error_unlock; dev_set_promiscuity(netdev_vport->dev, 1); netdev_vport->dev->priv_flags |= IFF_OVS_DATAPATH; + rtnl_unlock(); return vport; +error_unlock: + rtnl_unlock(); error_put: dev_put(netdev_vport->dev); error_free_vport: @@ -131,9 +135,11 @@ static void netdev_destroy(struct vport *vport) { struct netdev_vport *netdev_vport = netdev_vport_priv(vport); + rtnl_lock(); netdev_vport->dev->priv_flags &= ~IFF_OVS_DATAPATH; netdev_rx_handler_unregister(netdev_vport->dev); dev_set_promiscuity(netdev_vport->dev, -1); + rtnl_unlock(); call_rcu(&netdev_vport->rcu, free_port_rcu); } -- cgit v1.2.3-70-g09d2 From cff63a52924c6a78fa525c67d81480c85736ff3c Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Mon, 29 Apr 2013 13:06:41 +0000 Subject: openvswitch: Remove unneeded ovs_netdev_get_ifindex() The only user is get_dpifindex(), no need to redirect via the port operations. Signed-off-by: Thomas Graf Signed-off-by: David S. Miller --- net/openvswitch/datapath.c | 3 ++- net/openvswitch/vport-internal_dev.c | 1 - net/openvswitch/vport-netdev.c | 7 ------- net/openvswitch/vport-netdev.h | 1 - net/openvswitch/vport.h | 2 -- 5 files changed, 2 insertions(+), 12 deletions(-) (limited to 'net/openvswitch/vport-netdev.c') diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 74a5fe6feae..d12d6b8b5e8 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -56,6 +56,7 @@ #include "datapath.h" #include "flow.h" #include "vport-internal_dev.h" +#include "vport-netdev.h" #define REHASH_FLOW_INTERVAL (10 * 60 * HZ) @@ -151,7 +152,7 @@ static int get_dpifindex(struct datapath *dp) local = ovs_vport_rcu(dp, OVSP_LOCAL); if (local) - ifindex = local->ops->get_ifindex(local); + ifindex = netdev_vport_priv(local)->dev->ifindex; else ifindex = 0; diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c index 73682de8dc6..84e0a037918 100644 --- a/net/openvswitch/vport-internal_dev.c +++ b/net/openvswitch/vport-internal_dev.c @@ -232,7 +232,6 @@ const struct vport_ops ovs_internal_vport_ops = { .create = internal_dev_create, .destroy = internal_dev_destroy, .get_name = ovs_netdev_get_name, - .get_ifindex = ovs_netdev_get_ifindex, .send = internal_dev_recv, }; diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 40a89ae8e19..4f01c6d2ffa 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -150,12 +150,6 @@ const char *ovs_netdev_get_name(const struct vport *vport) return netdev_vport->dev->name; } -int ovs_netdev_get_ifindex(const struct vport *vport) -{ - const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); - return netdev_vport->dev->ifindex; -} - static unsigned int packet_length(const struct sk_buff *skb) { unsigned int length = skb->len - ETH_HLEN; @@ -206,6 +200,5 @@ const struct vport_ops ovs_netdev_vport_ops = { .create = netdev_create, .destroy = netdev_destroy, .get_name = ovs_netdev_get_name, - .get_ifindex = ovs_netdev_get_ifindex, .send = netdev_send, }; diff --git a/net/openvswitch/vport-netdev.h b/net/openvswitch/vport-netdev.h index 6478079b341..a3cb3a32cd7 100644 --- a/net/openvswitch/vport-netdev.h +++ b/net/openvswitch/vport-netdev.h @@ -40,6 +40,5 @@ netdev_vport_priv(const struct vport *vport) const char *ovs_netdev_get_name(const struct vport *); const char *ovs_netdev_get_config(const struct vport *); -int ovs_netdev_get_ifindex(const struct vport *); #endif /* vport_netdev.h */ diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h index 7ba08c30b85..68a377bc084 100644 --- a/net/openvswitch/vport.h +++ b/net/openvswitch/vport.h @@ -124,7 +124,6 @@ struct vport_parms { * have any configuration. * @get_name: Get the device's name. * @get_config: Get the device's configuration. - * @get_ifindex: Get the system interface index associated with the device. * May be null if the device does not have an ifindex. * @send: Send a packet on the device. Returns the length of the packet sent. */ @@ -141,7 +140,6 @@ struct vport_ops { /* Called with rcu_read_lock or ovs_mutex. */ const char *(*get_name)(const struct vport *); void (*get_config)(const struct vport *, void *); - int (*get_ifindex)(const struct vport *); int (*send)(struct vport *, struct sk_buff *); }; -- cgit v1.2.3-70-g09d2