2
* Copyright (c) 2010, 2011 Nicira Networks.
3
* Distributed under the terms of the GNU GPL version 2.
5
* Significant portions of this file may be copied from parts of the Linux
6
* kernel, by Linus Torvalds and others.
2
* Copyright (c) 2007-2011 Nicira Networks.
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
34
43
/* These flags are only needed when calling tnl_find_port(). */
35
44
#define TNL_T_KEY_EXACT (1 << 10)
36
45
#define TNL_T_KEY_MATCH (1 << 11)
37
#define TNL_T_KEY_EITHER (TNL_T_KEY_EXACT | TNL_T_KEY_MATCH)
39
47
/* Private flags not exposed to userspace in this form. */
40
#define TNL_F_IN_KEY_MATCH (1 << 16) /* Store the key in tun_id to match in flow table. */
41
#define TNL_F_OUT_KEY_ACTION (1 << 17) /* Get the key from a SET_TUNNEL action. */
48
#define TNL_F_IN_KEY_MATCH (1 << 16) /* Store the key in tun_id to
49
* match in flow table. */
50
#define TNL_F_OUT_KEY_ACTION (1 << 17) /* Get the key from a SET_TUNNEL
43
53
/* All public tunnel flags. */
44
54
#define TNL_F_PUBLIC (TNL_F_CSUM | TNL_F_TOS_INHERIT | TNL_F_TTL_INHERIT | \
46
56
TNL_F_HDR_CACHE | TNL_F_IPSEC)
59
* struct port_lookup_key - Tunnel port key, used as hash table key.
60
* @in_key: Key to match on input, 0 for wildcard.
61
* @saddr: IPv4 source address to match, 0 to accept any source address.
62
* @daddr: IPv4 destination of tunnel.
63
* @tunnel_type: Set of TNL_T_* flags that define lookup.
65
struct port_lookup_key {
72
#define PORT_KEY_LEN (offsetof(struct port_lookup_key, tunnel_type) + \
73
FIELD_SIZEOF(struct port_lookup_key, tunnel_type))
49
76
* struct tnl_mutable_config - modifiable configuration for a tunnel.
77
* @key: Used as key for tunnel port. Configured via OVS_TUNNEL_ATTR_*
50
79
* @rcu: RCU callback head for deferred destruction.
51
80
* @seq: Sequence number for distinguishing configuration versions.
52
* @tunnel_type: Set of TNL_T_* flags that define lookup.
53
81
* @tunnel_hlen: Tunnel header length.
54
82
* @eth_addr: Source address for packets generated by tunnel itself
55
83
* (e.g. ICMP fragmentation needed messages).
56
* @in_key: Key to match on input, 0 for wildcard.
57
84
* @out_key: Key to use on output, 0 if this tunnel has no fixed output key.
58
85
* @flags: TNL_F_* flags.
59
* @saddr: IPv4 source address to match, 0 to accept any source address.
60
* @daddr: IPv4 destination of tunnel.
61
86
* @tos: IPv4 TOS value to use for tunnel, 0 if no fixed TOS.
62
87
* @ttl: IPv4 TTL value to use for tunnel, 0 if no fixed TTL.
64
89
struct tnl_mutable_config {
90
struct port_lookup_key key;
65
91
struct rcu_head rcu;
70
95
unsigned tunnel_hlen;
72
97
unsigned char eth_addr[ETH_ALEN];
74
/* Configured via ODP_TUNNEL_ATTR_* attributes. */
99
/* Configured via OVS_TUNNEL_ATTR_* attributes. */
105
/* Multicast configuration. */
218
struct vport *tnl_create(const struct vport_parms *, const struct vport_ops *,
219
const struct tnl_ops *);
220
int tnl_destroy(struct vport *);
222
int tnl_set_options(struct vport *, struct nlattr *);
223
int tnl_get_options(const struct vport *, struct sk_buff *);
225
int tnl_set_addr(struct vport *vport, const unsigned char *addr);
226
const char *tnl_get_name(const struct vport *vport);
227
const unsigned char *tnl_get_addr(const struct vport *vport);
228
int tnl_send(struct vport *vport, struct sk_buff *skb);
229
void tnl_rcv(struct vport *vport, struct sk_buff *skb, u8 tos);
231
struct vport *tnl_find_port(__be32 saddr, __be32 daddr, __be64 key,
233
const struct tnl_mutable_config **mutable);
234
bool tnl_frag_needed(struct vport *vport,
235
const struct tnl_mutable_config *mutable,
236
struct sk_buff *skb, unsigned int mtu, __be64 flow_key);
237
void tnl_free_linked_skbs(struct sk_buff *skb);
245
struct vport *ovs_tnl_create(const struct vport_parms *, const struct vport_ops *,
246
const struct tnl_ops *);
247
void ovs_tnl_destroy(struct vport *);
249
int ovs_tnl_set_options(struct vport *, struct nlattr *);
250
int ovs_tnl_get_options(const struct vport *, struct sk_buff *);
252
int ovs_tnl_set_addr(struct vport *vport, const unsigned char *addr);
253
const char *ovs_tnl_get_name(const struct vport *vport);
254
const unsigned char *ovs_tnl_get_addr(const struct vport *vport);
255
int ovs_tnl_send(struct vport *vport, struct sk_buff *skb);
256
void ovs_tnl_rcv(struct vport *vport, struct sk_buff *skb, u8 tos);
258
struct vport *ovs_tnl_find_port(__be32 saddr, __be32 daddr, __be64 key,
260
const struct tnl_mutable_config **mutable);
261
bool ovs_tnl_frag_needed(struct vport *vport,
262
const struct tnl_mutable_config *mutable,
263
struct sk_buff *skb, unsigned int mtu, __be64 flow_key);
264
void ovs_tnl_free_linked_skbs(struct sk_buff *skb);
266
int ovs_tnl_init(void);
267
void ovs_tnl_exit(void);
239
268
static inline struct tnl_vport *tnl_vport_priv(const struct vport *vport)
241
270
return vport_priv(vport);
245
273
#endif /* tunnel.h */