ovn-controller: Change strategy for gateway conntrack zone allocation.
[cascardo/ovs.git] / ovn / controller / ovn-controller.h
1 /* Copyright (c) 2015, 2016 Nicira, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16
17 #ifndef OVN_CONTROLLER_H
18 #define OVN_CONTROLLER_H 1
19
20 #include "simap.h"
21 #include "ovn/lib/ovn-sb-idl.h"
22
23 /* Linux supports a maximum of 64K zones, which seems like a fine default. */
24 #define MAX_CT_ZONES 65535
25
26 struct controller_ctx {
27     struct ovsdb_idl *ovnsb_idl;
28     struct ovsdb_idl_txn *ovnsb_idl_txn;
29
30     struct ovsdb_idl *ovs_idl;
31     struct ovsdb_idl_txn *ovs_idl_txn;
32 };
33
34 /* Contains hmap_node whose hash values are the tunnel_key of datapaths
35  * with at least one local port binding. It also stores the port binding of
36  * "localnet" port if such a port exists on the datapath, which indicates
37  * physical network should be used for inter-chassis communication through
38  * the localnet port */
39 struct local_datapath {
40     struct hmap_node hmap_node;
41     struct hmap_node uuid_hmap_node;
42     struct uuid uuid;
43     char *logical_port;
44     const struct sbrec_port_binding *localnet_port;
45 };
46
47 struct local_datapath *get_local_datapath(const struct hmap *,
48                                           uint32_t tunnel_key);
49
50 /* Contains hmap_node whose hash values are the tunnel_key of datapaths
51  * with at least one logical patch port binding. */
52 struct patched_datapath {
53     struct hmap_node hmap_node;
54     char *key;  /* Holds the uuid of the corresponding datapath. */
55     bool local; /* 'True' if the datapath is for gateway router. */
56     bool stale; /* 'True' if the datapath is not referenced by any patch
57                  * port. */
58 };
59
60 struct patched_datapath *get_patched_datapath(const struct hmap *,
61                                               uint32_t tunnel_key);
62
63 const struct ovsrec_bridge *get_bridge(struct ovsdb_idl *,
64                                        const char *br_name);
65
66 const struct sbrec_chassis *get_chassis(struct ovsdb_idl *,
67                                         const char *chassis_id);
68
69 /* Must be a bit-field ordered from most-preferred (higher number) to
70  * least-preferred (lower number). */
71 enum chassis_tunnel_type {
72     GENEVE = 1 << 2,
73     STT    = 1 << 1,
74     VXLAN  = 1 << 0
75 };
76
77 uint32_t get_tunnel_type(const char *name);
78
79
80 #endif /* ovn/ovn-controller.h */