2 * Copyright (c) 2007-2012 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
22 #include <linux/version.h>
23 #include <net/net_namespace.h>
24 #include <net/netns/generic.h>
30 u8 ipproto; /* The IP protocol for the tunnel. */
33 * Returns the length of the tunnel header that will be added in
34 * build_header() (i.e. excludes the IP header).
36 int (*hdr_len)(const struct ovs_key_ipv4_tunnel *);
38 * Builds header for given SKB. Space will have already been
39 * allocated at the start of the packet equal
40 * to sizeof(struct iphdr) + value returned by hdr_len().
42 void (*build_header)(const struct vport *, struct sk_buff *,
51 const struct tnl_ops *tnl_ops;
54 struct vport *ovs_tnl_create(const struct vport_parms *, const struct vport_ops *,
55 const struct tnl_ops *);
56 void ovs_tnl_destroy(struct vport *);
58 const char *ovs_tnl_get_name(const struct vport *vport);
59 int ovs_tnl_send(struct vport *vport, struct sk_buff *skb);
60 void ovs_tnl_rcv(struct vport *vport, struct sk_buff *skb);
61 u16 ovs_tnl_get_src_port(struct sk_buff *skb);
63 static inline struct tnl_vport *tnl_vport_priv(const struct vport *vport)
65 return vport_priv(vport);
68 static inline void tnl_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key,
69 const struct iphdr *iph, __be64 tun_id, u32 tun_flags)
71 tun_key->tun_id = tun_id;
72 tun_key->ipv4_src = iph->saddr;
73 tun_key->ipv4_dst = iph->daddr;
74 tun_key->ipv4_tos = iph->tos;
75 tun_key->ipv4_ttl = iph->ttl;
76 tun_key->tun_flags = tun_flags;
78 /* clear struct padding. */
79 memset((unsigned char*) tun_key + OVS_TUNNEL_KEY_SIZE, 0,
80 sizeof(*tun_key) - OVS_TUNNEL_KEY_SIZE);