Linux Audio

Check our new training course

Loading...
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Copyright (c) 2007-2014 Nicira, Inc.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  4 */
  5
  6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  7
  8#include <linux/if.h>
  9#include <linux/skbuff.h>
 10#include <linux/ip.h>
 11#include <linux/if_tunnel.h>
 12#include <linux/if_vlan.h>
 13#include <linux/in.h>
 14#include <linux/in_route.h>
 15#include <linux/inetdevice.h>
 16#include <linux/jhash.h>
 17#include <linux/list.h>
 18#include <linux/kernel.h>
 19#include <linux/module.h>
 20#include <linux/workqueue.h>
 21#include <linux/rculist.h>
 22#include <net/route.h>
 23#include <net/xfrm.h>
 24
 25#include <net/icmp.h>
 26#include <net/ip.h>
 27#include <net/ip_tunnels.h>
 28#include <net/gre.h>
 29#include <net/net_namespace.h>
 30#include <net/netns/generic.h>
 31#include <net/protocol.h>
 32
 33#include "datapath.h"
 34#include "vport.h"
 35#include "vport-netdev.h"
 36
 37static struct vport_ops ovs_gre_vport_ops;
 38
 39static struct vport *gre_tnl_create(const struct vport_parms *parms)
 40{
 41	struct net *net = ovs_dp_get_net(parms->dp);
 42	struct net_device *dev;
 43	struct vport *vport;
 44	int err;
 45
 46	vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms);
 47	if (IS_ERR(vport))
 48		return vport;
 49
 50	rtnl_lock();
 51	dev = gretap_fb_dev_create(net, parms->name, NET_NAME_USER);
 52	if (IS_ERR(dev)) {
 53		rtnl_unlock();
 54		ovs_vport_free(vport);
 55		return ERR_CAST(dev);
 56	}
 57
 58	err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
 59	if (err < 0) {
 60		rtnl_delete_link(dev);
 61		rtnl_unlock();
 62		ovs_vport_free(vport);
 63		return ERR_PTR(err);
 64	}
 65
 66	rtnl_unlock();
 
 67	return vport;
 68}
 69
 70static struct vport *gre_create(const struct vport_parms *parms)
 71{
 72	struct vport *vport;
 73
 74	vport = gre_tnl_create(parms);
 75	if (IS_ERR(vport))
 76		return vport;
 77
 78	return ovs_netdev_link(vport, parms->name);
 79}
 80
 81static struct vport_ops ovs_gre_vport_ops = {
 82	.type		= OVS_VPORT_TYPE_GRE,
 83	.create		= gre_create,
 84	.send		= dev_queue_xmit,
 85	.destroy	= ovs_netdev_tunnel_destroy,
 86};
 87
 88static int __init ovs_gre_tnl_init(void)
 89{
 90	return ovs_vport_ops_register(&ovs_gre_vport_ops);
 91}
 92
 93static void __exit ovs_gre_tnl_exit(void)
 94{
 95	ovs_vport_ops_unregister(&ovs_gre_vport_ops);
 96}
 97
 98module_init(ovs_gre_tnl_init);
 99module_exit(ovs_gre_tnl_exit);
100
101MODULE_DESCRIPTION("OVS: GRE switching port");
102MODULE_LICENSE("GPL");
103MODULE_ALIAS("vport-type-3");
v4.6
 
  1/*
  2 * Copyright (c) 2007-2014 Nicira, Inc.
  3 *
  4 * This program is free software; you can redistribute it and/or
  5 * modify it under the terms of version 2 of the GNU General Public
  6 * License as published by the Free Software Foundation.
  7 *
  8 * This program is distributed in the hope that it will be useful, but
  9 * WITHOUT ANY WARRANTY; without even the implied warranty of
 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 11 * General Public License for more details.
 12 *
 13 * You should have received a copy of the GNU General Public License
 14 * along with this program; if not, write to the Free Software
 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 16 * 02110-1301, USA
 17 */
 18
 19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 20
 21#include <linux/if.h>
 22#include <linux/skbuff.h>
 23#include <linux/ip.h>
 24#include <linux/if_tunnel.h>
 25#include <linux/if_vlan.h>
 26#include <linux/in.h>
 27#include <linux/in_route.h>
 28#include <linux/inetdevice.h>
 29#include <linux/jhash.h>
 30#include <linux/list.h>
 31#include <linux/kernel.h>
 32#include <linux/module.h>
 33#include <linux/workqueue.h>
 34#include <linux/rculist.h>
 35#include <net/route.h>
 36#include <net/xfrm.h>
 37
 38#include <net/icmp.h>
 39#include <net/ip.h>
 40#include <net/ip_tunnels.h>
 41#include <net/gre.h>
 42#include <net/net_namespace.h>
 43#include <net/netns/generic.h>
 44#include <net/protocol.h>
 45
 46#include "datapath.h"
 47#include "vport.h"
 48#include "vport-netdev.h"
 49
 50static struct vport_ops ovs_gre_vport_ops;
 51
 52static struct vport *gre_tnl_create(const struct vport_parms *parms)
 53{
 54	struct net *net = ovs_dp_get_net(parms->dp);
 55	struct net_device *dev;
 56	struct vport *vport;
 
 57
 58	vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms);
 59	if (IS_ERR(vport))
 60		return vport;
 61
 62	rtnl_lock();
 63	dev = gretap_fb_dev_create(net, parms->name, NET_NAME_USER);
 64	if (IS_ERR(dev)) {
 65		rtnl_unlock();
 66		ovs_vport_free(vport);
 67		return ERR_CAST(dev);
 68	}
 69
 70	dev_change_flags(dev, dev->flags | IFF_UP);
 
 
 
 
 
 
 
 71	rtnl_unlock();
 72
 73	return vport;
 74}
 75
 76static struct vport *gre_create(const struct vport_parms *parms)
 77{
 78	struct vport *vport;
 79
 80	vport = gre_tnl_create(parms);
 81	if (IS_ERR(vport))
 82		return vport;
 83
 84	return ovs_netdev_link(vport, parms->name);
 85}
 86
 87static struct vport_ops ovs_gre_vport_ops = {
 88	.type		= OVS_VPORT_TYPE_GRE,
 89	.create		= gre_create,
 90	.send		= dev_queue_xmit,
 91	.destroy	= ovs_netdev_tunnel_destroy,
 92};
 93
 94static int __init ovs_gre_tnl_init(void)
 95{
 96	return ovs_vport_ops_register(&ovs_gre_vport_ops);
 97}
 98
 99static void __exit ovs_gre_tnl_exit(void)
100{
101	ovs_vport_ops_unregister(&ovs_gre_vport_ops);
102}
103
104module_init(ovs_gre_tnl_init);
105module_exit(ovs_gre_tnl_exit);
106
107MODULE_DESCRIPTION("OVS: GRE switching port");
108MODULE_LICENSE("GPL");
109MODULE_ALIAS("vport-type-3");