datapath: Backport: openvswitch: properly refcount vport-vxlan module
authorPravin B Shelar <pshelar@nicira.com>
Tue, 8 Dec 2015 02:23:19 +0000 (18:23 -0800)
committerPravin B Shelar <pshelar@nicira.com>
Tue, 8 Dec 2015 17:48:22 +0000 (09:48 -0800)
Upstream commit:
    After 614732eaa12d, 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: 614732eaa12d ("openvswitch: Use regular VXLAN net_device device")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 83e4bf7a74 ("openvswitch: properly refcount vport-vxlan
module").
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@kernel.org>
datapath/vport-geneve.c
datapath/vport-gre.c
datapath/vport-lisp.c
datapath/vport-stt.c
datapath/vport.c
datapath/vport.h

index 3b5c1ab..392d750 100644 (file)
@@ -129,7 +129,6 @@ static struct vport_ops ovs_geneve_vport_ops = {
        .destroy        = ovs_netdev_tunnel_destroy,
        .get_options    = geneve_get_options,
        .send           = geneve_xmit,
-       .owner          = THIS_MODULE,
        .get_egress_tun_info    = geneve_get_egress_tun_info,
 };
 
index a9ac0d4..50aaba5 100644 (file)
@@ -97,7 +97,6 @@ static struct vport_ops ovs_gre_vport_ops = {
        .send           = gre_fb_xmit,
        .get_egress_tun_info    = gre_get_egress_tun_info,
        .destroy        = ovs_netdev_tunnel_destroy,
-       .owner          = THIS_MODULE,
 };
 
 static int __init ovs_gre_tnl_init(void)
index e6c00fa..3ce8613 100644 (file)
@@ -129,7 +129,6 @@ static struct vport_ops ovs_lisp_vport_ops = {
        .destroy        = ovs_netdev_tunnel_destroy,
        .get_options    = lisp_get_options,
        .send           = lisp_xmit,
-       .owner          = THIS_MODULE,
        .get_egress_tun_info    = lisp_get_egress_tun_info,
 };
 
index 9e2079a..b8e0c88 100644 (file)
@@ -131,7 +131,6 @@ static struct vport_ops ovs_stt_vport_ops = {
        .destroy        = ovs_netdev_tunnel_destroy,
        .get_options    = stt_get_options,
        .send           = ovs_stt_xmit,
-       .owner          = THIS_MODULE,
        .get_egress_tun_info    = stt_get_egress_tun_info,
 };
 
index 899119f..01702d7 100644 (file)
@@ -113,7 +113,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;
@@ -129,7 +129,7 @@ errout:
        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)
 {
index d820719..33c3935 100644 (file)
@@ -212,7 +212,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,