]>
Commit | Line | Data |
---|---|---|
19a87e36 | 1 | /* |
a930d4c5 | 2 | * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. |
19a87e36 BP |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #ifndef CONNMGR_H | |
18 | #define CONNMGR_H 1 | |
19 | ||
2b07c8b1 | 20 | #include "classifier.h" |
ee89ea7b | 21 | #include "openvswitch/hmap.h" |
b19bab5b | 22 | #include "openvswitch/list.h" |
e29747e4 | 23 | #include "openvswitch/match.h" |
0d71302e | 24 | #include "openvswitch/ofp-connection.h" |
19a87e36 | 25 | #include "ofproto.h" |
cdbdeeda | 26 | #include "ofproto-provider.h" |
19a87e36 | 27 | #include "openflow/nicira-ext.h" |
e03c096d | 28 | #include "openvswitch/ofp-errors.h" |
0d71302e | 29 | #include "openvswitch/ofp-packet.h" |
19a87e36 BP |
30 | #include "openvswitch/types.h" |
31 | ||
a946b636 | 32 | struct nlattr; |
19a87e36 | 33 | struct ofconn; |
0d71302e BP |
34 | struct ofputil_flow_removed; |
35 | struct ofputil_requestforward; | |
2b07c8b1 | 36 | struct rule; |
0d085684 | 37 | struct simap; |
81e2083f | 38 | struct sset; |
19a87e36 | 39 | |
a2b53dec BP |
40 | /* An asynchronous message that might need to be queued between threads. */ |
41 | struct ofproto_async_msg { | |
ca6ba700 | 42 | struct ovs_list list_node; /* For queuing. */ |
f11c7538 | 43 | uint16_t controller_id; /* Controller ID to send to. */ |
a2b53dec BP |
44 | |
45 | enum ofputil_async_msg_type oam; | |
e8fed7d0 WT |
46 | /* OAM_PACKET_IN. */ |
47 | struct { | |
48 | struct ofputil_packet_in_private up; | |
49 | int max_len; /* From action, or -1 if none. */ | |
50 | } pin; | |
0fb7792a | 51 | }; |
a2b53dec | 52 | void ofproto_async_msg_free(struct ofproto_async_msg *); |
0fb7792a | 53 | |
19a87e36 BP |
54 | /* Basics. */ |
55 | struct connmgr *connmgr_create(struct ofproto *ofproto, | |
56 | const char *dpif_name, const char *local_name); | |
25010c68 JR |
57 | void connmgr_destroy(struct connmgr *) |
58 | OVS_REQUIRES(ofproto_mutex); | |
19a87e36 BP |
59 | |
60 | void connmgr_run(struct connmgr *, | |
b20f4073 | 61 | void (*handle_openflow)(struct ofconn *, |
fd4b7a0e | 62 | const struct ovs_list *msgs)); |
b20f4073 | 63 | void connmgr_wait(struct connmgr *); |
19a87e36 | 64 | |
0d085684 BP |
65 | void connmgr_get_memory_usage(const struct connmgr *, struct simap *usage); |
66 | ||
19a87e36 BP |
67 | struct ofproto *ofconn_get_ofproto(const struct ofconn *); |
68 | ||
7fdd2082 FL |
69 | void connmgr_set_bundle_idle_timeout(unsigned timeout); |
70 | ||
7ee20df1 BP |
71 | void connmgr_retry(struct connmgr *); |
72 | ||
19a87e36 BP |
73 | /* OpenFlow configuration. */ |
74 | bool connmgr_has_controllers(const struct connmgr *); | |
75 | void connmgr_get_controller_info(struct connmgr *, struct shash *); | |
72ba2ed3 | 76 | void connmgr_free_controller_info(struct shash *); |
af26093a | 77 | void connmgr_set_controllers(struct connmgr *, struct shash *); |
19a87e36 BP |
78 | void connmgr_reconnect(const struct connmgr *); |
79 | ||
81e2083f BP |
80 | int connmgr_set_snoops(struct connmgr *, const struct sset *snoops); |
81 | bool connmgr_has_snoops(const struct connmgr *); | |
82 | void connmgr_get_snoops(const struct connmgr *, struct sset *snoops); | |
19a87e36 BP |
83 | |
84 | /* Individual connections to OpenFlow controllers. */ | |
85 | enum ofconn_type ofconn_get_type(const struct ofconn *); | |
86 | ||
f4f1ea7e | 87 | bool ofconn_get_master_election_id(const struct ofconn *, uint64_t *idp); |
6ea4776b | 88 | bool ofconn_set_master_election_id(struct ofconn *, uint64_t); |
f4f1ea7e BP |
89 | enum ofp12_controller_role ofconn_get_role(const struct ofconn *); |
90 | void ofconn_set_role(struct ofconn *, enum ofp12_controller_role); | |
19a87e36 | 91 | |
e3d560db | 92 | enum ofputil_protocol ofconn_get_protocol(const struct ofconn *); |
27527aa0 | 93 | void ofconn_set_protocol(struct ofconn *, enum ofputil_protocol); |
19a87e36 | 94 | |
d8790c08 BP |
95 | enum ofputil_packet_in_format ofconn_get_packet_in_format(struct ofconn *); |
96 | void ofconn_set_packet_in_format(struct ofconn *, | |
97 | enum ofputil_packet_in_format); | |
54834960 | 98 | |
a7349929 BP |
99 | void ofconn_set_controller_id(struct ofconn *, uint16_t controller_id); |
100 | ||
f0fd1a17 PS |
101 | void ofconn_set_invalid_ttl_to_controller(struct ofconn *, bool); |
102 | bool ofconn_get_invalid_ttl_to_controller(struct ofconn *); | |
103 | ||
19a87e36 BP |
104 | int ofconn_get_miss_send_len(const struct ofconn *); |
105 | void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len); | |
106 | ||
80d5aefd | 107 | void ofconn_set_async_config(struct ofconn *, |
a930d4c5 BP |
108 | const struct ofputil_async_cfg *); |
109 | struct ofputil_async_cfg ofconn_get_async_config(const struct ofconn *); | |
80d5aefd | 110 | |
19a87e36 | 111 | void ofconn_send_reply(const struct ofconn *, struct ofpbuf *); |
ca6ba700 | 112 | void ofconn_send_replies(const struct ofconn *, struct ovs_list *); |
1be5ff75 | 113 | void ofconn_send_error(const struct ofconn *, const struct ofp_header *request, |
90bf1e07 | 114 | enum ofperr); |
19a87e36 | 115 | |
ff09bc08 JR |
116 | struct ofp_bundle; |
117 | ||
118 | struct ofp_bundle *ofconn_get_bundle(struct ofconn *, uint32_t id); | |
52c57cbb BP |
119 | void ofconn_insert_bundle(struct ofconn *, struct ofp_bundle *); |
120 | void ofconn_remove_bundle(struct ofconn *, struct ofp_bundle *); | |
777af88d | 121 | |
696d1bcf BP |
122 | /* Logging flow_mod summaries. */ |
123 | void ofconn_report_flow_mod(struct ofconn *, enum ofp_flow_mod_command); | |
124 | ||
19a87e36 | 125 | /* Sending asynchronous messages. */ |
6b83a3c5 | 126 | bool connmgr_wants_packet_in_on_miss(struct connmgr *mgr); |
2a6f78e0 | 127 | void connmgr_send_port_status(struct connmgr *, struct ofconn *source, |
042b8f42 BP |
128 | const struct ofputil_phy_port *old_pp, |
129 | const struct ofputil_phy_port *new_pp, | |
130 | uint8_t reason); | |
19a87e36 | 131 | void connmgr_send_flow_removed(struct connmgr *, |
25010c68 JR |
132 | const struct ofputil_flow_removed *) |
133 | OVS_REQUIRES(ofproto_mutex); | |
a2b53dec BP |
134 | void connmgr_send_async_msg(struct connmgr *, |
135 | const struct ofproto_async_msg *); | |
00467f73 AC |
136 | void ofconn_send_role_status(struct ofconn *ofconn, uint32_t role, |
137 | uint8_t reason); | |
19a87e36 | 138 | |
3c35db62 NR |
139 | void connmgr_send_requestforward(struct connmgr *, const struct ofconn *source, |
140 | const struct ofputil_requestforward *); | |
141 | ||
19a87e36 BP |
142 | /* Fail-open settings. */ |
143 | enum ofproto_fail_mode connmgr_get_fail_mode(const struct connmgr *); | |
144 | void connmgr_set_fail_mode(struct connmgr *, enum ofproto_fail_mode); | |
145 | ||
146 | /* Fail-open implementation. */ | |
147 | int connmgr_get_max_probe_interval(const struct connmgr *); | |
148 | bool connmgr_is_any_controller_connected(const struct connmgr *); | |
149 | bool connmgr_is_any_controller_admitted(const struct connmgr *); | |
150 | int connmgr_failure_duration(const struct connmgr *); | |
19a87e36 BP |
151 | |
152 | /* In-band configuration. */ | |
153 | void connmgr_set_extra_in_band_remotes(struct connmgr *, | |
154 | const struct sockaddr_in *, size_t); | |
155 | void connmgr_set_in_band_queue(struct connmgr *, int queue_id); | |
156 | ||
157 | /* In-band implementation. */ | |
f7f1ea29 | 158 | bool connmgr_has_in_band(struct connmgr *); |
19a87e36 BP |
159 | |
160 | /* Fail-open and in-band implementation. */ | |
161 | void connmgr_flushed(struct connmgr *); | |
162 | ||
3fbbcba7 BP |
163 | int connmgr_count_hidden_rules(const struct connmgr *); |
164 | ||
2b07c8b1 BP |
165 | /* A flow monitor managed by NXST_FLOW_MONITOR and related requests. */ |
166 | struct ofmonitor { | |
167 | struct ofconn *ofconn; /* Owning 'ofconn'. */ | |
168 | struct hmap_node ofconn_node; /* In ofconn's 'monitors' hmap. */ | |
169 | uint32_t id; | |
170 | ||
171 | enum nx_flow_monitor_flags flags; | |
172 | ||
173 | /* Matching. */ | |
4e022ec0 | 174 | ofp_port_t out_port; |
2b07c8b1 | 175 | uint8_t table_id; |
5cb7a798 | 176 | struct minimatch match; |
2b07c8b1 BP |
177 | }; |
178 | ||
179 | struct ofputil_flow_monitor_request; | |
180 | ||
181 | enum ofperr ofmonitor_create(const struct ofputil_flow_monitor_request *, | |
4cd1bc9d BP |
182 | struct ofconn *, struct ofmonitor **) |
183 | OVS_REQUIRES(ofproto_mutex); | |
184 | struct ofmonitor *ofmonitor_lookup(struct ofconn *, uint32_t id) | |
185 | OVS_REQUIRES(ofproto_mutex); | |
186 | void ofmonitor_destroy(struct ofmonitor *) | |
187 | OVS_REQUIRES(ofproto_mutex); | |
2b07c8b1 BP |
188 | |
189 | void ofmonitor_report(struct connmgr *, struct rule *, | |
190 | enum nx_flow_update_event, enum ofp_flow_removed_reason, | |
cdbdeeda SH |
191 | const struct ofconn *abbrev_ofconn, ovs_be32 abbrev_xid, |
192 | const struct rule_actions *old_actions) | |
15aaf599 | 193 | OVS_REQUIRES(ofproto_mutex); |
4cd1bc9d | 194 | void ofmonitor_flush(struct connmgr *) OVS_REQUIRES(ofproto_mutex); |
2b07c8b1 | 195 | |
a8e547c1 BP |
196 | |
197 | struct rule_collection; | |
2b07c8b1 | 198 | void ofmonitor_collect_resume_rules(struct ofmonitor *, uint64_t seqno, |
4cd1bc9d BP |
199 | struct rule_collection *) |
200 | OVS_REQUIRES(ofproto_mutex); | |
a8e547c1 | 201 | void ofmonitor_compose_refresh_updates(struct rule_collection *rules, |
ca6ba700 | 202 | struct ovs_list *msgs) |
4cd1bc9d | 203 | OVS_REQUIRES(ofproto_mutex); |
2b07c8b1 | 204 | |
6c6eedc5 SJ |
205 | void connmgr_send_table_status(struct connmgr *, |
206 | const struct ofputil_table_desc *td, | |
207 | uint8_t reason); | |
19a87e36 | 208 | #endif /* connmgr.h */ |