]> git.proxmox.com Git - mirror_ovs.git/blame - datapath/vport-gre.c
datapath: backport: allow output of MPLS packets on tunnel vports
[mirror_ovs.git] / datapath / vport-gre.c
CommitLineData
2736b84e 1/*
99e7b077 2 * Copyright (c) 2007-2015 Nicira, Inc.
2736b84e 3 *
a9a29d22
JG
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
2736b84e
JG
17 */
18
dfffaef1
JP
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
d1eb60cc
JG
21#include <linux/if.h>
22#include <linux/skbuff.h>
2736b84e
JG
23#include <linux/ip.h>
24#include <linux/if_tunnel.h>
25#include <linux/if_vlan.h>
26#include <linux/in.h>
5ebaf571
PS
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>
5a38795f 32#include <linux/module.h>
5ebaf571
PS
33#include <linux/workqueue.h>
34#include <linux/rculist.h>
35#include <net/route.h>
36#include <net/xfrm.h>
37
2736b84e 38#include <net/icmp.h>
2736b84e 39#include <net/ip.h>
5ebaf571
PS
40#include <net/ip_tunnels.h>
41#include <net/gre.h>
99e7b077
PS
42#include <net/net_namespace.h>
43#include <net/netns/generic.h>
2736b84e 44#include <net/protocol.h>
2736b84e 45
2a4999f3 46#include "datapath.h"
2736b84e 47#include "vport.h"
e23775f2 48#include "vport-netdev.h"
2736b84e 49
5a38795f 50static struct vport_ops ovs_gre_vport_ops;
5a38795f 51
e23775f2 52static struct vport *gre_tnl_create(const struct vport_parms *parms)
b9298d3f 53{
e23775f2
PS
54 struct net *net = ovs_dp_get_net(parms->dp);
55 struct net_device *dev;
43f31ef5
WZ
56 struct vport *vport;
57
e23775f2
PS
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);
5ebaf571
PS
68 }
69
e23775f2
PS
70 dev_change_flags(dev, dev->flags | IFF_UP);
71 rtnl_unlock();
2736b84e 72
e23775f2 73 return vport;
c405d282 74}
85c9de19
PS
75
76static struct vport *gre_create(const struct vport_parms *parms)
77{
85c9de19 78 struct vport *vport;
85c9de19 79
e23775f2 80 vport = gre_tnl_create(parms);
c405d282 81 if (IS_ERR(vport))
e23775f2 82 return vport;
85c9de19 83
e23775f2 84 return ovs_netdev_link(vport, parms->name);
c405d282
PS
85}
86
5a38795f 87static struct vport_ops ovs_gre_vport_ops = {
99e7b077
PS
88 .type = OVS_VPORT_TYPE_GRE,
89 .create = gre_create,
e23775f2 90 .send = gre_fb_xmit,
aad7cb91 91 .fill_metadata_dst = gre_fill_metadata_dst,
e23775f2 92 .destroy = ovs_netdev_tunnel_destroy,
2de795ad 93};
5a38795f
TG
94
95static int __init ovs_gre_tnl_init(void)
96{
99e7b077 97 return ovs_vport_ops_register(&ovs_gre_vport_ops);
5a38795f
TG
98}
99
100static void __exit ovs_gre_tnl_exit(void)
101{
5a38795f
TG
102 ovs_vport_ops_unregister(&ovs_gre_vport_ops);
103}
104
105module_init(ovs_gre_tnl_init);
106module_exit(ovs_gre_tnl_exit);
107
108MODULE_DESCRIPTION("OVS: GRE switching port");
109MODULE_LICENSE("GPL");
110MODULE_ALIAS("vport-type-3");