Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62b9c8d0 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller
Browse files

ovs: Turn vports with dependencies into separate modules



The internal and netdev vport remain part of openvswitch.ko. Encap
vports including vxlan, gre, and geneve can be built as separate
modules and are loaded on demand. Modules can be unloaded after use.
Datapath ports keep a reference to the vport module during their
lifetime.

Allows to remove the error prone maintenance of the global list
vport_ops_list.

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cf7b2003
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -29,11 +29,11 @@ config OPENVSWITCH
	  If unsure, say N.

config OPENVSWITCH_GRE
	bool "Open vSwitch GRE tunneling support"
	tristate "Open vSwitch GRE tunneling support"
	depends on INET
	depends on OPENVSWITCH
	depends on NET_IPGRE_DEMUX && !(OPENVSWITCH=y && NET_IPGRE_DEMUX=m)
	default y
	depends on NET_IPGRE_DEMUX
	default OPENVSWITCH
	---help---
	  If you say Y here, then the Open vSwitch will be able create GRE
	  vport.
@@ -43,11 +43,11 @@ config OPENVSWITCH_GRE
	  If unsure, say Y.

config OPENVSWITCH_VXLAN
	bool "Open vSwitch VXLAN tunneling support"
	tristate "Open vSwitch VXLAN tunneling support"
	depends on INET
	depends on OPENVSWITCH
	depends on VXLAN && !(OPENVSWITCH=y && VXLAN=m)
	default y
	depends on VXLAN
	default OPENVSWITCH
	---help---
	  If you say Y here, then the Open vSwitch will be able create vxlan vport.

@@ -56,11 +56,11 @@ config OPENVSWITCH_VXLAN
	  If unsure, say Y.

config OPENVSWITCH_GENEVE
	bool "Open vSwitch Geneve tunneling support"
	tristate "Open vSwitch Geneve tunneling support"
	depends on INET
	depends on OPENVSWITCH
	depends on GENEVE && !(OPENVSWITCH=y && GENEVE=m)
	default y
	depends on GENEVE
	default OPENVSWITCH
	---help---
	  If you say Y here, then the Open vSwitch will be able create geneve vport.

+3 −11
Original line number Diff line number Diff line
@@ -15,14 +15,6 @@ openvswitch-y := \
	vport-internal_dev.o \
	vport-netdev.o

ifneq ($(CONFIG_OPENVSWITCH_GENEVE),)
openvswitch-y += vport-geneve.o
endif

ifneq ($(CONFIG_OPENVSWITCH_VXLAN),)
openvswitch-y += vport-vxlan.o
endif

ifneq ($(CONFIG_OPENVSWITCH_GRE),)
openvswitch-y += vport-gre.o
endif
obj-$(CONFIG_OPENVSWITCH_GENEVE)+= vport-geneve.o
obj-$(CONFIG_OPENVSWITCH_VXLAN)	+= vport-vxlan.o
obj-$(CONFIG_OPENVSWITCH_GRE)	+= vport-gre.o
+14 −2
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@
#include "vport-netdev.h"

int ovs_net_id __read_mostly;
EXPORT_SYMBOL(ovs_net_id);

static struct genl_family dp_packet_genl_family;
static struct genl_family dp_flow_genl_family;
@@ -1764,6 +1765,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
		return -ENOMEM;

	ovs_lock();
restart:
	dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
	err = -ENODEV;
	if (!dp)
@@ -1795,8 +1797,11 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)

	vport = new_vport(&parms);
	err = PTR_ERR(vport);
	if (IS_ERR(vport))
	if (IS_ERR(vport)) {
		if (err == -EAGAIN)
			goto restart;
		goto exit_unlock_free;
	}

	err = ovs_vport_cmd_fill_info(vport, reply, info->snd_portid,
				      info->snd_seq, 0, OVS_VPORT_CMD_NEW);
@@ -2112,12 +2117,18 @@ static int __init dp_init(void)
	if (err)
		goto error_netns_exit;

	err = ovs_netdev_init();
	if (err)
		goto error_unreg_notifier;

	err = dp_register_genl();
	if (err < 0)
		goto error_unreg_notifier;
		goto error_unreg_netdev;

	return 0;

error_unreg_netdev:
	ovs_netdev_exit();
error_unreg_notifier:
	unregister_netdevice_notifier(&ovs_dp_device_notifier);
error_netns_exit:
@@ -2137,6 +2148,7 @@ static int __init dp_init(void)
static void dp_cleanup(void)
{
	dp_unregister_genl(ARRAY_SIZE(dp_genl_families));
	ovs_netdev_exit();
	unregister_netdevice_notifier(&ovs_dp_device_notifier);
	unregister_pernet_device(&ovs_net_ops);
	rcu_barrier();
+22 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/rculist.h>
#include <linux/udp.h>
#include <linux/if_vlan.h>
#include <linux/module.h>

#include <net/geneve.h>
#include <net/icmp.h>
@@ -28,6 +29,8 @@
#include "datapath.h"
#include "vport.h"

static struct vport_ops ovs_geneve_vport_ops;

/**
 * struct geneve_port - Keeps track of open UDP ports
 * @gs: The socket created for this port number.
@@ -225,11 +228,29 @@ static const char *geneve_get_name(const struct vport *vport)
	return geneve_port->name;
}

const struct vport_ops ovs_geneve_vport_ops = {
static struct vport_ops ovs_geneve_vport_ops = {
	.type		= OVS_VPORT_TYPE_GENEVE,
	.create		= geneve_tnl_create,
	.destroy	= geneve_tnl_destroy,
	.get_name	= geneve_get_name,
	.get_options	= geneve_get_options,
	.send		= geneve_tnl_send,
	.owner          = THIS_MODULE,
};

static int __init ovs_geneve_tnl_init(void)
{
	return ovs_vport_ops_register(&ovs_geneve_vport_ops);
}

static void __exit ovs_geneve_tnl_exit(void)
{
	ovs_vport_ops_unregister(&ovs_geneve_vport_ops);
}

module_init(ovs_geneve_tnl_init);
module_exit(ovs_geneve_tnl_exit);

MODULE_DESCRIPTION("OVS: Geneve swiching port");
MODULE_LICENSE("GPL");
MODULE_ALIAS("vport-type-5");
+22 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <linux/jhash.h>
#include <linux/list.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/workqueue.h>
#include <linux/rculist.h>
#include <net/route.h>
@@ -45,6 +46,8 @@
#include "datapath.h"
#include "vport.h"

static struct vport_ops ovs_gre_vport_ops;

/* Returns the least-significant 32 bits of a __be64. */
static __be32 be64_get_low32(__be64 x)
{
@@ -281,10 +284,28 @@ static void gre_tnl_destroy(struct vport *vport)
	gre_exit();
}

const struct vport_ops ovs_gre_vport_ops = {
static struct vport_ops ovs_gre_vport_ops = {
	.type		= OVS_VPORT_TYPE_GRE,
	.create		= gre_create,
	.destroy	= gre_tnl_destroy,
	.get_name	= gre_get_name,
	.send		= gre_tnl_send,
	.owner		= THIS_MODULE,
};

static int __init ovs_gre_tnl_init(void)
{
	return ovs_vport_ops_register(&ovs_gre_vport_ops);
}

static void __exit ovs_gre_tnl_exit(void)
{
	ovs_vport_ops_unregister(&ovs_gre_vport_ops);
}

module_init(ovs_gre_tnl_init);
module_exit(ovs_gre_tnl_exit);

MODULE_DESCRIPTION("OVS: GRE switching port");
MODULE_LICENSE("GPL");
MODULE_ALIAS("vport-type-3");
Loading