Skip to content

Commit

Permalink
openvswitch: properly refcount vport-vxlan module
Browse files Browse the repository at this point in the history
After 614732e, no refcount is maintained for the vport-vxlan module.
This allows the userspace to remove such module while vport-vxlan
devices still exist, which leads to later oops.

v1 -> v2:
 - move vport 'owner' initialization in ovs_vport_ops_register()
   and make such function a macro

Fixes: 614732e ("openvswitch: Use regular VXLAN net_device device")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Paolo Abeni authored and David S. Miller committed Dec 2, 2015
1 parent fbca9d2 commit 83e4bf7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion net/openvswitch/vport-geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ static struct vport_ops ovs_geneve_vport_ops = {
.destroy = ovs_netdev_tunnel_destroy,
.get_options = geneve_get_options,
.send = dev_queue_xmit,
.owner = THIS_MODULE,
};

static int __init ovs_geneve_tnl_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/openvswitch/vport-gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ static struct vport_ops ovs_gre_vport_ops = {
.create = gre_create,
.send = dev_queue_xmit,
.destroy = ovs_netdev_tunnel_destroy,
.owner = THIS_MODULE,
};

static int __init ovs_gre_tnl_init(void)
Expand Down
4 changes: 2 additions & 2 deletions net/openvswitch/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static struct hlist_head *hash_bucket(const struct net *net, const char *name)
return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
}

int ovs_vport_ops_register(struct vport_ops *ops)
int __ovs_vport_ops_register(struct vport_ops *ops)
{
int err = -EEXIST;
struct vport_ops *o;
Expand All @@ -87,7 +87,7 @@ int ovs_vport_ops_register(struct vport_ops *ops)
ovs_unlock();
return err;
}
EXPORT_SYMBOL_GPL(ovs_vport_ops_register);
EXPORT_SYMBOL_GPL(__ovs_vport_ops_register);

void ovs_vport_ops_unregister(struct vport_ops *ops)
{
Expand Down
8 changes: 7 additions & 1 deletion net/openvswitch/vport.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ static inline const char *ovs_vport_name(struct vport *vport)
return vport->dev->name;
}

int ovs_vport_ops_register(struct vport_ops *ops);
int __ovs_vport_ops_register(struct vport_ops *ops);
#define ovs_vport_ops_register(ops) \
({ \
(ops)->owner = THIS_MODULE; \
__ovs_vport_ops_register(ops); \
})

void ovs_vport_ops_unregister(struct vport_ops *ops);

static inline struct rtable *ovs_tunnel_route_lookup(struct net *net,
Expand Down

0 comments on commit 83e4bf7

Please sign in to comment.