2010-08-10 20:11:48 -04:00
|
|
|
/*
|
2012-05-02 15:21:36 -07:00
|
|
|
* Copyright (c) 2007-2012 Nicira, Inc.
|
2010-08-10 20:11:48 -04:00
|
|
|
*
|
2011-11-16 13:39:40 -08:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of version 2 of the GNU General Public
|
|
|
|
|
* License as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
* 02110-1301, USA
|
2010-08-10 20:11:48 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef TUNNEL_H
|
|
|
|
|
#define TUNNEL_H 1
|
|
|
|
|
|
2010-08-27 13:55:02 -07:00
|
|
|
#include <linux/version.h>
|
2012-01-30 06:56:54 -08:00
|
|
|
#include <net/net_namespace.h>
|
|
|
|
|
#include <net/netns/generic.h>
|
2010-08-27 13:55:02 -07:00
|
|
|
|
|
|
|
|
#include "flow.h"
|
2010-08-10 20:11:48 -04:00
|
|
|
#include "vport.h"
|
|
|
|
|
|
|
|
|
|
struct tnl_ops {
|
2010-08-27 13:55:02 -07:00
|
|
|
u8 ipproto; /* The IP protocol for the tunnel. */
|
2010-08-10 20:11:48 -04:00
|
|
|
|
2010-08-16 10:32:41 -04:00
|
|
|
/*
|
2010-08-27 13:55:02 -07:00
|
|
|
* Returns the length of the tunnel header that will be added in
|
2013-03-04 13:00:25 -08:00
|
|
|
* build_header() (i.e. excludes the IP header).
|
2010-08-16 10:32:41 -04:00
|
|
|
*/
|
2013-03-04 13:00:25 -08:00
|
|
|
int (*hdr_len)(const struct ovs_key_ipv4_tunnel *);
|
2010-08-16 10:32:41 -04:00
|
|
|
/*
|
2013-03-04 13:00:25 -08:00
|
|
|
* Builds header for given SKB. Space will have already been
|
|
|
|
|
* allocated at the start of the packet equal
|
|
|
|
|
* to sizeof(struct iphdr) + value returned by hdr_len().
|
|
|
|
|
*/
|
|
|
|
|
void (*build_header)(const struct vport *, struct sk_buff *,
|
|
|
|
|
int tunnel_hlen);
|
2010-08-27 13:55:02 -07:00
|
|
|
};
|
|
|
|
|
|
2010-08-10 20:11:48 -04:00
|
|
|
struct tnl_vport {
|
|
|
|
|
struct rcu_head rcu;
|
|
|
|
|
|
2013-03-04 13:00:25 -08:00
|
|
|
__be16 dst_port;
|
2010-08-10 20:11:48 -04:00
|
|
|
char name[IFNAMSIZ];
|
|
|
|
|
const struct tnl_ops *tnl_ops;
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-21 17:15:20 -08:00
|
|
|
struct vport *ovs_tnl_create(const struct vport_parms *, const struct vport_ops *,
|
|
|
|
|
const struct tnl_ops *);
|
|
|
|
|
void ovs_tnl_destroy(struct vport *);
|
|
|
|
|
|
|
|
|
|
const char *ovs_tnl_get_name(const struct vport *vport);
|
|
|
|
|
int ovs_tnl_send(struct vport *vport, struct sk_buff *skb);
|
2012-10-20 12:15:24 -07:00
|
|
|
void ovs_tnl_rcv(struct vport *vport, struct sk_buff *skb);
|
2013-02-21 21:52:04 -08:00
|
|
|
u16 ovs_tnl_get_src_port(struct sk_buff *skb);
|
2011-11-21 17:15:20 -08:00
|
|
|
|
2010-08-10 20:11:48 -04:00
|
|
|
static inline struct tnl_vport *tnl_vport_priv(const struct vport *vport)
|
|
|
|
|
{
|
|
|
|
|
return vport_priv(vport);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-20 12:15:24 -07:00
|
|
|
static inline void tnl_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key,
|
|
|
|
|
const struct iphdr *iph, __be64 tun_id, u32 tun_flags)
|
|
|
|
|
{
|
|
|
|
|
tun_key->tun_id = tun_id;
|
|
|
|
|
tun_key->ipv4_src = iph->saddr;
|
|
|
|
|
tun_key->ipv4_dst = iph->daddr;
|
|
|
|
|
tun_key->ipv4_tos = iph->tos;
|
|
|
|
|
tun_key->ipv4_ttl = iph->ttl;
|
|
|
|
|
tun_key->tun_flags = tun_flags;
|
2013-01-25 18:09:07 -08:00
|
|
|
|
|
|
|
|
/* clear struct padding. */
|
|
|
|
|
memset((unsigned char*) tun_key + OVS_TUNNEL_KEY_SIZE, 0,
|
|
|
|
|
sizeof(*tun_key) - OVS_TUNNEL_KEY_SIZE);
|
2012-10-20 12:15:24 -07:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 20:11:48 -04:00
|
|
|
#endif /* tunnel.h */
|