openvswitch: remove support for legacy tunnel ports
Subsystems (5)
Ilya Maximets
maintainercover openvswitch: remove support for legacy tunnel ports
ovs-vswitchd doesn't use OVS_VPORT_TYPE_GRE/VXLAN/GENEVE with the Linux kernel module since adding support for standard tunnel devices with COLLECT_METADATA back in 2017. The code to use them was only activated as a fallback for old kernels, so not used in practice. And it is now fully removed in the upcoming OVS 4.0 release.
Modern way to use tunnels with OVS is to create standard tunnel ports with RTM_NEWLINK + COLLECT_METADATA and add them as OVS_VPORT_TYPE_NETDEV.
Device reference management and the netlink options parsing for these legacy port types is complicated and was a CVE magnet in the previous release cycles. Existence of these modules also makes locking analysis for geneve module and other core tunnel devices unnecessarily more complicated, especially in light of migration to per-netns locking:
https://lore.kernel.org/r/CAAVpQUDmZEaQNDSySLayqexgTrUbhBaL7XPCt9XNQzh+NGQ=UQ@mail.gmail.com
Since there are no actual users for these port types for a very long time, let's just remove the support entirely. There is no practical reason to run OVS from 2017 on a recent kernel.
While it's technically a uAPI change in some sense, from the user's perspective this removal looks indistinguishable from the kernel built with CONFIG_OPENVSWITCH_GENEVE/VXLAN/GRE disabled. And it seems like removal of unused drivers/modules is not a rare event these days.
There are 3 parts to this set:
1. The first patch does the tunnel port removal, which is the primary goal here.
2. Patches 2 and 3 remove extra infrastructure that is no longer in use by anything inside the openvswitch module.
3. Patches 4-6 remove functions from gre/vxlan/geneve modules that were added for openvswitch in the past to support the tunnel types. openvswitch is the only in-tree consumer of these functions.
Version 1:
- Rebased.
- Removed the tunnel modules from the new OVS selftest config.
- Addressed RFC review from Sashiko:
* Made ovs_netdev_link() static.
* Restored -EOPNOTSUPP if OVS_VPORT_ATTR_OPTIONS was provided.
* Removed retry in ovs_vport_cmd_new() as not needed anymore.
RFC:
- https://lore.kernel.org/r/[email protected]
Ilya Maximets (6):
openvswitch: remove support for legacy tunnel types
openvswitch: vport: remove infrastructure for vport options
openvswitch: vport: remove infrastructure for separate modules
net: geneve: remove unused geneve_dev_create_fb
net: gre: remove unused gretap_fb_dev_create
net: vxlan: remove unused vxlan_dev_create
drivers/net/geneve.c | 49 ----- drivers/net/vxlan/vxlan_core.c | 42 +---- include/net/geneve.h | 5 - include/net/gre.h | 2 - include/net/vxlan.h | 3 - include/uapi/linux/openvswitch.h | 31 +++- net/ipv4/ip_gre.c | 47 ----- net/openvswitch/Kconfig | 35 ---- net/openvswitch/Makefile | 4 - net/openvswitch/datapath.c | 28 +-- net/openvswitch/vport-geneve.c | 143 --------------- net/openvswitch/vport-gre.c | 106 ----------- net/openvswitch/vport-netdev.c | 29 +-- net/openvswitch/vport-netdev.h | 2 - net/openvswitch/vport-vxlan.c | 172 ------------------ net/openvswitch/vport.c | 79 +------- net/openvswitch/vport.h | 23 +-- tools/testing/selftests/net/config | 3 - .../testing/selftests/net/openvswitch/config | 3 - .../selftests/net/openvswitch/openvswitch.sh | 38 ---- .../selftests/net/openvswitch/ovs-dpctl.py | 93 +++------- 21 files changed, 63 insertions(+), 874 deletions(-) delete mode 100644 net/openvswitch/vport-geneve.c delete mode 100644 net/openvswitch/vport-gre.c delete mode 100644 net/openvswitch/vport-vxlan.c
Signature · 1 line
2.55.0
Ilya Maximets
maintainerPATCH 1/6 openvswitch: remove support for legacy tunnel types
ovs-vswitchd doesn't use OVS_VPORT_TYPE_GRE/VXLAN/GENEVE with the Linux kernel module since adding support for standard tunnel devices with COLLECT_METADATA back in 2017. The code to use them was only activated as a fallback for old kernels, so not used in practice. And it is now fully removed in the upcoming OVS 4.0 release.
Modern way to use tunnels with OVS is to create standard tunnel ports with RTM_NEWLINK + COLLECT_METADATA and add them as OVS_VPORT_TYPE_NETDEV.
Device reference management and the netlink options parsing for these legacy port types is complicated and was a CVE magnet in the previous release cycles. Existence of these modules also makes locking analysis for geneve module and other core tunnel devices unnecessarily more complicated, especially in light of migration to per-netns locking.
Since there are no actual users for these port types for a very long time, let's just remove the support entirely. There is no practical reason to run OVS from 2017 on a recent kernel.
While it's technically a uAPI change in some sense, from the user's perspective this removal looks indistinguishable from the kernel built with CONFIG_OPENVSWITCH_GENEVE/VXLAN/GRE disabled. And it seems like removal of unused drivers/modules is not a rare event these days.
A comment is added to the uAPI header noting that standard RTM_NEWLINK with COLLECT_METADATA followed by OVS_VPORT_CMD_NEW with the simple OVS_VPORT_TYPE_NETDEV should be used instead.
Modules responsible for these tunnel ports are removed as well as selftests covering this functionality. Further cleanups will follow.
--- include/uapi/linux/openvswitch.h | 31 +++- net/openvswitch/Kconfig | 35 ---- net/openvswitch/Makefile | 4 - net/openvswitch/datapath.c | 6 +- net/openvswitch/vport-geneve.c | 143 --------------- net/openvswitch/vport-gre.c | 106 ----------- net/openvswitch/vport-netdev.c | 29 +-- net/openvswitch/vport-netdev.h | 2 - net/openvswitch/vport-vxlan.c | 172 ------------------ tools/testing/selftests/net/config | 3 - .../testing/selftests/net/openvswitch/config | 3 - .../selftests/net/openvswitch/openvswitch.sh | 38 ---- .../selftests/net/openvswitch/ovs-dpctl.py | 93 +++------- 13 files changed, 52 insertions(+), 613 deletions(-) delete mode 100644 net/openvswitch/vport-geneve.c delete mode 100644 net/openvswitch/vport-gre.c delete mode 100644 net/openvswitch/vport-vxlan.c
include/uapi/linux/openvswitch.h +26 -5
@@ -244,13 +244,33 @@ enum ovs_vport_cmd { OVS_VPORT_CMD_SET }; +/** +* enum ovs_vport_type - OVS vport types for %OVS_VPORT_ATTR_TYPE. +* @OVS_VPORT_TYPE_NETDEV: Existing network device attached as a vport. +* @OVS_VPORT_TYPE_INTERNAL: Network device implemented by the OVS datapath. +* @OVS_VPORT_TYPE_GRE: Legacy GRE tunnel. Not supported, see below. +* @OVS_VPORT_TYPE_VXLAN: Legacy VXLAN tunnel. Not supported, see below. +* @OVS_VPORT_TYPE_GENEVE: Legacy Geneve tunnel. Not supported, see below. +* +* The tunnel vport types are not supported. Instead, create the tunnel device +* using %RTM_NEWLINK with the appropriate %IFLA_INFO_KIND (e.g. ``gre``, +* ``gretap``, ``vxlan``, ``geneve``, or other tunnel types) and add it as +* %OVS_VPORT_TYPE_NETDEV. To match and set tunnel parameters on a per-flow +* basis, the tunnel device should collect metadata. To do that, some tunnel +* types require an explicit flag such as %IFLA_VXLAN_COLLECT_METADATA for +* ``vxlan``, while others such as ``bareudp`` collect metadata +* unconditionally. +*/ enum ovs_vport_type { +/* private: */ OVS_VPORT_TYPE_UNSPEC , +/* public: */ OVS_VPORT_TYPE_NETDEV ,/* network device */ OVS_VPORT_TYPE_INTERNAL ,/* network device implemented by datapath */ -OVS_VPORT_TYPE_GRE ,/* GRE tunnel. */ -OVS_VPORT_TYPE_VXLAN ,/* VXLAN tunnel. */ -OVS_VPORT_TYPE_GENEVE ,/* Geneve tunnel. */ +OVS_VPORT_TYPE_GRE ,/* GRE tunnel (legacy, not supported). */ +OVS_VPORT_TYPE_VXLAN ,/* VXLAN tunnel (legacy, not supported). */ +OVS_VPORT_TYPE_GENEVE ,/* Geneve tunnel (legacy, not supported). */ +/* private: */ __OVS_VPORT_TYPE_MAX };
@@ -284,7 +304,7 @@ enum ovs_vport_type {* %OVS_VPORT_ATTR_NAME attributes are required. %OVS_VPORT_ATTR_PORT_NO is * optional; if not specified a free port number is automatically selected. * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type -* of vport. +* of vport. None of currently supported vport types support options. * * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to * look up the vport to operate on; otherwise dp_idx from the &struct
@@ -336,7 +356,8 @@ enum {#define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1) -/* OVS_VPORT_ATTR_OPTIONS attributes for tunnels. +/* OVS_VPORT_ATTR_OPTIONS attributes for legacy tunnel vports. +* Not supported, see the note for enum ovs_vport_type. */ enum {OVS_TUNNEL_ATTR_UNSPEC ,
net/openvswitch/Kconfig +0 -35
@@ -40,38 +40,3 @@ config OPENVSWITCH called openvswitch. If unsure, say N. - -config OPENVSWITCH_GRE - tristate "Open vSwitch GRE tunneling support" - depends on OPENVSWITCH - depends on NET_IPGRE - default OPENVSWITCH - help - If you say Y here, then the Open vSwitch will be able create GRE - vport. - - Say N to exclude this support and reduce the binary size. - - If unsure, say Y. - -config OPENVSWITCH_VXLAN - tristate "Open vSwitch VXLAN tunneling support" - depends on OPENVSWITCH - depends on VXLAN - default OPENVSWITCH - help - If you say Y here, then the Open vSwitch will be able create vxlan vport. - - Say N to exclude this support and reduce the binary size. - - If unsure, say Y. - -config OPENVSWITCH_GENEVE - tristate "Open vSwitch Geneve tunneling support" - depends on OPENVSWITCH - depends on GENEVE - default OPENVSWITCH - help - If you say Y here, then the Open vSwitch will be able create geneve vport. - - Say N to exclude this support and reduce the binary size.
net/openvswitch/Makefile +0 -4
@@ -22,8 +22,4 @@ ifneq ($(CONFIG_NF_CONNTRACK),) openvswitch-y += conntrack.o endif -obj-$(CONFIG_OPENVSWITCH_VXLAN)+= vport-vxlan.o -obj-$(CONFIG_OPENVSWITCH_GENEVE)+= vport-geneve.o -obj-$(CONFIG_OPENVSWITCH_GRE) += vport-gre.o - CFLAGS_openvswitch_trace.o = -I$(src)
net/openvswitch/datapath.c +2 -4
@@ -2210,11 +2210,9 @@ static size_t ovs_vport_cmd_msg_size(void)/* OVS_VPORT_ATTR_UPCALL_PID */ msgsize +=nla_total_size (nr_cpu_ids *sizeof (u32)); -/* OVS_VPORT_ATTR_OPTIONS(OVS_TUNNEL_ATTR_DST_PORT + -* OVS_TUNNEL_ATTR_EXTENSION(OVS_VXLAN_EXT_GBP)) +/* There are no vports supporting OVS_VPORT_ATTR_OPTIONS, so it is +* not included in the message size calculation. */ - msgsize +=nla_total_size (nla_total_size (sizeof (u16)) + -nla_total_size (nla_total_size (0 )));return msgsize; }
net/openvswitch/vport-geneve.c deleted +0 -143
143 lines not on this page · raw message
net/openvswitch/vport-gre.c deleted +0 -106
106 lines not on this page · raw message
net/openvswitch/vport-netdev.c +2 -27
@@ -73,7 +73,7 @@ static struct net_device *get_dpdev(const struct datapath *dp)return local->dev; } -struct vport *ovs_netdev_link (struct vport *vport,bool tunnel) +static struct vport *ovs_netdev_link (struct vport *vport) {int err;
@@ -112,15 +112,12 @@ struct vport *ovs_netdev_link(struct vport *vport, bool tunnel) error_master_upper_dev_unlink:netdev_upper_dev_unlink (vport->dev,get_dpdev (vport->dp)); error_put_unlock: -if (tunnel && vport->dev->reg_state ==NETREG_REGISTERED ) -rtnl_delete_link (vport->dev,0 ,NULL );netdev_put (vport->dev, &vport->dev_tracker);rtnl_unlock (); error_free_vport:ovs_vport_free (vport);return ERR_PTR (err); } -EXPORT_SYMBOL_GPL (ovs_netdev_link);static struct vport *netdev_create (const struct vport_parms *parms) {
@@ -152,7 +149,7 @@ static struct vport *netdev_create(const struct vport_parms *parms) goto error_put; } -return ovs_netdev_link (vport, false); +return ovs_netdev_link (vport); error_put:netdev_put (vport->dev, &vport->dev_tracker); error_free_vport:
@@ -204,28 +201,6 @@ static void netdev_destroy(struct vport *vport)call_rcu (&vport->rcu, vport_netdev_free); } -void ovs_netdev_tunnel_destroy (struct vport *vport) -{ -rtnl_lock (); -if (netif_is_ovs_port (vport->dev)) -ovs_netdev_detach_dev (vport); - -/* We can be invoked by both explicit vport deletion and -* underlying netdev deregistration; delete the link only -* if it's not already shutting down. -*/ -if (vport->dev->reg_state ==NETREG_REGISTERED ) -rtnl_delete_link (vport->dev,0 ,NULL ); - -/* We can't put the device reference yet, since it can still be in -* use, but rtnl_unlock()->netdev_run_todo() will block until all -* the references are released, so the RCU call must be before it. -*/ -call_rcu (&vport->rcu, vport_netdev_free); -rtnl_unlock (); -} -EXPORT_SYMBOL_GPL (ovs_netdev_tunnel_destroy); -/* Returns null if this device is not attached to a datapath. */ struct vport *ovs_netdev_get_vport (struct net_device *dev) {
net/openvswitch/vport-netdev.h +0 -2
@@ -13,11 +13,9 @@struct vport *ovs_netdev_get_vport (struct net_device *dev); -struct vport *ovs_netdev_link (struct vport *vport,bool tunnel);void ovs_netdev_detach_dev (struct vport *);int __init ovs_netdev_init (void );void ovs_netdev_exit (void ); -void ovs_netdev_tunnel_destroy (struct vport *vport);#endif /* vport_netdev.h */
net/openvswitch/vport-vxlan.c deleted +0 -172
172 lines not on this page · raw message
tools/testing/selftests/net/config +0 -3
@@ -117,9 +117,6 @@ CONFIG_NFT_COMPAT=m CONFIG_NFT_NAT=m CONFIG_NUMA=y CONFIG_OPENVSWITCH=m -CONFIG_OPENVSWITCH_GENEVE=m -CONFIG_OPENVSWITCH_GRE=m -CONFIG_OPENVSWITCH_VXLAN=m CONFIG_PAGE_POOL_STATS=y CONFIG_PROC_SYSCTL=y CONFIG_PSAMPLE=m
tools/testing/selftests/net/openvswitch/config +0 -3
@@ -7,9 +7,6 @@ CONFIG_NET_IPGRE_DEMUX=m CONFIG_NF_CONNTRACK=m CONFIG_NF_CONNTRACK_OVS=y CONFIG_OPENVSWITCH=m -CONFIG_OPENVSWITCH_GENEVE=m -CONFIG_OPENVSWITCH_GRE=m -CONFIG_OPENVSWITCH_VXLAN=m CONFIG_PSAMPLE=m CONFIG_VETH=y CONFIG_VLAN_8021Q=y
tools/testing/selftests/net/openvswitch/openvswitch.sh +0 -38
@@ -26,7 +26,6 @@ tests=" netlink_checks ovsnl: validate netlink attrs and settings upcall_interfaces ovs: test the upcall interfaces tunnel_metadata ovs: test extraction of tunnel metadata - tunnel_refcount ovs: test tunnel vport reference cleanup drop_reason drop: test drop reasons are emitted pop_vlan vlan: POP_VLAN action strips tag dec_ttl ttl: dec_ttl decrements IP TTL
@@ -1210,43 +1209,6 @@ test_tunnel_metadata() { return 0 } -test_tunnel_refcount() { - sbxname="test_tunnel_refcount" - sbx_add "${sbxname}" || return 1 - - ovs_sbx "${sbxname}" ip netns add trefns || return 1 - on_exit "ovs_sbx ${sbxname} ip netns del trefns" - - for tun_type in gre vxlan geneve; do - info "testing ${tun_type} tunnel vport refcount" - - ovs_sbx "${sbxname}" ip netns exec trefns \ - python3 $ovs_base/ovs-dpctl.py \ - add-dp dp-${tun_type} || return 1 - - ovs_sbx "${sbxname}" ip netns exec trefns \ - python3 $ovs_base/ovs-dpctl.py \ - add-if --no-lwt -t ${tun_type} \ - dp-${tun_type} ovs-${tun_type}0 || return 1 - - ovs_wait ip -netns trefns link show \ - ovs-${tun_type}0 >/dev/null 2>&1 || return 1 - - info "deleting dp - may hang if reference counting is broken" - ovs_sbx "${sbxname}" ip netns exec trefns \ - python3 $ovs_base/ovs-dpctl.py \ - del-dp dp-${tun_type} & - - dev_removed() { - ! ip -netns trefns link show "$1" >/dev/null 2>&1 - } - ovs_wait dev_removed dp-${tun_type} || return 1 - ovs_wait dev_removed ovs-${tun_type}0 || return 1 - done - - return 0 -} - test_pop_vlan() { local sbx="test_pop_vlan" sbx_add "$sbx" || return $?
tools/testing/selftests/net/openvswitch/ovs-dpctl.py +22 -71
167 lines not on this page · raw message
Signature · 1 line
2.55.0
Ilya Maximets
maintainerPATCH 2/6 openvswitch: vport: remove infrastructure for vport options
In reply to Ilya MaximetsSince removal of tunnel vport types, there aren't any vports that support options. Let's remove the options-related infrastructure.
Can be reinstated if we ever need a new vport type or if we need extra options for the existing ones. The uAPI attribute remains.
Clarification comment is added to highlight that none of the supported vports support options at the moment.
If the options are provided, the code now directly replies with -EOPNOTSUPP to keep the behavior the same for remaining vport types.
Note: It is technically possible that someone has an out-of-tree module named vport-type-N that implements a different vport type and they have options for this vport type. However, our message size calculations do not account for whatever options such a port would have and so it is dangerous to load such a module without modifying the code in the main datapath.c, unless the options are smaller than the ones we had for vxlan. A more robust solution would be to have a different version of the entire openvswitch module instead, so the use case of a separate vport-type-N loaded with the upstream openvswitch module is unlikely. At this time we're not aware of anyone doing that.
--- net/openvswitch/datapath.c | 20 +++----------- net/openvswitch/vport.c | 54 -------------------------------------- net/openvswitch/vport.h | 14 ---------- 3 files changed, 4 insertions(+), 84 deletions(-)
net/openvswitch/datapath.c +4 -16
@@ -1856,7 +1856,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)/* Set up our datapath device. */ parms.name =nla_data (a[OVS_DP_ATTR_NAME ]); parms.type =OVS_VPORT_TYPE_INTERNAL ; - parms.options =NULL ; parms.dp = dp; parms.port_no =OVSP_LOCAL ; parms.upcall_portids = a[OVS_DP_ATTR_UPCALL_PID ];
@@ -2172,10 +2171,6 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,if (ovs_vport_get_upcall_portids (vport, skb)) goto nla_put_failure; - err =ovs_vport_get_options (vport, skb); -if (err == -EMSGSIZE ) - goto error; -genlmsg_end (skb, ovs_header);return 0 ;
@@ -2183,7 +2178,6 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,rcu_read_unlock (); nla_put_failure: err = -EMSGSIZE ; -error:genlmsg_cancel (skb, ovs_header);return err; }
@@ -2210,10 +2204,6 @@ static size_t ovs_vport_cmd_msg_size(void)/* OVS_VPORT_ATTR_UPCALL_PID */ msgsize +=nla_total_size (nr_cpu_ids *sizeof (u32)); -/* There are no vports supporting OVS_VPORT_ATTR_OPTIONS, so it is -* not included in the message size calculation. -*/ -return msgsize; }
@@ -2365,7 +2355,6 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) } parms.name =nla_data (a[OVS_VPORT_ATTR_NAME ]); - parms.options = a[OVS_VPORT_ATTR_OPTIONS ]; parms.dp = dp; parms.port_no = port_no; parms.upcall_portids = a[OVS_VPORT_ATTR_UPCALL_PID ];
@@ -2427,12 +2416,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) }if (a[OVS_VPORT_ATTR_OPTIONS ]) { - err =ovs_vport_set_options (vport, a[OVS_VPORT_ATTR_OPTIONS ]); -if (err) - goto exit_unlock_free; +/* There are no vport types that support legacy options. */ + err = -EOPNOTSUPP ; + goto exit_unlock_free; } -if (a[OVS_VPORT_ATTR_UPCALL_PID ]) {struct nlattr *ids = a[OVS_VPORT_ATTR_UPCALL_PID ];
@@ -2606,7 +2594,7 @@ static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = { [OVS_VPORT_ATTR_PORT_NO] = { .type = NLA_U32 }, [OVS_VPORT_ATTR_TYPE] = { .type = NLA_U32 }, [OVS_VPORT_ATTR_UPCALL_PID] = { .type = NLA_UNSPEC }, - [OVS_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED }, + [OVS_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED }, /* Unused. */ [OVS_VPORT_ATTR_IFINDEX] = NLA_POLICY_MIN(NLA_S32, 0), [OVS_VPORT_ATTR_NETNSID] = { .type = NLA_S32 }, [OVS_VPORT_ATTR_UPCALL_STATS] = { .type = NLA_NESTED },
net/openvswitch/vport.c +0 -54
66 lines not on this page · raw message
net/openvswitch/vport.h +0 -14
@@ -34,9 +34,6 @@ void ovs_vport_get_stats(struct vport *, struct ovs_vport_stats *);int ovs_vport_get_upcall_stats (struct vport *vport,struct sk_buff *skb); -int ovs_vport_set_options (struct vport *,struct nlattr *options); -int ovs_vport_get_options (const struct vport *,struct sk_buff *); -int ovs_vport_set_upcall_portids (struct vport *,const struct nlattr *pids);int ovs_vport_get_upcall_portids (const struct vport *,struct sk_buff *);u32 ovs_vport_find_upcall_portid (const struct vport *,struct sk_buff *);
@@ -92,8 +89,6 @@ struct vport {* * @name: New vport's name. * @type: New vport's type. -* @options: %OVS_VPORT_ATTR_OPTIONS attribute from Netlink message, %NULL if -* none was supplied. * @desired_ifindex: New vport's ifindex. * @dp: New vport's datapath. * @port_no: New vport's port number.
@@ -104,7 +99,6 @@ struct vport_parms {const char *name;enum ovs_vport_type type;int desired_ifindex; -struct nlattr *options;/* For ovs_vport_alloc(). */ struct datapath *dp;
@@ -120,11 +114,6 @@ struct vport_parms {* a new vport allocated with ovs_vport_alloc(), otherwise an ERR_PTR() value. * @destroy: Destroys a vport. Must call vport_free() on the vport but not * before an RCU grace period has elapsed. -* @set_options: Modify the configuration of an existing vport. May be %NULL -* if modification is not supported. -* @get_options: Appends vport-specific attributes for the configuration of an -* existing vport to a &struct sk_buff. May be %NULL for a vport that does not -* have any configuration. * @send: Send a packet on the device. * zero for dropped packets or negative for error. * @owner: Module that implements this vport type.
@@ -137,9 +126,6 @@ struct vport_ops {struct vport *(*create)(const struct vport_parms *);void (*destroy)(struct vport *); -int (*set_options)(struct vport *,struct nlattr *); -int (*get_options)(const struct vport *,struct sk_buff *); -int (*send)(struct sk_buff *skb);struct module *owner;struct list_head list;
Signature · 1 line
2.55.0
Ilya Maximets
maintainerPATCH 3/6 openvswitch: vport: remove infrastructure for separate modules
In reply to Ilya MaximetsSince removal of legacy tunnel vport types only the built-in ones remain. So, there is no need for the extra infrastructure for dynamic module loading. Can be reinstated in the future if we need a new vport type.
Note: It is technically possible that someone has an out-of-tree module named vport-type-N that implements a different vport type. At this time we're not aware of anyone doing that. People running out-of-tree modules normally just have an out-of-tree openvswitch module as a whole. And there are actually no supported out-of-tree implementations of the openvswitch module known to the community.
--- net/openvswitch/datapath.c | 6 +----- net/openvswitch/vport.c | 25 +++---------------------- net/openvswitch/vport.h | 9 +-------- 3 files changed, 5 insertions(+), 35 deletions(-)
net/openvswitch/datapath.c +1 -5
@@ -2331,7 +2331,6 @@ 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)
@@ -2363,11 +2362,8 @@ 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 (err == -EAGAIN ) - goto restart; +if (IS_ERR (vport)) goto exit_unlock_free; - } err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), info->snd_portid, info->snd_seq, 0,
net/openvswitch/vport.c +3 -22
@@ -57,7 +57,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;
@@ -73,7 +73,6 @@ int __ovs_vport_ops_register(struct vport_ops *ops)ovs_unlock ();return err; } -EXPORT_SYMBOL_GPL (__ovs_vport_ops_register);void ovs_vport_ops_unregister (struct vport_ops *ops) {
@@ -81,7 +80,6 @@ void ovs_vport_ops_unregister(struct vport_ops *ops)list_del (&ops->list);ovs_unlock (); } -EXPORT_SYMBOL_GPL (ovs_vport_ops_unregister);/** * ovs_vport_locate - find a port that has already been created
@@ -210,14 +208,9 @@ struct vport *ovs_vport_add(const struct vport_parms *parms)if (ops) {struct hlist_head *bucket; -if (!try_module_get (ops->owner)) -return ERR_PTR (-EAFNOSUPPORT ); - vport = ops->create (parms); -if (IS_ERR (vport)) { -module_put (ops->owner); +if (IS_ERR (vport))return vport; - } bucket =hash_bucket (ovs_dp_get_net (vport->dp),ovs_vport_name (vport));
@@ -225,18 +218,7 @@ struct vport *ovs_vport_add(const struct vport_parms *parms)return vport; } -/* Unlock to attempt module load and return -EAGAIN if load -* was successful as we need to restart the port addition -* workflow. -*/ -ovs_unlock (); -request_module ("vport-type-%d" , parms->type); -ovs_lock (); - -if (!ovs_vport_lookup (parms)) -return ERR_PTR (-EAFNOSUPPORT ); -else -return ERR_PTR (-EAGAIN ); +return ERR_PTR (-EAFNOSUPPORT ); }/**
@@ -250,7 +232,6 @@ struct vport *ovs_vport_add(const struct vport_parms *parms)void ovs_vport_del (struct vport *vport) {hlist_del_rcu (&vport->hash_node); -module_put (vport->ops->owner); vport->ops->destroy (vport); }
net/openvswitch/vport.h +1 -8
@@ -116,7 +116,6 @@ struct vport_parms {* before an RCU grace period has elapsed. * @send: Send a packet on the device. * zero for dropped packets or negative for error. -* @owner: Module that implements this vport type. * @list: List entry in the global list of vport types. */ struct vport_ops {
@@ -127,7 +126,6 @@ struct vport_ops {void (*destroy)(struct vport *);int (*send)(struct sk_buff *skb); -struct module *owner;struct list_head list; };
@@ -191,12 +189,7 @@ static inline const char *ovs_vport_name(struct vport *vport)return vport->dev->name; } -int __ovs_vport_ops_register (struct vport_ops *ops); -#define ovs_vport_ops_register (ops) \ - ({ \ - (ops)->owner = THIS_MODULE; \ - __ovs_vport_ops_register(ops); \ - }) +int ovs_vport_ops_register (struct vport_ops *ops);void ovs_vport_ops_unregister (struct vport_ops *ops);void ovs_vport_send (struct vport *vport,struct sk_buff *skb,u8 mac_proto);
Signature · 1 line
2.55.0
Ilya Maximets
maintainerPATCH 4/6 net: geneve: remove unused geneve_dev_create_fb
In reply to Ilya MaximetsThe only user was vport-geneve in openvswitch and now it is gone.
This also removes the last exported function in geneve module, significantly reducing complexity of the locking analysis.
--- drivers/net/geneve.c | 49 -------------------------------------------- include/net/geneve.h | 5 ----- 2 files changed, 54 deletions(-)
drivers/net/geneve.c +0 -49
@@ -2670,55 +2670,6 @@ static struct rtnl_link_ops geneve_link_ops __read_mostly = { .fill_info = geneve_fill_info, }; -struct net_device *geneve_dev_create_fb (struct net *net,const char *name, -u8 name_assign_type,u16 dst_port) -{ -struct nlattr *tb[IFLA_MAX +1 ]; -struct net_device *dev; -LIST_HEAD (list_kill); -int err; -struct geneve_config cfg = { - .df =GENEVE_DF_UNSET , - .use_udp6_rx_checksums = true, - .ttl_inherit = false, - .collect_md = true, - .dualstack = true, - .port_min =1 , - .port_max =USHRT_MAX , - }; - -memset (tb,0 ,sizeof (tb)); - dev =rtnl_create_link (net, name, name_assign_type, - &geneve_link_ops, tb,NULL ); -if (IS_ERR (dev)) -return dev; - -init_tnl_info (&cfg.info, dst_port); - err =geneve_configure (net, dev,NULL , &cfg); -if (err) { -free_netdev (dev); -return ERR_PTR (err); - } - -/* openvswitch users expect packet sizes to be unrestricted, -* so set the largest MTU we can. -*/ - err =geneve_change_mtu (dev,IP_MAX_MTU ); -if (err) - goto err; - - err =rtnl_configure_link (dev,NULL ,0 ,NULL ); -if (err <0 ) - goto err; - -return dev; -err: -geneve_dellink (dev, &list_kill); -unregister_netdevice_many (&list_kill); -return ERR_PTR (err); -} -EXPORT_SYMBOL_GPL (geneve_dev_create_fb); -static int geneve_netdevice_event (struct notifier_block *unused,unsigned long event,void *ptr) {
include/net/geneve.h +0 -5
@@ -68,9 +68,4 @@ static inline bool netif_is_geneve(const struct net_device *dev) !strcmp(dev->rtnl_link_ops->kind, "geneve"); } -#ifdef CONFIG_INET -struct net_device *geneve_dev_create_fb (struct net *net,const char *name, -u8 name_assign_type,u16 dst_port); -#endif /*ifdef CONFIG_INET */ -#endif /*ifdef__NET_GENEVE_H */
Signature · 1 line
2.55.0
Ilya Maximets
maintainerPATCH 5/6 net: gre: remove unused gretap_fb_dev_create
In reply to Ilya MaximetsThe only user was vport-gre in openvswitch and now it is gone.
--- include/net/gre.h | 2 -- net/ipv4/ip_gre.c | 47 ----------------------------------------------- 2 files changed, 49 deletions(-)
include/net/gre.h +0 -2
@@ -32,8 +32,6 @@ struct gre_protocol {int gre_add_protocol (const struct gre_protocol *proto,u8 version);int gre_del_protocol (const struct gre_protocol *proto,u8 version); -struct net_device *gretap_fb_dev_create (struct net *net,const char *name, -u8 name_assign_type);int gre_parse_header (struct sk_buff *skb,struct tnl_ptk_info *tpi,bool *csum_err,__be16 proto,int nhs);
net/ipv4/ip_gre.c +0 -47
53 lines not on this page · raw message
Signature · 1 line
2.55.0
Ilya Maximets
maintainerPATCH 6/6 net: vxlan: remove unused vxlan_dev_create
In reply to Ilya MaximetsThe vport-vxlan in openvswitch was the last user and it is now gone.
And we can now rename the internal function to have a better name.
--- drivers/net/vxlan/vxlan_core.c | 42 ++++------------------------------ include/net/vxlan.h | 3 --- 2 files changed, 4 insertions(+), 41 deletions(-)
drivers/net/vxlan/vxlan_core.c +4 -38
@@ -3966,9 +3966,9 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,return 0 ; } -static int __vxlan_dev_create (struct net *net,struct net_device *dev, -struct vxlan_config *conf, -struct netlink_ext_ack *extack) +static int vxlan_dev_create (struct net *net,struct net_device *dev, +struct vxlan_config *conf, +struct netlink_ext_ack *extack) {struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_dev *vxlan =netdev_priv (dev);
@@ -4416,7 +4416,7 @@ static int vxlan_newlink(struct net_device *dev,if (err)return err; -return __vxlan_dev_create (link_net, dev, &conf, extack); +return vxlan_dev_create (link_net, dev, &conf, extack); } static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
@@ -4700,40 +4700,6 @@ static struct rtnl_link_ops vxlan_link_ops __read_mostly = { .get_link_net = vxlan_get_link_net, }; -struct net_device *vxlan_dev_create (struct net *net,const char *name, -u8 name_assign_type, -struct vxlan_config *conf) -{ -struct nlattr *tb[IFLA_MAX +1 ]; -struct net_device *dev; -int err; - -memset (&tb,0 ,sizeof (tb)); - - dev =rtnl_create_link (net, name, name_assign_type, - &vxlan_link_ops, tb,NULL ); -if (IS_ERR (dev)) -return dev; - - err =__vxlan_dev_create (net, dev, conf,NULL ); -if (err <0 ) { -free_netdev (dev); -return ERR_PTR (err); - } - - err =rtnl_configure_link (dev,NULL ,0 ,NULL ); -if (err <0 ) { -LIST_HEAD (list_kill); - -vxlan_dellink (dev, &list_kill); -unregister_netdevice_many (&list_kill); -return ERR_PTR (err); - } - -return dev; -} -EXPORT_SYMBOL_GPL (vxlan_dev_create); -static void vxlan_handle_lowerdev_unregister (struct vxlan_net *vn,struct net_device *dev) {
include/net/vxlan.h +0 -3
@@ -359,9 +359,6 @@ struct vxlan_dev { VXLAN_F_MC_ROUTE | \ 0) -struct net_device *vxlan_dev_create (struct net *net,const char *name, -u8 name_assign_type,struct vxlan_config *conf); -static inline netdev_features_t vxlan_features_check (struct sk_buff *skb,netdev_features_t features) {
Signature · 1 line
2.55.0
Paolo Abeni
maintainerQuoted 5 lines · Ilya Maximets
ovs-vswitchd doesn't use OVS_VPORT_TYPE_GRE/VXLAN/GENEVE with the Linux kernel module since adding support for standard tunnel devices with
COLLECT_METADATAback in 2017. The code to use them was only activated as a fallback for old kernels, so not used in practice. And it is now fully removed in the upcoming OVS 4.0 release.
Given the above, that ovs-vswitchd is the only legit user this interface the change looks very safe to me...
Quoted 1 line
21 files changed, 63 insertions(+), 874 deletions(-)
... and this is a very compelling reason to have it in ASAP.
/P
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Tue, 4 Aug 2026 20:20:34 +0200 you wrote:
ovs-vswitchd doesn't use OVS_VPORT_TYPE_GRE/VXLAN/GENEVE with the Linux kernel module since adding support for standard tunnel devices with
COLLECT_METADATAback in 2017. The code to use them was only activated as a fallback for old kernels, so not used in practice. And it is now fully removed in the upcoming OVS 4.0 release.Modern way to use tunnels with OVS is to create standard tunnel ports with
RTM_NEWLINK+COLLECT_METADATAand add them asOVS_VPORT_TYPE_NETDEV.[...]
Here is the summary with links:
- [net-next,1/6] openvswitch: remove support for legacy tunnel types
https://git.kernel.org/netdev/net-next/c/d26dcf73a8f1 - [net-next,2/6] openvswitch: vport: remove infrastructure for vport options https://git.kernel.org/netdev/net-next/c/38aecd1a1973 - [net-next,3/6] openvswitch: vport: remove infrastructure for separate modules https://git.kernel.org/netdev/net-next/c/2425eba0f822 - [net-next,4/6] net: geneve: remove unused geneve_dev_create_fb https://git.kernel.org/netdev/net-next/c/e5ba33295201 - [net-next,5/6] net: gre: remove unused gretap_fb_dev_create https://git.kernel.org/netdev/net-next/c/9646825a51c4 - [net-next,6/6] net: vxlan: remove unused vxlan_dev_create https://git.kernel.org/netdev/net-next/c/a5ae637f863d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html