1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2007-2014 Nicira, Inc.
6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9 #include <linux/skbuff.h>
11 #include <linux/if_tunnel.h>
12 #include <linux/if_vlan.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>
27 #include <net/ip_tunnels.h>
29 #include <net/net_namespace.h>
30 #include <net/netns/generic.h>
31 #include <net/protocol.h>
35 #include "vport-netdev.h"
37 static struct vport_ops ovs_gre_vport_ops
;
39 static struct vport
*gre_tnl_create(const struct vport_parms
*parms
)
41 struct net
*net
= ovs_dp_get_net(parms
->dp
);
42 struct net_device
*dev
;
46 vport
= ovs_vport_alloc(0, &ovs_gre_vport_ops
, parms
);
51 dev
= gretap_fb_dev_create(net
, parms
->name
, NET_NAME_USER
);
54 ovs_vport_free(vport
);
58 err
= dev_change_flags(dev
, dev
->flags
| IFF_UP
, NULL
);
60 rtnl_delete_link(dev
, 0, NULL
);
62 ovs_vport_free(vport
);
70 static struct vport
*gre_create(const struct vport_parms
*parms
)
74 vport
= gre_tnl_create(parms
);
78 return ovs_netdev_link(vport
, parms
->name
);
81 static struct vport_ops ovs_gre_vport_ops
= {
82 .type
= OVS_VPORT_TYPE_GRE
,
84 .send
= dev_queue_xmit
,
85 .destroy
= ovs_netdev_tunnel_destroy
,
88 static int __init
ovs_gre_tnl_init(void)
90 return ovs_vport_ops_register(&ovs_gre_vport_ops
);
93 static void __exit
ovs_gre_tnl_exit(void)
95 ovs_vport_ops_unregister(&ovs_gre_vport_ops
);
98 module_init(ovs_gre_tnl_init
);
99 module_exit(ovs_gre_tnl_exit
);
101 MODULE_DESCRIPTION("OVS: GRE switching port");
102 MODULE_LICENSE("GPL");
103 MODULE_ALIAS("vport-type-3");