~gandelman-a/ubuntu/precise/openvswitch/lp1044318

« back to all changes in this revision

Viewing changes to datapath/tunnel.h

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-02-13 09:41:54 UTC
  • mfrom: (5.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120213094154-2slirexctkpkkuto
Tags: 1.4.0-1ubuntu1
* Merged from debian unstable (LP: #925611), remaining changes are:
  * debian/control: Recommend openvswitch-datapath-dkms.
    (LP: #894754) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2010, 2011 Nicira Networks.
3
 
 * Distributed under the terms of the GNU GPL version 2.
4
 
 *
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.
 
3
 *
 
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
7
17
 */
8
18
 
9
19
#ifndef TUNNEL_H
13
23
 
14
24
#include "flow.h"
15
25
#include "openvswitch/tunnel.h"
16
 
#include "table.h"
17
26
#include "vport.h"
18
27
 
19
28
/*
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)
38
46
 
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
 
51
                                           * action. */
42
52
 
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)
47
57
 
48
58
/**
 
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.
 
64
 */
 
65
struct port_lookup_key {
 
66
        __be64 in_key;
 
67
        __be32 saddr;
 
68
        __be32 daddr;
 
69
        u32    tunnel_type;
 
70
};
 
71
 
 
72
#define PORT_KEY_LEN    (offsetof(struct port_lookup_key, tunnel_type) + \
 
73
                         FIELD_SIZEOF(struct port_lookup_key, tunnel_type))
 
74
 
 
75
/**
49
76
 * struct tnl_mutable_config - modifiable configuration for a tunnel.
 
77
 * @key: Used as key for tunnel port.  Configured via OVS_TUNNEL_ATTR_*
 
78
 * attributes.
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.
63
88
 */
64
89
struct tnl_mutable_config {
 
90
        struct port_lookup_key key;
65
91
        struct rcu_head rcu;
66
92
 
67
93
        unsigned seq;
68
94
 
69
 
        u32 tunnel_type;
70
95
        unsigned tunnel_hlen;
71
96
 
72
97
        unsigned char eth_addr[ETH_ALEN];
73
98
 
74
 
        /* Configured via ODP_TUNNEL_ATTR_* attributes. */
75
 
        __be64  in_key;
 
99
        /* Configured via OVS_TUNNEL_ATTR_* attributes. */
76
100
        __be64  out_key;
77
101
        u32     flags;
78
 
        __be32  saddr;
79
 
        __be32  daddr;
80
102
        u8      tos;
81
103
        u8      ttl;
 
104
 
 
105
        /* Multicast configuration. */
 
106
        int     mlink;
82
107
};
83
108
 
84
109
struct tnl_ops {
138
163
        struct rcu_head rcu;
139
164
 
140
165
        int len;                /* Length of data to be memcpy'd from cache. */
 
166
        int hh_len;             /* Hardware hdr length, cached from hh_cache. */
141
167
 
142
 
        /* Sequence number of mutable->seq from which this cache was generated. */
 
168
        /* Sequence number of mutable->seq from which this cache was
 
169
         * generated. */
143
170
        unsigned mutable_seq;
144
171
 
145
172
#ifdef HAVE_HH_SEQ
187
214
 
188
215
struct tnl_vport {
189
216
        struct rcu_head rcu;
190
 
        struct tbl_node tbl_node;
 
217
        struct hlist_node hash_node;
191
218
 
192
219
        char name[IFNAMSIZ];
193
220
        const struct tnl_ops *tnl_ops;
202
229
        atomic_t frag_id;
203
230
 
204
231
        spinlock_t cache_lock;
205
 
        struct tnl_cache __rcu *cache;          /* Protected by RCU/cache_lock. */
 
232
        struct tnl_cache __rcu *cache;  /* Protected by RCU/cache_lock. */
206
233
 
207
234
#ifdef NEED_CACHE_TIMEOUT
208
235
        /*
215
242
#endif
216
243
};
217
244
 
218
 
struct vport *tnl_create(const struct vport_parms *, const struct vport_ops *,
219
 
                         const struct tnl_ops *);
220
 
int tnl_destroy(struct vport *);
221
 
 
222
 
int tnl_set_options(struct vport *, struct nlattr *);
223
 
int tnl_get_options(const struct vport *, struct sk_buff *);
224
 
 
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);
230
 
 
231
 
struct vport *tnl_find_port(__be32 saddr, __be32 daddr, __be64 key,
232
 
                            int tunnel_type,
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);
238
 
 
 
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 *);
 
248
 
 
249
int ovs_tnl_set_options(struct vport *, struct nlattr *);
 
250
int ovs_tnl_get_options(const struct vport *, struct sk_buff *);
 
251
 
 
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);
 
257
 
 
258
struct vport *ovs_tnl_find_port(__be32 saddr, __be32 daddr, __be64 key,
 
259
                                int tunnel_type,
 
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);
 
265
 
 
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)
240
269
{
241
270
        return vport_priv(vport);
242
271
}
243
272
 
244
 
 
245
273
#endif /* tunnel.h */