~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/openvswitch/vport-gre.c

Version: ~ [ linux-5.5-rc1 ] ~ [ linux-5.4.2 ] ~ [ linux-5.3.15 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.88 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 
 50 static struct vport_ops ovs_gre_vport_ops;
 51 
 52 static 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         int err;
 58 
 59         vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms);
 60         if (IS_ERR(vport))
 61                 return vport;
 62 
 63         rtnl_lock();
 64         dev = gretap_fb_dev_create(net, parms->name, NET_NAME_USER);
 65         if (IS_ERR(dev)) {
 66                 rtnl_unlock();
 67                 ovs_vport_free(vport);
 68                 return ERR_CAST(dev);
 69         }
 70 
 71         err = dev_change_flags(dev, dev->flags | IFF_UP);
 72         if (err < 0) {
 73                 rtnl_delete_link(dev);
 74                 rtnl_unlock();
 75                 ovs_vport_free(vport);
 76                 return ERR_PTR(err);
 77         }
 78 
 79         rtnl_unlock();
 80         return vport;
 81 }
 82 
 83 static struct vport *gre_create(const struct vport_parms *parms)
 84 {
 85         struct vport *vport;
 86 
 87         vport = gre_tnl_create(parms);
 88         if (IS_ERR(vport))
 89                 return vport;
 90 
 91         return ovs_netdev_link(vport, parms->name);
 92 }
 93 
 94 static struct vport_ops ovs_gre_vport_ops = {
 95         .type           = OVS_VPORT_TYPE_GRE,
 96         .create         = gre_create,
 97         .send           = dev_queue_xmit,
 98         .destroy        = ovs_netdev_tunnel_destroy,
 99 };
100 
101 static int __init ovs_gre_tnl_init(void)
102 {
103         return ovs_vport_ops_register(&ovs_gre_vport_ops);
104 }
105 
106 static void __exit ovs_gre_tnl_exit(void)
107 {
108         ovs_vport_ops_unregister(&ovs_gre_vport_ops);
109 }
110 
111 module_init(ovs_gre_tnl_init);
112 module_exit(ovs_gre_tnl_exit);
113 
114 MODULE_DESCRIPTION("OVS: GRE switching port");
115 MODULE_LICENSE("GPL");
116 MODULE_ALIAS("vport-type-3");
117 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp