2 * Copyright (c) 2007-2014 Nicira, Inc.
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.
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.
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
19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <linux/skbuff.h>
24 #include <linux/if_tunnel.h>
25 #include <linux/if_vlan.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>
40 #include <net/ip_tunnels.h>
42 #include <net/net_namespace.h>
43 #include <net/netns/generic.h>
44 #include <net/protocol.h>
48 #include "vport-netdev.h"
50 static struct vport_ops ovs_gre_vport_ops
;
52 static struct vport
*gre_tnl_create(const struct vport_parms
*parms
)
54 struct net
*net
= ovs_dp_get_net(parms
->dp
);
55 struct net_device
*dev
;
58 vport
= ovs_vport_alloc(0, &ovs_gre_vport_ops
, parms
);
63 dev
= gretap_fb_dev_create(net
, parms
->name
, NET_NAME_USER
);
66 ovs_vport_free(vport
);
70 dev_change_flags(dev
, dev
->flags
| IFF_UP
);
76 static struct vport
*gre_create(const struct vport_parms
*parms
)
80 vport
= gre_tnl_create(parms
);
84 return ovs_netdev_link(vport
, parms
->name
);
87 static struct vport_ops ovs_gre_vport_ops
= {
88 .type
= OVS_VPORT_TYPE_GRE
,
90 .send
= dev_queue_xmit
,
91 .destroy
= ovs_netdev_tunnel_destroy
,
94 static int __init
ovs_gre_tnl_init(void)
96 return ovs_vport_ops_register(&ovs_gre_vport_ops
);
99 static void __exit
ovs_gre_tnl_exit(void)
101 ovs_vport_ops_unregister(&ovs_gre_vport_ops
);
104 module_init(ovs_gre_tnl_init
);
105 module_exit(ovs_gre_tnl_exit
);
107 MODULE_DESCRIPTION("OVS: GRE switching port");
108 MODULE_LICENSE("GPL");
109 MODULE_ALIAS("vport-type-3");