Commit e7c8ab84 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

openvswitch: add net device refcount tracker to struct vport

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e4b89540
...@@ -82,7 +82,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name) ...@@ -82,7 +82,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
err = -ENODEV; err = -ENODEV;
goto error_free_vport; goto error_free_vport;
} }
netdev_tracker_alloc(vport->dev, &vport->dev_tracker, GFP_KERNEL);
if (vport->dev->flags & IFF_LOOPBACK || if (vport->dev->flags & IFF_LOOPBACK ||
(vport->dev->type != ARPHRD_ETHER && (vport->dev->type != ARPHRD_ETHER &&
vport->dev->type != ARPHRD_NONE) || vport->dev->type != ARPHRD_NONE) ||
...@@ -115,7 +115,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name) ...@@ -115,7 +115,7 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
error_unlock: error_unlock:
rtnl_unlock(); rtnl_unlock();
error_put: error_put:
dev_put(vport->dev); dev_put_track(vport->dev, &vport->dev_tracker);
error_free_vport: error_free_vport:
ovs_vport_free(vport); ovs_vport_free(vport);
return ERR_PTR(err); return ERR_PTR(err);
...@@ -137,7 +137,7 @@ static void vport_netdev_free(struct rcu_head *rcu) ...@@ -137,7 +137,7 @@ static void vport_netdev_free(struct rcu_head *rcu)
{ {
struct vport *vport = container_of(rcu, struct vport, rcu); struct vport *vport = container_of(rcu, struct vport, rcu);
dev_put(vport->dev); dev_put_track(vport->dev, &vport->dev_tracker);
ovs_vport_free(vport); ovs_vport_free(vport);
} }
...@@ -173,7 +173,7 @@ void ovs_netdev_tunnel_destroy(struct vport *vport) ...@@ -173,7 +173,7 @@ void ovs_netdev_tunnel_destroy(struct vport *vport)
*/ */
if (vport->dev->reg_state == NETREG_REGISTERED) if (vport->dev->reg_state == NETREG_REGISTERED)
rtnl_delete_link(vport->dev); rtnl_delete_link(vport->dev);
dev_put(vport->dev); dev_put_track(vport->dev, &vport->dev_tracker);
vport->dev = NULL; vport->dev = NULL;
rtnl_unlock(); rtnl_unlock();
......
...@@ -58,6 +58,7 @@ struct vport_portids { ...@@ -58,6 +58,7 @@ struct vport_portids {
/** /**
* struct vport - one port within a datapath * struct vport - one port within a datapath
* @dev: Pointer to net_device. * @dev: Pointer to net_device.
* @dev_tracker: refcount tracker for @dev reference
* @dp: Datapath to which this port belongs. * @dp: Datapath to which this port belongs.
* @upcall_portids: RCU protected 'struct vport_portids'. * @upcall_portids: RCU protected 'struct vport_portids'.
* @port_no: Index into @dp's @ports array. * @port_no: Index into @dp's @ports array.
...@@ -69,6 +70,7 @@ struct vport_portids { ...@@ -69,6 +70,7 @@ struct vport_portids {
*/ */
struct vport { struct vport {
struct net_device *dev; struct net_device *dev;
netdevice_tracker dev_tracker;
struct datapath *dp; struct datapath *dp;
struct vport_portids __rcu *upcall_portids; struct vport_portids __rcu *upcall_portids;
u16 port_no; u16 port_no;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment