/src/openvswitch/include/openvswitch/ofp-actions.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2012-2017, 2019-2020 Nicira, Inc. |
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 OPENVSWITCH_OFP_ACTIONS_H |
18 | | #define OPENVSWITCH_OFP_ACTIONS_H 1 |
19 | | |
20 | | #include <stddef.h> |
21 | | #include <stdint.h> |
22 | | #include "openflow/openflow.h" |
23 | | #include "openflow/nicira-ext.h" |
24 | | #include "openvswitch/meta-flow.h" |
25 | | #include "openvswitch/ofp-errors.h" |
26 | | #include "openvswitch/ofp-protocol.h" |
27 | | #include "openvswitch/types.h" |
28 | | #include "openvswitch/ofp-ed-props.h" |
29 | | |
30 | | #ifdef __cplusplus |
31 | | extern "C" { |
32 | | #endif |
33 | | |
34 | | struct vl_mff_map; |
35 | | |
36 | | /* List of OVS abstracted actions. |
37 | | * |
38 | | * This macro is used directly only internally by this header, but the list is |
39 | | * still of interest to developers. |
40 | | * |
41 | | * Each OFPACT invocation has the following parameters: |
42 | | * |
43 | | * 1. <ENUM>, used below in the enum definition of OFPACT_<ENUM>, and |
44 | | * elsewhere. |
45 | | * |
46 | | * 2. <STRUCT> corresponding to a structure "struct <STRUCT>", that must be |
47 | | * defined below. This structure must be an abstract definition of the |
48 | | * action. Its first member must have type "struct ofpact" and name |
49 | | * "ofpact". It may be fixed length or end with a flexible array member |
50 | | * (e.g. "int member[];"). |
51 | | * |
52 | | * 3. <MEMBER>, which has one of two possible values: |
53 | | * |
54 | | * - If "struct <STRUCT>" is fixed-length, it must be "ofpact". |
55 | | * |
56 | | * - If "struct <STRUCT>" is variable-length, it must be the name of the |
57 | | * flexible array member. |
58 | | * |
59 | | * 4. <NAME>, a quoted string that gives the name of the action, for use in |
60 | | * parsing actions from text. |
61 | | */ |
62 | | #define OFPACTS \ |
63 | | /* Output. */ \ |
64 | | OFPACT(OUTPUT, ofpact_output, ofpact, "output") \ |
65 | | OFPACT(GROUP, ofpact_group, ofpact, "group") \ |
66 | | OFPACT(CONTROLLER, ofpact_controller, userdata, "controller") \ |
67 | | OFPACT(ENQUEUE, ofpact_enqueue, ofpact, "enqueue") \ |
68 | | OFPACT(OUTPUT_REG, ofpact_output_reg, ofpact, "output_reg") \ |
69 | | OFPACT(BUNDLE, ofpact_bundle, members, "bundle") \ |
70 | | \ |
71 | | /* Header changes. */ \ |
72 | | OFPACT(SET_FIELD, ofpact_set_field, ofpact, "set_field") \ |
73 | | OFPACT(SET_VLAN_VID, ofpact_vlan_vid, ofpact, "set_vlan_vid") \ |
74 | | OFPACT(SET_VLAN_PCP, ofpact_vlan_pcp, ofpact, "set_vlan_pcp") \ |
75 | | OFPACT(STRIP_VLAN, ofpact_null, ofpact, "strip_vlan") \ |
76 | | OFPACT(PUSH_VLAN, ofpact_push_vlan, ofpact, "push_vlan") \ |
77 | | OFPACT(SET_ETH_SRC, ofpact_mac, ofpact, "mod_dl_src") \ |
78 | | OFPACT(SET_ETH_DST, ofpact_mac, ofpact, "mod_dl_dst") \ |
79 | | OFPACT(SET_IPV4_SRC, ofpact_ipv4, ofpact, "mod_nw_src") \ |
80 | | OFPACT(SET_IPV4_DST, ofpact_ipv4, ofpact, "mod_nw_dst") \ |
81 | | OFPACT(SET_IP_DSCP, ofpact_dscp, ofpact, "mod_nw_tos") \ |
82 | | OFPACT(SET_IP_ECN, ofpact_ecn, ofpact, "mod_nw_ecn") \ |
83 | | OFPACT(SET_IP_TTL, ofpact_ip_ttl, ofpact, "mod_nw_ttl") \ |
84 | | OFPACT(SET_L4_SRC_PORT, ofpact_l4_port, ofpact, "mod_tp_src") \ |
85 | | OFPACT(SET_L4_DST_PORT, ofpact_l4_port, ofpact, "mod_tp_dst") \ |
86 | | OFPACT(REG_MOVE, ofpact_reg_move, ofpact, "move") \ |
87 | | OFPACT(STACK_PUSH, ofpact_stack, ofpact, "push") \ |
88 | | OFPACT(STACK_POP, ofpact_stack, ofpact, "pop") \ |
89 | | OFPACT(DEC_TTL, ofpact_cnt_ids, cnt_ids, "dec_ttl") \ |
90 | | OFPACT(SET_MPLS_LABEL, ofpact_mpls_label, ofpact, "set_mpls_label") \ |
91 | | OFPACT(SET_MPLS_TC, ofpact_mpls_tc, ofpact, "set_mpls_tc") \ |
92 | | OFPACT(SET_MPLS_TTL, ofpact_mpls_ttl, ofpact, "set_mpls_ttl") \ |
93 | | OFPACT(DEC_MPLS_TTL, ofpact_null, ofpact, "dec_mpls_ttl") \ |
94 | | OFPACT(PUSH_MPLS, ofpact_push_mpls, ofpact, "push_mpls") \ |
95 | | OFPACT(POP_MPLS, ofpact_pop_mpls, ofpact, "pop_mpls") \ |
96 | | OFPACT(DEC_NSH_TTL, ofpact_null, ofpact, "dec_nsh_ttl") \ |
97 | | OFPACT(DELETE_FIELD, ofpact_delete_field, ofpact, "delete_field") \ |
98 | | \ |
99 | | /* Generic encap & decap */ \ |
100 | | OFPACT(ENCAP, ofpact_encap, props, "encap") \ |
101 | | OFPACT(DECAP, ofpact_decap, ofpact, "decap") \ |
102 | | \ |
103 | | /* Metadata. */ \ |
104 | | OFPACT(SET_TUNNEL, ofpact_tunnel, ofpact, "set_tunnel") \ |
105 | | OFPACT(SET_QUEUE, ofpact_queue, ofpact, "set_queue") \ |
106 | | OFPACT(POP_QUEUE, ofpact_null, ofpact, "pop_queue") \ |
107 | | OFPACT(FIN_TIMEOUT, ofpact_fin_timeout, ofpact, "fin_timeout") \ |
108 | | \ |
109 | | /* Flow table interaction. */ \ |
110 | | OFPACT(RESUBMIT, ofpact_resubmit, ofpact, "resubmit") \ |
111 | | OFPACT(LEARN, ofpact_learn, specs, "learn") \ |
112 | | OFPACT(CONJUNCTION, ofpact_conjunction, ofpact, "conjunction") \ |
113 | | \ |
114 | | /* Arithmetic. */ \ |
115 | | OFPACT(MULTIPATH, ofpact_multipath, ofpact, "multipath") \ |
116 | | \ |
117 | | /* Other. */ \ |
118 | | OFPACT(NOTE, ofpact_note, data, "note") \ |
119 | | OFPACT(EXIT, ofpact_null, ofpact, "exit") \ |
120 | | OFPACT(SAMPLE, ofpact_sample, ofpact, "sample") \ |
121 | | OFPACT(UNROLL_XLATE, ofpact_unroll_xlate, ofpact, "unroll_xlate") \ |
122 | | OFPACT(CT, ofpact_conntrack, ofpact, "ct") \ |
123 | | OFPACT(CT_CLEAR, ofpact_null, ofpact, "ct_clear") \ |
124 | | OFPACT(NAT, ofpact_nat, ofpact, "nat") \ |
125 | | OFPACT(OUTPUT_TRUNC, ofpact_output_trunc,ofpact, "output_trunc") \ |
126 | | OFPACT(CLONE, ofpact_nest, actions, "clone") \ |
127 | | OFPACT(CHECK_PKT_LARGER, ofpact_check_pkt_larger, ofpact, \ |
128 | | "check_pkt_larger") \ |
129 | | \ |
130 | | /* Debugging actions. \ |
131 | | * \ |
132 | | * These are intentionally undocumented, subject to change, and \ |
133 | | * only accepted if ovs-vswitchd is started with --enable-dummy. */ \ |
134 | | OFPACT(DEBUG_RECIRC, ofpact_null, ofpact, "debug_recirc") \ |
135 | | OFPACT(DEBUG_SLOW, ofpact_null, ofpact, "debug_slow") \ |
136 | | \ |
137 | | /* Instructions ("meter" is an action in OF1.5+). */ \ |
138 | | OFPACT(METER, ofpact_meter, ofpact, "meter") \ |
139 | | OFPACT(CLEAR_ACTIONS, ofpact_null, ofpact, "clear_actions") \ |
140 | | OFPACT(WRITE_ACTIONS, ofpact_nest, actions, "write_actions") \ |
141 | | OFPACT(WRITE_METADATA, ofpact_metadata, ofpact, "write_metadata") \ |
142 | | OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact, "goto_table") |
143 | | |
144 | | /* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */ |
145 | | enum OVS_PACKED_ENUM ofpact_type { |
146 | | #define OFPACT(ENUM, STRUCT, MEMBER, NAME) OFPACT_##ENUM, |
147 | | OFPACTS |
148 | | #undef OFPACT |
149 | | }; |
150 | | |
151 | | /* Define N_OFPACTS to the number of types of ofpacts. */ |
152 | | enum { |
153 | | #define OFPACT(ENUM, STRUCT, MEMBER, NAME) + 1 |
154 | | N_OFPACTS = OFPACTS |
155 | | #undef OFPACT |
156 | | }; |
157 | | |
158 | | /* Header for an action. |
159 | | * |
160 | | * Each action is a structure "struct ofpact_*" that begins with "struct |
161 | | * ofpact", usually followed by other data that describes the action. Actions |
162 | | * are padded out to a multiple of OFPACT_ALIGNTO bytes in length. |
163 | | * |
164 | | * The 'raw' member is special: |
165 | | * |
166 | | * - Most "struct ofpact"s correspond to one particular kind of OpenFlow |
167 | | * action, at least in a given OpenFlow version. For example, |
168 | | * OFPACT_SET_VLAN_VID corresponds to OFPAT10_SET_VLAN_VID in OpenFlow |
169 | | * 1.0. |
170 | | * |
171 | | * For such actions, the 'raw' member is not meaningful and generally |
172 | | * should be zero. |
173 | | * |
174 | | * - A few "struct ofpact"s correspond to multiple OpenFlow actions. For |
175 | | * example, OFPACT_SET_TUNNEL can be NXAST_SET_TUNNEL or |
176 | | * NXAST_SET_TUNNEL64. In these cases, if the "struct ofpact" originated |
177 | | * from OpenFlow, then we want to make sure that, if it gets translated |
178 | | * back to OpenFlow later, it is translated back to the same action type. |
179 | | * (Otherwise, we'd violate the promise made in the topics/design doc, in |
180 | | * the "Action Reproduction" section.) |
181 | | * |
182 | | * For such actions, the 'raw' member should be the "enum ofp_raw_action" |
183 | | * originally extracted from the OpenFlow action. (If the action didn't |
184 | | * originate from OpenFlow, then setting 'raw' to zero should be fine: |
185 | | * code to translate the ofpact to OpenFlow must tolerate this case.) |
186 | | */ |
187 | | struct ofpact { |
188 | | /* We want the space advantage of an 8-bit type here on every |
189 | | * implementation, without giving up the advantage of having a useful type |
190 | | * on implementations that support packed enums. */ |
191 | | #ifdef HAVE_PACKED_ENUM |
192 | | enum ofpact_type type; /* OFPACT_*. */ |
193 | | #else |
194 | | uint8_t type; /* OFPACT_* */ |
195 | | #endif |
196 | | |
197 | | uint8_t raw; /* Original type when added, if any. */ |
198 | | uint16_t len; /* Length of the action, in bytes, including |
199 | | * struct ofpact, excluding padding. */ |
200 | | }; |
201 | | BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4); |
202 | | |
203 | | /* Alignment. */ |
204 | | #define OFPACT_ALIGNTO 8 |
205 | | #define OFPACT_ALIGN(SIZE) ROUND_UP(SIZE, OFPACT_ALIGNTO) |
206 | | #define OFPACT_IS_ALIGNED(ADDR) ((uintptr_t) (ADDR) % OFPACT_ALIGNTO == 0) |
207 | | #define OFPACT_PADDED_MEMBERS(MEMBERS) PADDED_MEMBERS(OFPACT_ALIGNTO, MEMBERS) |
208 | | |
209 | | /* Returns the ofpact following 'ofpact'. */ |
210 | | static inline struct ofpact * |
211 | | ofpact_next(const struct ofpact *ofpact) |
212 | 0 | { |
213 | 0 | return ALIGNED_CAST(struct ofpact *, |
214 | 0 | (uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len)); |
215 | 0 | } |
216 | | |
217 | | struct ofpact *ofpact_next_flattened(const struct ofpact *); |
218 | | |
219 | | static inline struct ofpact * |
220 | | ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len) |
221 | 0 | { |
222 | 0 | return ofpacts |
223 | 0 | ? ALIGNED_CAST(struct ofpact *, (uint8_t *) ofpacts + ofpacts_len) |
224 | 0 | : NULL; |
225 | 0 | } |
226 | | |
227 | | static inline bool |
228 | | ofpact_last(const struct ofpact *a, const struct ofpact *ofpacts, |
229 | | size_t ofpact_len) |
230 | 0 | { |
231 | 0 | return ofpact_next(a) == ofpact_end(ofpacts, ofpact_len); |
232 | 0 | } |
233 | | |
234 | | static inline size_t |
235 | | ofpact_remaining_len(const struct ofpact *a, const struct ofpact *ofpacts, |
236 | | size_t ofpact_len) |
237 | 0 | { |
238 | 0 | return ofpact_len - ((uint8_t *)a - (uint8_t *)ofpacts); |
239 | 0 | } |
240 | | |
241 | | static inline const struct ofpact * |
242 | | ofpact_find_type_flattened(const struct ofpact *a, enum ofpact_type type, |
243 | | const struct ofpact * const end) |
244 | 0 | { |
245 | 0 | while (a < end) { |
246 | 0 | if (a->type == type) { |
247 | 0 | return a; |
248 | 0 | } |
249 | 0 | a = ofpact_next_flattened(a); |
250 | 0 | } |
251 | 0 | return NULL; |
252 | 0 | } |
253 | | |
254 | | #define OFPACT_FIND_TYPE_FLATTENED(A, TYPE, END) \ |
255 | | ofpact_get_##TYPE##_nullable( \ |
256 | | ofpact_find_type_flattened(A, OFPACT_##TYPE, END)) |
257 | | |
258 | | /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts |
259 | | * starting at OFPACTS. */ |
260 | | #define OFPACT_FOR_EACH(POS, OFPACTS, OFPACTS_LEN) \ |
261 | | for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \ |
262 | | (POS) = ofpact_next(POS)) |
263 | | |
264 | | /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts |
265 | | * starting at OFPACTS. |
266 | | * |
267 | | * For ofpacts that contain nested ofpacts, this visits each of the inner |
268 | | * ofpacts as well. */ |
269 | | #define OFPACT_FOR_EACH_FLATTENED(POS, OFPACTS, OFPACTS_LEN) \ |
270 | | for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \ |
271 | | (POS) = ofpact_next_flattened(POS)) |
272 | | |
273 | | #define OFPACT_FOR_EACH_TYPE_FLATTENED(POS, TYPE, OFPACTS, OFPACTS_LEN) \ |
274 | | for ((POS) = OFPACT_FIND_TYPE_FLATTENED(OFPACTS, TYPE, \ |
275 | | ofpact_end(OFPACTS, OFPACTS_LEN)); \ |
276 | | (POS); \ |
277 | | (POS) = OFPACT_FIND_TYPE_FLATTENED( \ |
278 | | ofpact_next_flattened(&(POS)->ofpact), TYPE, \ |
279 | | ofpact_end(OFPACTS, OFPACTS_LEN))) |
280 | | |
281 | | /* Action structure for each OFPACT_*. */ |
282 | | |
283 | | /* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS. |
284 | | * |
285 | | * Used for OFPAT10_STRIP_VLAN, NXAST_POP_QUEUE, NXAST_EXIT, |
286 | | * OFPAT11_POP_VLAN, OFPIT11_CLEAR_ACTIONS. |
287 | | * |
288 | | * Action structure for actions that do not have any extra data beyond the |
289 | | * action type. */ |
290 | | struct ofpact_null { |
291 | | OFPACT_PADDED_MEMBERS( |
292 | | struct ofpact ofpact; |
293 | | ); |
294 | | }; |
295 | | |
296 | | /* OFPACT_OUTPUT. |
297 | | * |
298 | | * Used for OFPAT10_OUTPUT. */ |
299 | | struct ofpact_output { |
300 | | OFPACT_PADDED_MEMBERS( |
301 | | struct ofpact ofpact; |
302 | | ofp_port_t port; /* Output port. */ |
303 | | uint16_t max_len; /* Max send len, for port OFPP_CONTROLLER. */ |
304 | | ); |
305 | | }; |
306 | | |
307 | | #define NX_CTLR_NO_METER 0 |
308 | | |
309 | | /* OFPACT_CONTROLLER. |
310 | | * |
311 | | * Used for NXAST_CONTROLLER. */ |
312 | | struct ofpact_controller { |
313 | | OFPACT_PADDED_MEMBERS( |
314 | | struct ofpact ofpact; |
315 | | uint16_t max_len; /* Max length to send to controller. */ |
316 | | uint16_t controller_id; /* Controller ID to send packet-in. */ |
317 | | enum ofp_packet_in_reason reason; /* Reason to put in packet-in. */ |
318 | | |
319 | | /* If true, this action freezes packet traversal of the OpenFlow |
320 | | * tables and adds a continuation to the packet-in message, that |
321 | | * a controller can use to resume that traversal. */ |
322 | | bool pause; |
323 | | |
324 | | /* Arbitrary data to include in the packet-in message (currently, |
325 | | * only in NXT_PACKET_IN2). */ |
326 | | uint16_t userdata_len; |
327 | | |
328 | | /* Meter to which this controller action should be associated. |
329 | | * If requested, this will override a "controller" virtual meter. |
330 | | * A value of NX_CTLR_NO_METER means no meter is requested. */ |
331 | | uint32_t meter_id; |
332 | | uint32_t provider_meter_id; |
333 | | ); |
334 | | uint8_t userdata[0]; |
335 | | }; |
336 | | |
337 | | /* OFPACT_ENQUEUE. |
338 | | * |
339 | | * Used for OFPAT10_ENQUEUE. */ |
340 | | struct ofpact_enqueue { |
341 | | OFPACT_PADDED_MEMBERS( |
342 | | struct ofpact ofpact; |
343 | | ofp_port_t port; |
344 | | uint32_t queue; |
345 | | ); |
346 | | }; |
347 | | |
348 | | /* OFPACT_OUTPUT_REG. |
349 | | * |
350 | | * Used for NXAST_OUTPUT_REG. */ |
351 | | struct ofpact_output_reg { |
352 | | OFPACT_PADDED_MEMBERS( |
353 | | struct ofpact ofpact; |
354 | | uint16_t max_len; |
355 | | struct mf_subfield src; |
356 | | ); |
357 | | }; |
358 | | |
359 | | /* OFPACT_OUTPUT_TRUNC. |
360 | | * |
361 | | * Used for NXAST_OUTPUT_TRUNC. */ |
362 | | struct ofpact_output_trunc { |
363 | | OFPACT_PADDED_MEMBERS( |
364 | | struct ofpact ofpact; |
365 | | ofp_port_t port; /* Output port. */ |
366 | | uint32_t max_len; /* Max send len. */ |
367 | | ); |
368 | | }; |
369 | | |
370 | | /* Bundle member choice algorithm to apply. |
371 | | * |
372 | | * In the descriptions below, 'members' is the list of possible members in the |
373 | | * order they appear in the OpenFlow action. */ |
374 | | enum nx_bd_algorithm { |
375 | | /* Chooses the first live member listed in the bundle. |
376 | | * |
377 | | * O(n_members) performance. */ |
378 | | NX_BD_ALG_ACTIVE_BACKUP = 0, |
379 | | |
380 | | /* Highest Random Weight. |
381 | | * |
382 | | * for i in [0,n_members): |
383 | | * weights[i] = hash(flow, i) |
384 | | * member = { members[i] such that weights[i] >= weights[j] for all j != i } |
385 | | * |
386 | | * Redistributes 1/n_members of traffic when a member's liveness changes. |
387 | | * O(n_members) performance. |
388 | | * |
389 | | * Uses the 'fields' and 'basis' parameters. */ |
390 | | NX_BD_ALG_HRW = 1 |
391 | | }; |
392 | | |
393 | | /* OFPACT_BUNDLE. |
394 | | * |
395 | | * Used for NXAST_BUNDLE. */ |
396 | | struct ofpact_bundle { |
397 | | OFPACT_PADDED_MEMBERS( |
398 | | struct ofpact ofpact; |
399 | | |
400 | | /* Member choice algorithm to apply to hash value. */ |
401 | | enum nx_bd_algorithm algorithm; |
402 | | |
403 | | /* What fields to hash and how. */ |
404 | | enum nx_hash_fields fields; |
405 | | uint16_t basis; /* Universal hash parameter. */ |
406 | | |
407 | | struct mf_subfield dst; |
408 | | |
409 | | bool compat_syntax; |
410 | | |
411 | | /* Members for output. */ |
412 | | unsigned int n_members; |
413 | | ); |
414 | | ofp_port_t members[]; |
415 | | }; |
416 | | |
417 | | /* OFPACT_SET_VLAN_VID. |
418 | | * |
419 | | * We keep track if vlan was present at action validation time to avoid a |
420 | | * PUSH_VLAN when translating to OpenFlow 1.1+. |
421 | | * |
422 | | * We also keep the originating OFPUTIL action code in ofpact.compat. |
423 | | * |
424 | | * Used for OFPAT10_SET_VLAN_VID and OFPAT11_SET_VLAN_VID. */ |
425 | | struct ofpact_vlan_vid { |
426 | | OFPACT_PADDED_MEMBERS( |
427 | | struct ofpact ofpact; |
428 | | uint16_t vlan_vid; /* VLAN VID in low 12 bits, other bits 0. */ |
429 | | bool push_vlan_if_needed; /* OF 1.0 semantics if true. */ |
430 | | bool flow_has_vlan; /* VLAN present at action validation time? */ |
431 | | ); |
432 | | }; |
433 | | |
434 | | /* OFPACT_SET_VLAN_PCP. |
435 | | * |
436 | | * We keep track if vlan was present at action validation time to avoid a |
437 | | * PUSH_VLAN when translating to OpenFlow 1.1+. |
438 | | * |
439 | | * We also keep the originating OFPUTIL action code in ofpact.compat. |
440 | | * |
441 | | * Used for OFPAT10_SET_VLAN_PCP and OFPAT11_SET_VLAN_PCP. */ |
442 | | struct ofpact_vlan_pcp { |
443 | | OFPACT_PADDED_MEMBERS( |
444 | | struct ofpact ofpact; |
445 | | uint8_t vlan_pcp; /* VLAN PCP in low 3 bits, other bits 0. */ |
446 | | bool push_vlan_if_needed; /* OF 1.0 semantics if true. */ |
447 | | bool flow_has_vlan; /* VLAN present at action validation? */ |
448 | | ); |
449 | | }; |
450 | | |
451 | | /* OFPACT_PUSH_VLAN. |
452 | | * |
453 | | * Used for OFPAT11_PUSH_VLAN. */ |
454 | | struct ofpact_push_vlan { |
455 | | OFPACT_PADDED_MEMBERS( |
456 | | struct ofpact ofpact; |
457 | | ovs_be16 ethertype; |
458 | | ); |
459 | | }; |
460 | | |
461 | | /* OFPACT_SET_ETH_SRC, OFPACT_SET_ETH_DST. |
462 | | * |
463 | | * Used for OFPAT10_SET_DL_SRC, OFPAT10_SET_DL_DST. */ |
464 | | struct ofpact_mac { |
465 | | OFPACT_PADDED_MEMBERS( |
466 | | struct ofpact ofpact; |
467 | | struct eth_addr mac; |
468 | | ); |
469 | | }; |
470 | | |
471 | | /* OFPACT_SET_IPV4_SRC, OFPACT_SET_IPV4_DST. |
472 | | * |
473 | | * Used for OFPAT10_SET_NW_SRC, OFPAT10_SET_NW_DST. */ |
474 | | struct ofpact_ipv4 { |
475 | | OFPACT_PADDED_MEMBERS( |
476 | | struct ofpact ofpact; |
477 | | ovs_be32 ipv4; |
478 | | ); |
479 | | }; |
480 | | |
481 | | /* OFPACT_SET_IP_DSCP. |
482 | | * |
483 | | * Used for OFPAT10_SET_NW_TOS. */ |
484 | | struct ofpact_dscp { |
485 | | OFPACT_PADDED_MEMBERS( |
486 | | struct ofpact ofpact; |
487 | | uint8_t dscp; /* DSCP in high 6 bits, rest ignored. */ |
488 | | ); |
489 | | }; |
490 | | |
491 | | /* OFPACT_SET_IP_ECN. |
492 | | * |
493 | | * Used for OFPAT11_SET_NW_ECN. */ |
494 | | struct ofpact_ecn { |
495 | | OFPACT_PADDED_MEMBERS( |
496 | | struct ofpact ofpact; |
497 | | uint8_t ecn; /* ECN in low 2 bits, rest ignored. */ |
498 | | ); |
499 | | }; |
500 | | |
501 | | /* OFPACT_SET_IP_TTL. |
502 | | * |
503 | | * Used for OFPAT11_SET_NW_TTL. */ |
504 | | struct ofpact_ip_ttl { |
505 | | OFPACT_PADDED_MEMBERS( |
506 | | struct ofpact ofpact; |
507 | | uint8_t ttl; |
508 | | ); |
509 | | }; |
510 | | |
511 | | /* OFPACT_SET_L4_SRC_PORT, OFPACT_SET_L4_DST_PORT. |
512 | | * |
513 | | * Used for OFPAT10_SET_TP_SRC, OFPAT10_SET_TP_DST. */ |
514 | | struct ofpact_l4_port { |
515 | | OFPACT_PADDED_MEMBERS( |
516 | | struct ofpact ofpact; |
517 | | uint16_t port; /* TCP, UDP or SCTP port number. */ |
518 | | uint8_t flow_ip_proto; /* IP proto from corresponding match, or 0 */ |
519 | | ); |
520 | | }; |
521 | | |
522 | | /* OFPACT_REG_MOVE. |
523 | | * |
524 | | * Used for NXAST_REG_MOVE. */ |
525 | | struct ofpact_reg_move { |
526 | | OFPACT_PADDED_MEMBERS( |
527 | | struct ofpact ofpact; |
528 | | struct mf_subfield src; |
529 | | struct mf_subfield dst; |
530 | | ); |
531 | | }; |
532 | | |
533 | | /* OFPACT_STACK_PUSH, OFPACT_STACK_POP. |
534 | | * |
535 | | * Used for NXAST_STACK_PUSH and NXAST_STACK_POP. */ |
536 | | struct ofpact_stack { |
537 | | OFPACT_PADDED_MEMBERS( |
538 | | struct ofpact ofpact; |
539 | | struct mf_subfield subfield; |
540 | | ); |
541 | | }; |
542 | | |
543 | | /* OFPACT_SET_FIELD. |
544 | | * |
545 | | * Used for NXAST_REG_LOAD and OFPAT12_SET_FIELD. */ |
546 | | struct ofpact_set_field { |
547 | | OFPACT_PADDED_MEMBERS( |
548 | | struct ofpact ofpact; |
549 | | bool flow_has_vlan; /* VLAN present at action validation time. */ |
550 | | const struct mf_field *field; |
551 | | ); |
552 | | union mf_value value[]; /* Significant value bytes followed by |
553 | | * significant mask bytes aligned at |
554 | | * OFPACT_ALIGNTO bytes. */ |
555 | | }; |
556 | | BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value) |
557 | | % OFPACT_ALIGNTO == 0); |
558 | | BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value) |
559 | | == sizeof(struct ofpact_set_field)); |
560 | | |
561 | | /* Use macro to not have to deal with constness. */ |
562 | | #define ofpact_set_field_mask(SF) \ |
563 | | ALIGNED_CAST(union mf_value *, \ |
564 | | (uint8_t *)(SF)->value + \ |
565 | | ROUND_UP((SF)->field->n_bytes, OFPACT_ALIGNTO)) |
566 | | |
567 | | /* OFPACT_PUSH_VLAN/MPLS/PBB |
568 | | * |
569 | | * Used for NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */ |
570 | | struct ofpact_push_mpls { |
571 | | OFPACT_PADDED_MEMBERS( |
572 | | struct ofpact ofpact; |
573 | | ovs_be16 ethertype; |
574 | | ); |
575 | | }; |
576 | | |
577 | | /* OFPACT_POP_MPLS |
578 | | * |
579 | | * Used for NXAST_POP_MPLS, OFPAT11_POP_MPLS.. */ |
580 | | struct ofpact_pop_mpls { |
581 | | OFPACT_PADDED_MEMBERS( |
582 | | struct ofpact ofpact; |
583 | | ovs_be16 ethertype; |
584 | | ); |
585 | | }; |
586 | | |
587 | | /* OFPACT_DELETE_FIELD. |
588 | | * |
589 | | * Used for NXAST_DELETE_FIELD. */ |
590 | | struct ofpact_delete_field { |
591 | | OFPACT_PADDED_MEMBERS( |
592 | | struct ofpact ofpact; |
593 | | const struct mf_field *field; |
594 | | ); |
595 | | }; |
596 | | |
597 | | /* OFPACT_SET_TUNNEL. |
598 | | * |
599 | | * Used for NXAST_SET_TUNNEL, NXAST_SET_TUNNEL64. */ |
600 | | struct ofpact_tunnel { |
601 | | OFPACT_PADDED_MEMBERS( |
602 | | struct ofpact ofpact; |
603 | | uint64_t tun_id; |
604 | | ); |
605 | | }; |
606 | | |
607 | | /* OFPACT_SET_QUEUE. |
608 | | * |
609 | | * Used for NXAST_SET_QUEUE. */ |
610 | | struct ofpact_queue { |
611 | | OFPACT_PADDED_MEMBERS( |
612 | | struct ofpact ofpact; |
613 | | uint32_t queue_id; |
614 | | ); |
615 | | }; |
616 | | |
617 | | /* OFPACT_FIN_TIMEOUT. |
618 | | * |
619 | | * Used for NXAST_FIN_TIMEOUT. */ |
620 | | struct ofpact_fin_timeout { |
621 | | OFPACT_PADDED_MEMBERS( |
622 | | struct ofpact ofpact; |
623 | | uint16_t fin_idle_timeout; |
624 | | uint16_t fin_hard_timeout; |
625 | | ); |
626 | | }; |
627 | | |
628 | | /* OFPACT_WRITE_METADATA. |
629 | | * |
630 | | * Used for NXAST_WRITE_METADATA. */ |
631 | | struct ofpact_metadata { |
632 | | OFPACT_PADDED_MEMBERS( |
633 | | struct ofpact ofpact; |
634 | | ovs_be64 metadata; |
635 | | ovs_be64 mask; |
636 | | ); |
637 | | }; |
638 | | |
639 | | /* OFPACT_METER. |
640 | | * |
641 | | * Used for OFPIT13_METER. */ |
642 | | struct ofpact_meter { |
643 | | OFPACT_PADDED_MEMBERS( |
644 | | struct ofpact ofpact; |
645 | | uint32_t meter_id; |
646 | | uint32_t provider_meter_id; |
647 | | ); |
648 | | }; |
649 | | |
650 | | /* OFPACT_CHECK_PKT_LARGER. |
651 | | * |
652 | | * Used for NXAST_CHECK_PKT_LARGER. */ |
653 | | struct ofpact_check_pkt_larger { |
654 | | OFPACT_PADDED_MEMBERS( |
655 | | struct ofpact ofpact; |
656 | | struct mf_subfield dst; |
657 | | uint16_t pkt_len; |
658 | | ); |
659 | | }; |
660 | | /* OFPACT_WRITE_ACTIONS, OFPACT_CLONE. |
661 | | * |
662 | | * Used for OFPIT11_WRITE_ACTIONS, NXAST_CLONE. */ |
663 | | struct ofpact_nest { |
664 | | OFPACT_PADDED_MEMBERS(struct ofpact ofpact;); |
665 | | struct ofpact actions[]; |
666 | | }; |
667 | | BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions) % OFPACT_ALIGNTO == 0); |
668 | | BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions) |
669 | | == sizeof(struct ofpact_nest)); |
670 | | |
671 | | static inline size_t |
672 | | ofpact_nest_get_action_len(const struct ofpact_nest *on) |
673 | 0 | { |
674 | 0 | return on->ofpact.len - offsetof(struct ofpact_nest, actions); |
675 | 0 | } |
676 | | |
677 | | /* Bits for 'flags' in struct nx_action_conntrack. |
678 | | * |
679 | | * If NX_CT_F_COMMIT is set, then the connection entry is moved from the |
680 | | * unconfirmed to confirmed list in the tracker. |
681 | | * If NX_CT_F_FORCE is set, in addition to NX_CT_F_COMMIT, then the conntrack |
682 | | * entry is replaced with a new one in case the original direction of the |
683 | | * existing entry is opposite of the current packet direction. |
684 | | */ |
685 | | enum nx_conntrack_flags { |
686 | | NX_CT_F_COMMIT = 1 << 0, |
687 | | NX_CT_F_FORCE = 1 << 1, |
688 | | }; |
689 | | |
690 | | /* Magic value for struct nx_action_conntrack 'recirc_table' field, to specify |
691 | | * that the packet should not be recirculated. */ |
692 | | #define NX_CT_RECIRC_NONE OFPTT_ALL |
693 | | |
694 | | #if !defined(IPPORT_FTP) |
695 | | #define IPPORT_FTP 21 |
696 | | #endif |
697 | | |
698 | | #if !defined(IPPORT_TFTP) |
699 | | #define IPPORT_TFTP 69 |
700 | | #endif |
701 | | |
702 | | /* OFPACT_CT. |
703 | | * |
704 | | * Used for NXAST_CT. */ |
705 | | struct ofpact_conntrack { |
706 | | OFPACT_PADDED_MEMBERS( |
707 | | struct ofpact ofpact; |
708 | | uint16_t flags; |
709 | | uint16_t zone_imm; |
710 | | struct mf_subfield zone_src; |
711 | | uint16_t alg; |
712 | | uint8_t recirc_table; |
713 | | ); |
714 | | struct ofpact actions[0]; |
715 | | }; |
716 | | BUILD_ASSERT_DECL(offsetof(struct ofpact_conntrack, actions) |
717 | | % OFPACT_ALIGNTO == 0); |
718 | | BUILD_ASSERT_DECL(offsetof(struct ofpact_conntrack, actions) |
719 | | == sizeof(struct ofpact_conntrack)); |
720 | | |
721 | | static inline size_t |
722 | | ofpact_ct_get_action_len(const struct ofpact_conntrack *oc) |
723 | 0 | { |
724 | 0 | return oc->ofpact.len - offsetof(struct ofpact_conntrack, actions); |
725 | 0 | } |
726 | | |
727 | | void ofpacts_execute_action_set(struct ofpbuf *action_list, |
728 | | const struct ofpbuf *action_set); |
729 | | |
730 | | /* Bits for 'flags' in struct nx_action_nat. |
731 | | */ |
732 | | enum nx_nat_flags { |
733 | | NX_NAT_F_SRC = 1 << 0, /* Mutually exclusive with NX_NAT_F_DST. */ |
734 | | NX_NAT_F_DST = 1 << 1, |
735 | | NX_NAT_F_PERSISTENT = 1 << 2, |
736 | | NX_NAT_F_PROTO_HASH = 1 << 3, /* Mutually exclusive with PROTO_RANDOM. */ |
737 | | NX_NAT_F_PROTO_RANDOM = 1 << 4, |
738 | | NX_NAT_F_MASK = (NX_NAT_F_SRC | NX_NAT_F_DST | NX_NAT_F_PERSISTENT | NX_NAT_F_PROTO_HASH | NX_NAT_F_PROTO_RANDOM) |
739 | | }; |
740 | | |
741 | | /* OFPACT_NAT. |
742 | | * |
743 | | * Used for NXAST_NAT. */ |
744 | | struct ofpact_nat { |
745 | | OFPACT_PADDED_MEMBERS( |
746 | | struct ofpact ofpact; |
747 | | uint8_t range_af; /* AF_UNSPEC, AF_INET, or AF_INET6 */ |
748 | | uint16_t flags; /* NX_NAT_F_* */ |
749 | | struct { |
750 | | struct { |
751 | | uint16_t min; |
752 | | uint16_t max; |
753 | | } proto; |
754 | | union { |
755 | | struct { |
756 | | ovs_be32 min; |
757 | | ovs_be32 max; |
758 | | } ipv4; |
759 | | struct { |
760 | | struct in6_addr min; |
761 | | struct in6_addr max; |
762 | | } ipv6; |
763 | | } addr; |
764 | | } range; |
765 | | ); |
766 | | }; |
767 | | |
768 | | |
769 | | /* OFPACT_RESUBMIT. |
770 | | * |
771 | | * Used for NXAST_RESUBMIT, NXAST_RESUBMIT_TABLE, NXAST_RESUBMIT_TABLE_CT. */ |
772 | | struct ofpact_resubmit { |
773 | | OFPACT_PADDED_MEMBERS( |
774 | | struct ofpact ofpact; |
775 | | ofp_port_t in_port; |
776 | | uint8_t table_id; |
777 | | bool with_ct_orig; /* Resubmit with Conntrack original direction tuple |
778 | | * fields in place of IP header fields. */ |
779 | | ); |
780 | | }; |
781 | | |
782 | | /* Bits for 'flags' in struct nx_action_learn. |
783 | | * |
784 | | * If NX_LEARN_F_SEND_FLOW_REM is set, then the learned flows will have their |
785 | | * OFPFF_SEND_FLOW_REM flag set. |
786 | | * |
787 | | * If NX_LEARN_F_WRITE_RESULT is set, then the actions will write whether the |
788 | | * learn operation succeded on a bit. If the learn is successful the bit will |
789 | | * be set, otherwise (e.g. if the limit is hit) the bit will be unset. |
790 | | * |
791 | | * If NX_LEARN_F_DELETE_LEARNED is set, then removing this action will delete |
792 | | * all the flows from the learn action's 'table_id' that have the learn |
793 | | * action's 'cookie'. Important points: |
794 | | * |
795 | | * - The deleted flows include those created by this action, those created |
796 | | * by other learn actions with the same 'table_id' and 'cookie', those |
797 | | * created by flow_mod requests by a controller in the specified table |
798 | | * with the specified cookie, and those created through any other |
799 | | * means. |
800 | | * |
801 | | * - If multiple flows specify "learn" actions with |
802 | | * NX_LEARN_F_DELETE_LEARNED with the same 'table_id' and 'cookie', then |
803 | | * no deletion occurs until all of those "learn" actions are deleted. |
804 | | * |
805 | | * - Deleting a flow that contains a learn action is the most obvious way |
806 | | * to delete a learn action. Modifying a flow's actions, or replacing it |
807 | | * by a new flow, can also delete a learn action. Finally, replacing a |
808 | | * learn action with NX_LEARN_F_DELETE_LEARNED with a learn action |
809 | | * without that flag also effectively deletes the learn action and can |
810 | | * trigger flow deletion. |
811 | | * |
812 | | * NX_LEARN_F_DELETE_LEARNED was added in Open vSwitch 2.4. */ |
813 | | enum nx_learn_flags { |
814 | | NX_LEARN_F_SEND_FLOW_REM = 1 << 0, |
815 | | NX_LEARN_F_DELETE_LEARNED = 1 << 1, |
816 | | NX_LEARN_F_WRITE_RESULT = 1 << 2, |
817 | | }; |
818 | | |
819 | | #define NX_LEARN_N_BITS_MASK 0x3ff |
820 | | |
821 | | #define NX_LEARN_SRC_FIELD (0 << 13) /* Copy from field. */ |
822 | | #define NX_LEARN_SRC_IMMEDIATE (1 << 13) /* Copy from immediate value. */ |
823 | | #define NX_LEARN_SRC_MASK (1 << 13) |
824 | | |
825 | | #define NX_LEARN_DST_MATCH (0 << 11) /* Add match criterion. */ |
826 | | #define NX_LEARN_DST_LOAD (1 << 11) /* Add NXAST_REG_LOAD action. */ |
827 | | #define NX_LEARN_DST_OUTPUT (2 << 11) /* Add OFPAT_OUTPUT action. */ |
828 | | #define NX_LEARN_DST_RESERVED (3 << 11) /* Not yet defined. */ |
829 | | #define NX_LEARN_DST_MASK (3 << 11) |
830 | | |
831 | | /* Part of struct ofpact_learn, below. */ |
832 | | struct ofpact_learn_spec { |
833 | | OFPACT_PADDED_MEMBERS( |
834 | | struct mf_subfield src; /* NX_LEARN_SRC_FIELD only. */ |
835 | | struct mf_subfield dst; /* NX_LEARN_DST_MATCH, |
836 | | * NX_LEARN_DST_LOAD only. */ |
837 | | uint16_t src_type; /* One of NX_LEARN_SRC_*. */ |
838 | | uint16_t dst_type; /* One of NX_LEARN_DST_*. */ |
839 | | uint32_t n_bits; /* Number of bits in source and dest. */ |
840 | | ); |
841 | | /* Followed by 'DIV_ROUND_UP(n_bits, 8)' bytes of immediate data for |
842 | | * match 'dst_type's NX_LEARN_DST_MATCH and NX_LEARN_DST_LOAD when |
843 | | * NX_LEARN_SRC_IMMEDIATE is set in 'src_type', followed by zeroes to align |
844 | | * to OFPACT_ALIGNTO. */ |
845 | | }; |
846 | | BUILD_ASSERT_DECL(sizeof(struct ofpact_learn_spec) % OFPACT_ALIGNTO == 0); |
847 | | |
848 | | static inline const void * |
849 | | ofpact_learn_spec_imm(const struct ofpact_learn_spec *spec) |
850 | 0 | { |
851 | 0 | return spec + 1; |
852 | 0 | } |
853 | | |
854 | | static inline const struct ofpact_learn_spec * |
855 | | ofpact_learn_spec_next(const struct ofpact_learn_spec *spec) |
856 | 0 | { |
857 | 0 | if (spec->src_type == NX_LEARN_SRC_IMMEDIATE) { |
858 | 0 | unsigned int n_bytes = OFPACT_ALIGN(DIV_ROUND_UP(spec->n_bits, 8)); |
859 | 0 | return ALIGNED_CAST(const struct ofpact_learn_spec *, |
860 | 0 | (const uint8_t *)(spec + 1) + n_bytes); |
861 | 0 | } |
862 | 0 | return spec + 1; |
863 | 0 | } |
864 | | |
865 | | /* OFPACT_LEARN. |
866 | | * |
867 | | * Used for NXAST_LEARN. */ |
868 | | struct ofpact_learn { |
869 | | OFPACT_PADDED_MEMBERS( |
870 | | struct ofpact ofpact; |
871 | | |
872 | | uint16_t idle_timeout; /* Idle time before discarding (seconds). */ |
873 | | uint16_t hard_timeout; /* Max time before discarding (seconds). */ |
874 | | uint16_t priority; /* Priority level of flow entry. */ |
875 | | uint8_t table_id; /* Table to insert flow entry. */ |
876 | | enum nx_learn_flags flags; /* NX_LEARN_F_*. */ |
877 | | ovs_be64 cookie; /* Cookie for new flow. */ |
878 | | uint16_t fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */ |
879 | | uint16_t fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */ |
880 | | /* If the number of flows on 'table_id' with 'cookie' exceeds this, |
881 | | * the action will not add a new flow. 0 indicates unlimited. */ |
882 | | uint32_t limit; |
883 | | /* Used only if 'flags' has NX_LEARN_F_WRITE_RESULT. If the execution |
884 | | * failed to install a new flow because 'limit' is exceeded, |
885 | | * result_dst will be set to 0, otherwise to 1. */ |
886 | | struct mf_subfield result_dst; |
887 | | ); |
888 | | |
889 | | struct ofpact_learn_spec specs[]; |
890 | | }; |
891 | | |
892 | | static inline const struct ofpact_learn_spec * |
893 | | ofpact_learn_spec_end(const struct ofpact_learn *learn) |
894 | 0 | { |
895 | 0 | return ALIGNED_CAST(const struct ofpact_learn_spec *, |
896 | 0 | ofpact_next(&learn->ofpact)); |
897 | 0 | } |
898 | | |
899 | | #define OFPACT_LEARN_SPEC_FOR_EACH(SPEC, LEARN) \ |
900 | | for ((SPEC) = (LEARN)->specs; \ |
901 | | (SPEC) < ofpact_learn_spec_end(LEARN); \ |
902 | | (SPEC) = ofpact_learn_spec_next(SPEC)) |
903 | | |
904 | | /* Multipath link choice algorithm to apply. |
905 | | * |
906 | | * In the descriptions below, 'n_links' is max_link + 1. */ |
907 | | enum nx_mp_algorithm { |
908 | | /* link = hash(flow) % n_links. |
909 | | * |
910 | | * Redistributes all traffic when n_links changes. O(1) performance. See |
911 | | * RFC 2992. |
912 | | * |
913 | | * Use UINT16_MAX for max_link to get a raw hash value. */ |
914 | | NX_MP_ALG_MODULO_N = 0, |
915 | | |
916 | | /* link = hash(flow) / (MAX_HASH / n_links). |
917 | | * |
918 | | * Redistributes between one-quarter and one-half of traffic when n_links |
919 | | * changes. O(1) performance. See RFC 2992. |
920 | | */ |
921 | | NX_MP_ALG_HASH_THRESHOLD = 1, |
922 | | |
923 | | /* Highest Random Weight. |
924 | | * |
925 | | * for i in [0,n_links): |
926 | | * weights[i] = hash(flow, i) |
927 | | * link = { i such that weights[i] >= weights[j] for all j != i } |
928 | | * |
929 | | * Redistributes 1/n_links of traffic when n_links changes. O(n_links) |
930 | | * performance. If n_links is greater than a threshold (currently 64, but |
931 | | * subject to change), Open vSwitch will substitute another algorithm |
932 | | * automatically. See RFC 2992. */ |
933 | | NX_MP_ALG_HRW = 2, |
934 | | |
935 | | /* Iterative Hash. |
936 | | * |
937 | | * i = 0 |
938 | | * repeat: |
939 | | * i = i + 1 |
940 | | * link = hash(flow, i) % arg |
941 | | * while link > max_link |
942 | | * |
943 | | * Redistributes 1/n_links of traffic when n_links changes. O(1) |
944 | | * performance when arg/max_link is bounded by a constant. |
945 | | * |
946 | | * Redistributes all traffic when arg changes. |
947 | | * |
948 | | * arg must be greater than max_link and for best performance should be no |
949 | | * more than approximately max_link * 2. If arg is outside the acceptable |
950 | | * range, Open vSwitch will automatically substitute the least power of 2 |
951 | | * greater than max_link. |
952 | | * |
953 | | * This algorithm is specific to Open vSwitch. |
954 | | */ |
955 | | NX_MP_ALG_ITER_HASH = 3, |
956 | | }; |
957 | | |
958 | | /* OFPACT_CONJUNCTION. |
959 | | * |
960 | | * Used for NXAST_CONJUNCTION. */ |
961 | | struct ofpact_conjunction { |
962 | | OFPACT_PADDED_MEMBERS( |
963 | | struct ofpact ofpact; |
964 | | uint8_t clause; |
965 | | uint8_t n_clauses; |
966 | | uint32_t id; |
967 | | ); |
968 | | }; |
969 | | |
970 | | /* OFPACT_MULTIPATH. |
971 | | * |
972 | | * Used for NXAST_MULTIPATH. */ |
973 | | struct ofpact_multipath { |
974 | | OFPACT_PADDED_MEMBERS( |
975 | | struct ofpact ofpact; |
976 | | |
977 | | /* What fields to hash and how. */ |
978 | | enum nx_hash_fields fields; |
979 | | uint16_t basis; /* Universal hash parameter. */ |
980 | | |
981 | | /* Multipath link choice algorithm to apply to hash value. */ |
982 | | enum nx_mp_algorithm algorithm; |
983 | | uint16_t max_link; /* Number of output links, minus 1. */ |
984 | | uint32_t arg; /* Algorithm-specific argument. */ |
985 | | |
986 | | /* Where to store the result. */ |
987 | | struct mf_subfield dst; |
988 | | ); |
989 | | }; |
990 | | |
991 | | /* OFPACT_NOTE. |
992 | | * |
993 | | * Used for NXAST_NOTE. */ |
994 | | struct ofpact_note { |
995 | | OFPACT_PADDED_MEMBERS( |
996 | | struct ofpact ofpact; |
997 | | size_t length; |
998 | | ); |
999 | | uint8_t data[]; |
1000 | | }; |
1001 | | |
1002 | | /* Direction of sampled packets. */ |
1003 | | enum nx_action_sample_direction { |
1004 | | /* OVS will attempt to infer the sample's direction based on whether |
1005 | | * 'sampling_port' is the packet's output port. This is generally |
1006 | | * effective except when sampling happens as part of an output to a patch |
1007 | | * port, which doesn't involve a datapath output action. */ |
1008 | | NX_ACTION_SAMPLE_DEFAULT, |
1009 | | |
1010 | | /* Explicit direction. This is useful for sampling packets coming in from |
1011 | | * or going out of a patch port, where the direction cannot be inferred. */ |
1012 | | NX_ACTION_SAMPLE_INGRESS, |
1013 | | NX_ACTION_SAMPLE_EGRESS |
1014 | | }; |
1015 | | |
1016 | | /* OFPACT_SAMPLE. |
1017 | | * |
1018 | | * Used for NXAST_SAMPLE, NXAST_SAMPLE2, NXAST_SAMPLE3 and NXAST_SAMPLE4. */ |
1019 | | struct ofpact_sample { |
1020 | | OFPACT_PADDED_MEMBERS( |
1021 | | struct ofpact ofpact; |
1022 | | uint16_t probability; /* Always positive. */ |
1023 | | uint32_t collector_set_id; |
1024 | | uint32_t obs_domain_imm; |
1025 | | struct mf_subfield obs_domain_src; |
1026 | | uint32_t obs_point_imm; |
1027 | | struct mf_subfield obs_point_src; |
1028 | | ofp_port_t sampling_port; |
1029 | | enum nx_action_sample_direction direction; |
1030 | | ); |
1031 | | }; |
1032 | | |
1033 | | /* OFPACT_DEC_TTL. |
1034 | | * |
1035 | | * Used for OFPAT11_DEC_NW_TTL, NXAST_DEC_TTL and NXAST_DEC_TTL_CNT_IDS. */ |
1036 | | struct ofpact_cnt_ids { |
1037 | | OFPACT_PADDED_MEMBERS( |
1038 | | struct ofpact ofpact; |
1039 | | unsigned int n_controllers; |
1040 | | ); |
1041 | | uint16_t cnt_ids[]; |
1042 | | }; |
1043 | | |
1044 | | /* OFPACT_SET_MPLS_LABEL. |
1045 | | * |
1046 | | * Used for OFPAT11_SET_MPLS_LABEL and NXAST_SET_MPLS_LABEL */ |
1047 | | struct ofpact_mpls_label { |
1048 | | OFPACT_PADDED_MEMBERS( |
1049 | | struct ofpact ofpact; |
1050 | | ovs_be32 label; |
1051 | | ); |
1052 | | }; |
1053 | | |
1054 | | /* OFPACT_SET_MPLS_TC. |
1055 | | * |
1056 | | * Used for OFPAT11_SET_MPLS_TC and NXAST_SET_MPLS_TC */ |
1057 | | struct ofpact_mpls_tc { |
1058 | | OFPACT_PADDED_MEMBERS( |
1059 | | struct ofpact ofpact; |
1060 | | uint8_t tc; |
1061 | | ); |
1062 | | }; |
1063 | | |
1064 | | /* OFPACT_SET_MPLS_TTL. |
1065 | | * |
1066 | | * Used for OFPAT11_SET_MPLS_TTL and NXAST_SET_MPLS_TTL */ |
1067 | | struct ofpact_mpls_ttl { |
1068 | | OFPACT_PADDED_MEMBERS( |
1069 | | struct ofpact ofpact; |
1070 | | uint8_t ttl; |
1071 | | ); |
1072 | | }; |
1073 | | |
1074 | | /* OFPACT_GOTO_TABLE |
1075 | | * |
1076 | | * Used for OFPIT11_GOTO_TABLE */ |
1077 | | struct ofpact_goto_table { |
1078 | | OFPACT_PADDED_MEMBERS( |
1079 | | struct ofpact ofpact; |
1080 | | uint8_t table_id; |
1081 | | ); |
1082 | | }; |
1083 | | |
1084 | | /* OFPACT_GROUP. |
1085 | | * |
1086 | | * Used for OFPAT11_GROUP. */ |
1087 | | struct ofpact_group { |
1088 | | OFPACT_PADDED_MEMBERS( |
1089 | | struct ofpact ofpact; |
1090 | | uint32_t group_id; |
1091 | | ); |
1092 | | }; |
1093 | | |
1094 | | /* OFPACT_UNROLL_XLATE. |
1095 | | * |
1096 | | * Used only internally. */ |
1097 | | struct ofpact_unroll_xlate { |
1098 | | OFPACT_PADDED_MEMBERS( |
1099 | | struct ofpact ofpact; |
1100 | | |
1101 | | /* Metadata in xlate context, visible to controller via PACKET_INs. */ |
1102 | | uint8_t rule_table_id; /* 0xFF if none. */ |
1103 | | ovs_be64 rule_cookie; /* OVS_BE64_MAX if none. */ |
1104 | | ); |
1105 | | }; |
1106 | | |
1107 | | /* OFPACT_ENCAP. |
1108 | | * |
1109 | | * Used for NXAST_ENCAP. */ |
1110 | | |
1111 | | struct ofpact_encap { |
1112 | | OFPACT_PADDED_MEMBERS( |
1113 | | struct ofpact ofpact; |
1114 | | ovs_be32 new_pkt_type; /* Packet type of the header to add. */ |
1115 | | uint16_t hdr_size; /* New header size in bytes. */ |
1116 | | uint16_t n_props; /* Number of encap properties. */ |
1117 | | ); |
1118 | | struct ofpact_ed_prop props[]; /* Properties in internal format. */ |
1119 | | }; |
1120 | | |
1121 | | /* OFPACT_DECAP. |
1122 | | * |
1123 | | * Used for NXAST_DECAP. */ |
1124 | | struct ofpact_decap { |
1125 | | OFPACT_PADDED_MEMBERS( |
1126 | | struct ofpact ofpact; |
1127 | | |
1128 | | /* New packet type. |
1129 | | * |
1130 | | * The special value (0,0xFFFE) "Use next proto" is used to request OVS |
1131 | | * to automatically set the new packet type based on the decap'ed |
1132 | | * header's next protocol. |
1133 | | */ |
1134 | | ovs_be32 new_pkt_type; |
1135 | | ); |
1136 | | }; |
1137 | | |
1138 | | /* Converting OpenFlow to ofpacts. */ |
1139 | | enum ofperr ofpacts_pull_openflow_actions(struct ofpbuf *openflow, |
1140 | | unsigned int actions_len, |
1141 | | enum ofp_version version, |
1142 | | const struct vl_mff_map *, |
1143 | | uint64_t *ofpacts_tlv_bitmap, |
1144 | | struct ofpbuf *ofpacts); |
1145 | | enum ofperr |
1146 | | ofpacts_pull_openflow_instructions(struct ofpbuf *openflow, |
1147 | | unsigned int instructions_len, |
1148 | | enum ofp_version version, |
1149 | | const struct vl_mff_map *vl_mff_map, |
1150 | | uint64_t *ofpacts_tlv_bitmap, |
1151 | | struct ofpbuf *ofpacts); |
1152 | | |
1153 | | struct ofpact_check_params { |
1154 | | /* Input. */ |
1155 | | struct match *match; |
1156 | | ofp_port_t max_ports; |
1157 | | uint8_t table_id; |
1158 | | uint8_t n_tables; |
1159 | | |
1160 | | /* Output. */ |
1161 | | enum ofputil_protocol usable_protocols; |
1162 | | }; |
1163 | | enum ofperr ofpacts_check(struct ofpact[], size_t ofpacts_len, |
1164 | | struct ofpact_check_params *); |
1165 | | enum ofperr ofpacts_check_consistency(struct ofpact[], size_t ofpacts_len, |
1166 | | enum ofputil_protocol needed_protocols, |
1167 | | struct ofpact_check_params *); |
1168 | | enum ofperr ofpact_check_output_port(ofp_port_t port, ofp_port_t max_ports); |
1169 | | |
1170 | | /* Converting ofpacts to OpenFlow. */ |
1171 | | size_t ofpacts_put_openflow_actions(const struct ofpact[], size_t ofpacts_len, |
1172 | | struct ofpbuf *openflow, enum ofp_version); |
1173 | | void ofpacts_put_openflow_instructions(const struct ofpact[], |
1174 | | size_t ofpacts_len, |
1175 | | struct ofpbuf *openflow, |
1176 | | enum ofp_version ofp_version); |
1177 | | |
1178 | | /* Sets of supported actions. */ |
1179 | | ovs_be32 ofpact_bitmap_to_openflow(uint64_t ofpacts_bitmap, enum ofp_version); |
1180 | | uint64_t ofpact_bitmap_from_openflow(ovs_be32 ofpat_bitmap, enum ofp_version); |
1181 | | void ofpact_bitmap_format(uint64_t ofpacts_bitmap, struct ds *); |
1182 | | |
1183 | | /* Working with ofpacts. */ |
1184 | | bool ofpacts_output_to_port(const struct ofpact[], size_t ofpacts_len, |
1185 | | ofp_port_t port); |
1186 | | bool ofpacts_output_to_group(const struct ofpact[], size_t ofpacts_len, |
1187 | | uint32_t group_id); |
1188 | | bool ofpacts_equal(const struct ofpact a[], size_t a_len, |
1189 | | const struct ofpact b[], size_t b_len); |
1190 | | bool ofpacts_equal_stringwise(const struct ofpact a[], size_t a_len, |
1191 | | const struct ofpact b[], size_t b_len); |
1192 | | const struct mf_field *ofpact_get_mf_dst(const struct ofpact *ofpact); |
1193 | | uint32_t ofpacts_get_meter(const struct ofpact[], size_t ofpacts_len); |
1194 | | |
1195 | | /* Formatting ofpacts. */ |
1196 | | struct ofpact_format_params { |
1197 | | /* Input. */ |
1198 | | const struct ofputil_port_map *port_map; |
1199 | | const struct ofputil_table_map *table_map; |
1200 | | |
1201 | | /* Output. */ |
1202 | | struct ds *s; |
1203 | | }; |
1204 | | void ofpacts_format(const struct ofpact[], size_t ofpacts_len, |
1205 | | const struct ofpact_format_params *); |
1206 | | const char *ofpact_name(enum ofpact_type); |
1207 | | |
1208 | | /* Parsing ofpacts. */ |
1209 | | struct ofpact_parse_params { |
1210 | | /* Input. */ |
1211 | | const struct ofputil_port_map *port_map; |
1212 | | const struct ofputil_table_map *table_map; |
1213 | | |
1214 | | /* Output. */ |
1215 | | struct ofpbuf *ofpacts; |
1216 | | enum ofputil_protocol *usable_protocols; |
1217 | | |
1218 | | /* Parse context. */ |
1219 | | unsigned int depth; |
1220 | | }; |
1221 | | #define MAX_OFPACT_PARSE_DEPTH 100 |
1222 | | char *ofpacts_parse_actions(const char *, const struct ofpact_parse_params *) |
1223 | | OVS_WARN_UNUSED_RESULT; |
1224 | | char *ofpacts_parse_instructions(const char *, |
1225 | | const struct ofpact_parse_params *) |
1226 | | OVS_WARN_UNUSED_RESULT; |
1227 | | |
1228 | | /* Internal use by the helpers below. */ |
1229 | | void ofpact_init(struct ofpact *, enum ofpact_type, size_t len); |
1230 | | void *ofpact_put(struct ofpbuf *, enum ofpact_type, size_t len); |
1231 | | void *ofpact_finish(struct ofpbuf *, struct ofpact *); |
1232 | | |
1233 | | /* For each OFPACT_<ENUM> with a corresponding struct <STRUCT>, this defines |
1234 | | * the following commonly useful functions: |
1235 | | * |
1236 | | * struct <STRUCT> *ofpact_put_<ENUM>(struct ofpbuf *ofpacts); |
1237 | | * |
1238 | | * Appends a new 'ofpact', of length OFPACT_<ENUM>_SIZE, to 'ofpacts', |
1239 | | * initializes it with ofpact_init_<ENUM>(), and returns it. Also sets |
1240 | | * 'ofpacts->header' to the returned action. |
1241 | | * |
1242 | | * After using this function to add a variable-length action, add the |
1243 | | * elements of the flexible array (e.g. with ofpbuf_put()), then use |
1244 | | * ofpact_finish() to pad the action to a multiple of OFPACT_ALIGNTO bytes |
1245 | | * and update its embedded length field. (Keep in mind the need to refresh |
1246 | | * the structure from 'ofpacts->header' after adding data to 'ofpacts'.) |
1247 | | * |
1248 | | * struct <STRUCT> *ofpact_get_<ENUM>(const struct ofpact *ofpact); |
1249 | | * |
1250 | | * Returns 'ofpact' cast to "struct <STRUCT> *". 'ofpact->type' must be |
1251 | | * OFPACT_<ENUM>. |
1252 | | * |
1253 | | * void ofpact_finish_<ENUM>(struct ofpbuf *ofpacts, struct <STRUCT> **ap); |
1254 | | * |
1255 | | * Finishes composing variable-length action '*ap' (begun using |
1256 | | * ofpact_put_<NAME>() on 'ofpacts'), by padding the action to a multiple |
1257 | | * of OFPACT_ALIGNTO bytes and updating its embedded length field. |
1258 | | * |
1259 | | * May reallocate 'ofpacts', and so as a convenience automatically updates |
1260 | | * '*ap' to point to the new location. If the caller has other pointers |
1261 | | * within 'ap' or 'ofpacts', it needs to update them manually. |
1262 | | * |
1263 | | * as well as the following more rarely useful definitions: |
1264 | | * |
1265 | | * void ofpact_init_<ENUM>(struct <STRUCT> *ofpact); |
1266 | | * |
1267 | | * Initializes the parts of 'ofpact' that identify it as having type |
1268 | | * OFPACT_<ENUM> and length OFPACT_<ENUM>_SIZE and zeros the rest. |
1269 | | */ |
1270 | | #define OFPACT(ENUM, STRUCT, MEMBER, NAME) \ |
1271 | | BUILD_ASSERT_DECL(offsetof(struct STRUCT, ofpact) == 0); \ |
1272 | | \ |
1273 | | /* Action structures must be a multiple of OFPACT_ALIGNTO bytes. */ \ |
1274 | | BUILD_ASSERT_DECL(sizeof(struct STRUCT) % OFPACT_ALIGNTO == 0); \ |
1275 | | \ |
1276 | | /* Variable-length data must start at a multiple of OFPACT_ALIGNTO \ |
1277 | | * bytes. */ \ |
1278 | | BUILD_ASSERT_DECL(offsetof(struct STRUCT, MEMBER) \ |
1279 | | % OFPACT_ALIGNTO == 0); \ |
1280 | | \ |
1281 | | /* If there is variable-length data, it starts at the end of the \ |
1282 | | * structure. */ \ |
1283 | | BUILD_ASSERT_DECL(!offsetof(struct STRUCT, MEMBER) \ |
1284 | | || (offsetof(struct STRUCT, MEMBER) \ |
1285 | | == sizeof(struct STRUCT))); \ |
1286 | | \ |
1287 | | static inline struct STRUCT * \ |
1288 | | ofpact_get_##ENUM(const struct ofpact *ofpact) \ |
1289 | 0 | { \ |
1290 | 0 | ovs_assert(ofpact->type == OFPACT_##ENUM); \ |
1291 | 0 | return ALIGNED_CAST(struct STRUCT *, ofpact); \ |
1292 | 0 | } \ Unexecuted instantiation: packets.c:ofpact_get_OUTPUT Unexecuted instantiation: packets.c:ofpact_get_GROUP Unexecuted instantiation: packets.c:ofpact_get_CONTROLLER Unexecuted instantiation: packets.c:ofpact_get_ENQUEUE Unexecuted instantiation: packets.c:ofpact_get_OUTPUT_REG Unexecuted instantiation: packets.c:ofpact_get_BUNDLE Unexecuted instantiation: packets.c:ofpact_get_SET_FIELD Unexecuted instantiation: packets.c:ofpact_get_SET_VLAN_VID Unexecuted instantiation: packets.c:ofpact_get_SET_VLAN_PCP Unexecuted instantiation: packets.c:ofpact_get_STRIP_VLAN Unexecuted instantiation: packets.c:ofpact_get_PUSH_VLAN Unexecuted instantiation: packets.c:ofpact_get_SET_ETH_SRC Unexecuted instantiation: packets.c:ofpact_get_SET_ETH_DST Unexecuted instantiation: packets.c:ofpact_get_SET_IPV4_SRC Unexecuted instantiation: packets.c:ofpact_get_SET_IPV4_DST Unexecuted instantiation: packets.c:ofpact_get_SET_IP_DSCP Unexecuted instantiation: packets.c:ofpact_get_SET_IP_ECN Unexecuted instantiation: packets.c:ofpact_get_SET_IP_TTL Unexecuted instantiation: packets.c:ofpact_get_SET_L4_SRC_PORT Unexecuted instantiation: packets.c:ofpact_get_SET_L4_DST_PORT Unexecuted instantiation: packets.c:ofpact_get_REG_MOVE Unexecuted instantiation: packets.c:ofpact_get_STACK_PUSH Unexecuted instantiation: packets.c:ofpact_get_STACK_POP Unexecuted instantiation: packets.c:ofpact_get_DEC_TTL Unexecuted instantiation: packets.c:ofpact_get_SET_MPLS_LABEL Unexecuted instantiation: packets.c:ofpact_get_SET_MPLS_TC Unexecuted instantiation: packets.c:ofpact_get_SET_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_get_DEC_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_get_PUSH_MPLS Unexecuted instantiation: packets.c:ofpact_get_POP_MPLS Unexecuted instantiation: packets.c:ofpact_get_DEC_NSH_TTL Unexecuted instantiation: packets.c:ofpact_get_DELETE_FIELD Unexecuted instantiation: packets.c:ofpact_get_ENCAP Unexecuted instantiation: packets.c:ofpact_get_DECAP Unexecuted instantiation: packets.c:ofpact_get_SET_TUNNEL Unexecuted instantiation: packets.c:ofpact_get_SET_QUEUE Unexecuted instantiation: packets.c:ofpact_get_POP_QUEUE Unexecuted instantiation: packets.c:ofpact_get_FIN_TIMEOUT Unexecuted instantiation: packets.c:ofpact_get_RESUBMIT Unexecuted instantiation: packets.c:ofpact_get_LEARN Unexecuted instantiation: packets.c:ofpact_get_CONJUNCTION Unexecuted instantiation: packets.c:ofpact_get_MULTIPATH Unexecuted instantiation: packets.c:ofpact_get_NOTE Unexecuted instantiation: packets.c:ofpact_get_EXIT Unexecuted instantiation: packets.c:ofpact_get_SAMPLE Unexecuted instantiation: packets.c:ofpact_get_UNROLL_XLATE Unexecuted instantiation: packets.c:ofpact_get_CT Unexecuted instantiation: packets.c:ofpact_get_CT_CLEAR Unexecuted instantiation: packets.c:ofpact_get_NAT Unexecuted instantiation: packets.c:ofpact_get_OUTPUT_TRUNC Unexecuted instantiation: packets.c:ofpact_get_CLONE Unexecuted instantiation: packets.c:ofpact_get_CHECK_PKT_LARGER Unexecuted instantiation: packets.c:ofpact_get_DEBUG_RECIRC Unexecuted instantiation: packets.c:ofpact_get_DEBUG_SLOW Unexecuted instantiation: packets.c:ofpact_get_METER Unexecuted instantiation: packets.c:ofpact_get_CLEAR_ACTIONS Unexecuted instantiation: packets.c:ofpact_get_WRITE_ACTIONS Unexecuted instantiation: packets.c:ofpact_get_WRITE_METADATA Unexecuted instantiation: packets.c:ofpact_get_GOTO_TABLE |
1293 | | \ |
1294 | | static inline struct STRUCT * \ |
1295 | | ofpact_get_##ENUM##_nullable(const struct ofpact *ofpact) \ |
1296 | 0 | { \ |
1297 | 0 | ovs_assert(!ofpact || ofpact->type == OFPACT_##ENUM); \ |
1298 | 0 | return ALIGNED_CAST(struct STRUCT *, ofpact); \ |
1299 | 0 | } \ Unexecuted instantiation: packets.c:ofpact_get_OUTPUT_nullable Unexecuted instantiation: packets.c:ofpact_get_GROUP_nullable Unexecuted instantiation: packets.c:ofpact_get_CONTROLLER_nullable Unexecuted instantiation: packets.c:ofpact_get_ENQUEUE_nullable Unexecuted instantiation: packets.c:ofpact_get_OUTPUT_REG_nullable Unexecuted instantiation: packets.c:ofpact_get_BUNDLE_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_FIELD_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_VLAN_VID_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_VLAN_PCP_nullable Unexecuted instantiation: packets.c:ofpact_get_STRIP_VLAN_nullable Unexecuted instantiation: packets.c:ofpact_get_PUSH_VLAN_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_ETH_SRC_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_ETH_DST_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_IPV4_SRC_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_IPV4_DST_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_IP_DSCP_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_IP_ECN_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_IP_TTL_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_L4_SRC_PORT_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_L4_DST_PORT_nullable Unexecuted instantiation: packets.c:ofpact_get_REG_MOVE_nullable Unexecuted instantiation: packets.c:ofpact_get_STACK_PUSH_nullable Unexecuted instantiation: packets.c:ofpact_get_STACK_POP_nullable Unexecuted instantiation: packets.c:ofpact_get_DEC_TTL_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_MPLS_LABEL_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_MPLS_TC_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_MPLS_TTL_nullable Unexecuted instantiation: packets.c:ofpact_get_DEC_MPLS_TTL_nullable Unexecuted instantiation: packets.c:ofpact_get_PUSH_MPLS_nullable Unexecuted instantiation: packets.c:ofpact_get_POP_MPLS_nullable Unexecuted instantiation: packets.c:ofpact_get_DEC_NSH_TTL_nullable Unexecuted instantiation: packets.c:ofpact_get_DELETE_FIELD_nullable Unexecuted instantiation: packets.c:ofpact_get_ENCAP_nullable Unexecuted instantiation: packets.c:ofpact_get_DECAP_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_TUNNEL_nullable Unexecuted instantiation: packets.c:ofpact_get_SET_QUEUE_nullable Unexecuted instantiation: packets.c:ofpact_get_POP_QUEUE_nullable Unexecuted instantiation: packets.c:ofpact_get_FIN_TIMEOUT_nullable Unexecuted instantiation: packets.c:ofpact_get_RESUBMIT_nullable Unexecuted instantiation: packets.c:ofpact_get_LEARN_nullable Unexecuted instantiation: packets.c:ofpact_get_CONJUNCTION_nullable Unexecuted instantiation: packets.c:ofpact_get_MULTIPATH_nullable Unexecuted instantiation: packets.c:ofpact_get_NOTE_nullable Unexecuted instantiation: packets.c:ofpact_get_EXIT_nullable Unexecuted instantiation: packets.c:ofpact_get_SAMPLE_nullable Unexecuted instantiation: packets.c:ofpact_get_UNROLL_XLATE_nullable Unexecuted instantiation: packets.c:ofpact_get_CT_nullable Unexecuted instantiation: packets.c:ofpact_get_CT_CLEAR_nullable Unexecuted instantiation: packets.c:ofpact_get_NAT_nullable Unexecuted instantiation: packets.c:ofpact_get_OUTPUT_TRUNC_nullable Unexecuted instantiation: packets.c:ofpact_get_CLONE_nullable Unexecuted instantiation: packets.c:ofpact_get_CHECK_PKT_LARGER_nullable Unexecuted instantiation: packets.c:ofpact_get_DEBUG_RECIRC_nullable Unexecuted instantiation: packets.c:ofpact_get_DEBUG_SLOW_nullable Unexecuted instantiation: packets.c:ofpact_get_METER_nullable Unexecuted instantiation: packets.c:ofpact_get_CLEAR_ACTIONS_nullable Unexecuted instantiation: packets.c:ofpact_get_WRITE_ACTIONS_nullable Unexecuted instantiation: packets.c:ofpact_get_WRITE_METADATA_nullable Unexecuted instantiation: packets.c:ofpact_get_GOTO_TABLE_nullable |
1300 | | \ |
1301 | | static inline struct STRUCT * \ |
1302 | | ofpact_put_##ENUM(struct ofpbuf *ofpacts) \ |
1303 | 0 | { \ |
1304 | 0 | return (struct STRUCT *) ofpact_put(ofpacts, OFPACT_##ENUM, \ |
1305 | 0 | sizeof(struct STRUCT)); \ |
1306 | 0 | } \ Unexecuted instantiation: packets.c:ofpact_put_OUTPUT Unexecuted instantiation: packets.c:ofpact_put_GROUP Unexecuted instantiation: packets.c:ofpact_put_CONTROLLER Unexecuted instantiation: packets.c:ofpact_put_ENQUEUE Unexecuted instantiation: packets.c:ofpact_put_OUTPUT_REG Unexecuted instantiation: packets.c:ofpact_put_BUNDLE Unexecuted instantiation: packets.c:ofpact_put_SET_FIELD Unexecuted instantiation: packets.c:ofpact_put_SET_VLAN_VID Unexecuted instantiation: packets.c:ofpact_put_SET_VLAN_PCP Unexecuted instantiation: packets.c:ofpact_put_STRIP_VLAN Unexecuted instantiation: packets.c:ofpact_put_PUSH_VLAN Unexecuted instantiation: packets.c:ofpact_put_SET_ETH_SRC Unexecuted instantiation: packets.c:ofpact_put_SET_ETH_DST Unexecuted instantiation: packets.c:ofpact_put_SET_IPV4_SRC Unexecuted instantiation: packets.c:ofpact_put_SET_IPV4_DST Unexecuted instantiation: packets.c:ofpact_put_SET_IP_DSCP Unexecuted instantiation: packets.c:ofpact_put_SET_IP_ECN Unexecuted instantiation: packets.c:ofpact_put_SET_IP_TTL Unexecuted instantiation: packets.c:ofpact_put_SET_L4_SRC_PORT Unexecuted instantiation: packets.c:ofpact_put_SET_L4_DST_PORT Unexecuted instantiation: packets.c:ofpact_put_REG_MOVE Unexecuted instantiation: packets.c:ofpact_put_STACK_PUSH Unexecuted instantiation: packets.c:ofpact_put_STACK_POP Unexecuted instantiation: packets.c:ofpact_put_DEC_TTL Unexecuted instantiation: packets.c:ofpact_put_SET_MPLS_LABEL Unexecuted instantiation: packets.c:ofpact_put_SET_MPLS_TC Unexecuted instantiation: packets.c:ofpact_put_SET_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_put_DEC_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_put_PUSH_MPLS Unexecuted instantiation: packets.c:ofpact_put_POP_MPLS Unexecuted instantiation: packets.c:ofpact_put_DEC_NSH_TTL Unexecuted instantiation: packets.c:ofpact_put_DELETE_FIELD Unexecuted instantiation: packets.c:ofpact_put_ENCAP Unexecuted instantiation: packets.c:ofpact_put_DECAP Unexecuted instantiation: packets.c:ofpact_put_SET_TUNNEL Unexecuted instantiation: packets.c:ofpact_put_SET_QUEUE Unexecuted instantiation: packets.c:ofpact_put_POP_QUEUE Unexecuted instantiation: packets.c:ofpact_put_FIN_TIMEOUT Unexecuted instantiation: packets.c:ofpact_put_RESUBMIT Unexecuted instantiation: packets.c:ofpact_put_LEARN Unexecuted instantiation: packets.c:ofpact_put_CONJUNCTION Unexecuted instantiation: packets.c:ofpact_put_MULTIPATH Unexecuted instantiation: packets.c:ofpact_put_NOTE Unexecuted instantiation: packets.c:ofpact_put_EXIT Unexecuted instantiation: packets.c:ofpact_put_SAMPLE Unexecuted instantiation: packets.c:ofpact_put_UNROLL_XLATE Unexecuted instantiation: packets.c:ofpact_put_CT Unexecuted instantiation: packets.c:ofpact_put_CT_CLEAR Unexecuted instantiation: packets.c:ofpact_put_NAT Unexecuted instantiation: packets.c:ofpact_put_OUTPUT_TRUNC Unexecuted instantiation: packets.c:ofpact_put_CLONE Unexecuted instantiation: packets.c:ofpact_put_CHECK_PKT_LARGER Unexecuted instantiation: packets.c:ofpact_put_DEBUG_RECIRC Unexecuted instantiation: packets.c:ofpact_put_DEBUG_SLOW Unexecuted instantiation: packets.c:ofpact_put_METER Unexecuted instantiation: packets.c:ofpact_put_CLEAR_ACTIONS Unexecuted instantiation: packets.c:ofpact_put_WRITE_ACTIONS Unexecuted instantiation: packets.c:ofpact_put_WRITE_METADATA Unexecuted instantiation: packets.c:ofpact_put_GOTO_TABLE |
1307 | | \ |
1308 | | static inline void \ |
1309 | | ofpact_init_##ENUM(struct STRUCT *ofpact) \ |
1310 | 0 | { \ |
1311 | 0 | ofpact_init(&ofpact->ofpact, OFPACT_##ENUM, \ |
1312 | 0 | sizeof(struct STRUCT)); \ |
1313 | 0 | } \ Unexecuted instantiation: packets.c:ofpact_init_OUTPUT Unexecuted instantiation: packets.c:ofpact_init_GROUP Unexecuted instantiation: packets.c:ofpact_init_CONTROLLER Unexecuted instantiation: packets.c:ofpact_init_ENQUEUE Unexecuted instantiation: packets.c:ofpact_init_OUTPUT_REG Unexecuted instantiation: packets.c:ofpact_init_BUNDLE Unexecuted instantiation: packets.c:ofpact_init_SET_FIELD Unexecuted instantiation: packets.c:ofpact_init_SET_VLAN_VID Unexecuted instantiation: packets.c:ofpact_init_SET_VLAN_PCP Unexecuted instantiation: packets.c:ofpact_init_STRIP_VLAN Unexecuted instantiation: packets.c:ofpact_init_PUSH_VLAN Unexecuted instantiation: packets.c:ofpact_init_SET_ETH_SRC Unexecuted instantiation: packets.c:ofpact_init_SET_ETH_DST Unexecuted instantiation: packets.c:ofpact_init_SET_IPV4_SRC Unexecuted instantiation: packets.c:ofpact_init_SET_IPV4_DST Unexecuted instantiation: packets.c:ofpact_init_SET_IP_DSCP Unexecuted instantiation: packets.c:ofpact_init_SET_IP_ECN Unexecuted instantiation: packets.c:ofpact_init_SET_IP_TTL Unexecuted instantiation: packets.c:ofpact_init_SET_L4_SRC_PORT Unexecuted instantiation: packets.c:ofpact_init_SET_L4_DST_PORT Unexecuted instantiation: packets.c:ofpact_init_REG_MOVE Unexecuted instantiation: packets.c:ofpact_init_STACK_PUSH Unexecuted instantiation: packets.c:ofpact_init_STACK_POP Unexecuted instantiation: packets.c:ofpact_init_DEC_TTL Unexecuted instantiation: packets.c:ofpact_init_SET_MPLS_LABEL Unexecuted instantiation: packets.c:ofpact_init_SET_MPLS_TC Unexecuted instantiation: packets.c:ofpact_init_SET_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_init_DEC_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_init_PUSH_MPLS Unexecuted instantiation: packets.c:ofpact_init_POP_MPLS Unexecuted instantiation: packets.c:ofpact_init_DEC_NSH_TTL Unexecuted instantiation: packets.c:ofpact_init_DELETE_FIELD Unexecuted instantiation: packets.c:ofpact_init_ENCAP Unexecuted instantiation: packets.c:ofpact_init_DECAP Unexecuted instantiation: packets.c:ofpact_init_SET_TUNNEL Unexecuted instantiation: packets.c:ofpact_init_SET_QUEUE Unexecuted instantiation: packets.c:ofpact_init_POP_QUEUE Unexecuted instantiation: packets.c:ofpact_init_FIN_TIMEOUT Unexecuted instantiation: packets.c:ofpact_init_RESUBMIT Unexecuted instantiation: packets.c:ofpact_init_LEARN Unexecuted instantiation: packets.c:ofpact_init_CONJUNCTION Unexecuted instantiation: packets.c:ofpact_init_MULTIPATH Unexecuted instantiation: packets.c:ofpact_init_NOTE Unexecuted instantiation: packets.c:ofpact_init_EXIT Unexecuted instantiation: packets.c:ofpact_init_SAMPLE Unexecuted instantiation: packets.c:ofpact_init_UNROLL_XLATE Unexecuted instantiation: packets.c:ofpact_init_CT Unexecuted instantiation: packets.c:ofpact_init_CT_CLEAR Unexecuted instantiation: packets.c:ofpact_init_NAT Unexecuted instantiation: packets.c:ofpact_init_OUTPUT_TRUNC Unexecuted instantiation: packets.c:ofpact_init_CLONE Unexecuted instantiation: packets.c:ofpact_init_CHECK_PKT_LARGER Unexecuted instantiation: packets.c:ofpact_init_DEBUG_RECIRC Unexecuted instantiation: packets.c:ofpact_init_DEBUG_SLOW Unexecuted instantiation: packets.c:ofpact_init_METER Unexecuted instantiation: packets.c:ofpact_init_CLEAR_ACTIONS Unexecuted instantiation: packets.c:ofpact_init_WRITE_ACTIONS Unexecuted instantiation: packets.c:ofpact_init_WRITE_METADATA Unexecuted instantiation: packets.c:ofpact_init_GOTO_TABLE |
1314 | | \ |
1315 | | static inline void \ |
1316 | | ofpact_finish_##ENUM(struct ofpbuf *ofpbuf, struct STRUCT **ofpactp) \ |
1317 | 0 | { \ |
1318 | 0 | struct ofpact *ofpact = &(*ofpactp)->ofpact; \ |
1319 | 0 | ovs_assert(ofpact->type == OFPACT_##ENUM); \ |
1320 | 0 | *ofpactp = (struct STRUCT *) ofpact_finish(ofpbuf, ofpact); \ |
1321 | 0 | } Unexecuted instantiation: packets.c:ofpact_finish_OUTPUT Unexecuted instantiation: packets.c:ofpact_finish_GROUP Unexecuted instantiation: packets.c:ofpact_finish_CONTROLLER Unexecuted instantiation: packets.c:ofpact_finish_ENQUEUE Unexecuted instantiation: packets.c:ofpact_finish_OUTPUT_REG Unexecuted instantiation: packets.c:ofpact_finish_BUNDLE Unexecuted instantiation: packets.c:ofpact_finish_SET_FIELD Unexecuted instantiation: packets.c:ofpact_finish_SET_VLAN_VID Unexecuted instantiation: packets.c:ofpact_finish_SET_VLAN_PCP Unexecuted instantiation: packets.c:ofpact_finish_STRIP_VLAN Unexecuted instantiation: packets.c:ofpact_finish_PUSH_VLAN Unexecuted instantiation: packets.c:ofpact_finish_SET_ETH_SRC Unexecuted instantiation: packets.c:ofpact_finish_SET_ETH_DST Unexecuted instantiation: packets.c:ofpact_finish_SET_IPV4_SRC Unexecuted instantiation: packets.c:ofpact_finish_SET_IPV4_DST Unexecuted instantiation: packets.c:ofpact_finish_SET_IP_DSCP Unexecuted instantiation: packets.c:ofpact_finish_SET_IP_ECN Unexecuted instantiation: packets.c:ofpact_finish_SET_IP_TTL Unexecuted instantiation: packets.c:ofpact_finish_SET_L4_SRC_PORT Unexecuted instantiation: packets.c:ofpact_finish_SET_L4_DST_PORT Unexecuted instantiation: packets.c:ofpact_finish_REG_MOVE Unexecuted instantiation: packets.c:ofpact_finish_STACK_PUSH Unexecuted instantiation: packets.c:ofpact_finish_STACK_POP Unexecuted instantiation: packets.c:ofpact_finish_DEC_TTL Unexecuted instantiation: packets.c:ofpact_finish_SET_MPLS_LABEL Unexecuted instantiation: packets.c:ofpact_finish_SET_MPLS_TC Unexecuted instantiation: packets.c:ofpact_finish_SET_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_finish_DEC_MPLS_TTL Unexecuted instantiation: packets.c:ofpact_finish_PUSH_MPLS Unexecuted instantiation: packets.c:ofpact_finish_POP_MPLS Unexecuted instantiation: packets.c:ofpact_finish_DEC_NSH_TTL Unexecuted instantiation: packets.c:ofpact_finish_DELETE_FIELD Unexecuted instantiation: packets.c:ofpact_finish_ENCAP Unexecuted instantiation: packets.c:ofpact_finish_DECAP Unexecuted instantiation: packets.c:ofpact_finish_SET_TUNNEL Unexecuted instantiation: packets.c:ofpact_finish_SET_QUEUE Unexecuted instantiation: packets.c:ofpact_finish_POP_QUEUE Unexecuted instantiation: packets.c:ofpact_finish_FIN_TIMEOUT Unexecuted instantiation: packets.c:ofpact_finish_RESUBMIT Unexecuted instantiation: packets.c:ofpact_finish_LEARN Unexecuted instantiation: packets.c:ofpact_finish_CONJUNCTION Unexecuted instantiation: packets.c:ofpact_finish_MULTIPATH Unexecuted instantiation: packets.c:ofpact_finish_NOTE Unexecuted instantiation: packets.c:ofpact_finish_EXIT Unexecuted instantiation: packets.c:ofpact_finish_SAMPLE Unexecuted instantiation: packets.c:ofpact_finish_UNROLL_XLATE Unexecuted instantiation: packets.c:ofpact_finish_CT Unexecuted instantiation: packets.c:ofpact_finish_CT_CLEAR Unexecuted instantiation: packets.c:ofpact_finish_NAT Unexecuted instantiation: packets.c:ofpact_finish_OUTPUT_TRUNC Unexecuted instantiation: packets.c:ofpact_finish_CLONE Unexecuted instantiation: packets.c:ofpact_finish_CHECK_PKT_LARGER Unexecuted instantiation: packets.c:ofpact_finish_DEBUG_RECIRC Unexecuted instantiation: packets.c:ofpact_finish_DEBUG_SLOW Unexecuted instantiation: packets.c:ofpact_finish_METER Unexecuted instantiation: packets.c:ofpact_finish_CLEAR_ACTIONS Unexecuted instantiation: packets.c:ofpact_finish_WRITE_ACTIONS Unexecuted instantiation: packets.c:ofpact_finish_WRITE_METADATA Unexecuted instantiation: packets.c:ofpact_finish_GOTO_TABLE |
1322 | | OFPACTS |
1323 | | #undef OFPACT |
1324 | | |
1325 | | /* Additional functions for composing ofpacts. */ |
1326 | | struct ofpact_set_field *ofpact_put_set_field(struct ofpbuf *ofpacts, |
1327 | | const struct mf_field *, |
1328 | | const void *value, |
1329 | | const void *mask); |
1330 | | struct ofpact_set_field *ofpact_put_reg_load(struct ofpbuf *ofpacts, |
1331 | | const struct mf_field *, |
1332 | | const void *value, |
1333 | | const void *mask); |
1334 | | struct ofpact_set_field *ofpact_put_reg_load2(struct ofpbuf *ofpacts, |
1335 | | const struct mf_field *, |
1336 | | const void *value, |
1337 | | const void *mask); |
1338 | | |
1339 | | /* OpenFlow 1.1 instructions. |
1340 | | * The order is sorted in execution order. Not in the value of OFPIT11_xxx. |
1341 | | * It is enforced on parser from text string. |
1342 | | */ |
1343 | | #define OVS_INSTRUCTIONS \ |
1344 | | DEFINE_INST(OFPIT13_METER, \ |
1345 | | ofp13_instruction_meter, false, \ |
1346 | | "meter") \ |
1347 | | \ |
1348 | | DEFINE_INST(OFPIT11_APPLY_ACTIONS, \ |
1349 | | ofp11_instruction_actions, true, \ |
1350 | | "apply_actions") \ |
1351 | | \ |
1352 | | DEFINE_INST(OFPIT11_CLEAR_ACTIONS, \ |
1353 | | ofp11_instruction, false, \ |
1354 | | "clear_actions") \ |
1355 | | \ |
1356 | | DEFINE_INST(OFPIT11_WRITE_ACTIONS, \ |
1357 | | ofp11_instruction_actions, true, \ |
1358 | | "write_actions") \ |
1359 | | \ |
1360 | | DEFINE_INST(OFPIT11_WRITE_METADATA, \ |
1361 | | ofp11_instruction_write_metadata, false, \ |
1362 | | "write_metadata") \ |
1363 | | \ |
1364 | | DEFINE_INST(OFPIT11_GOTO_TABLE, \ |
1365 | | ofp11_instruction_goto_table, false, \ |
1366 | | "goto_table") |
1367 | | |
1368 | | enum ovs_instruction_type { |
1369 | | #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) OVSINST_##ENUM, |
1370 | | OVS_INSTRUCTIONS |
1371 | | #undef DEFINE_INST |
1372 | | }; |
1373 | | |
1374 | | enum { |
1375 | | #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) + 1 |
1376 | | N_OVS_INSTRUCTIONS = OVS_INSTRUCTIONS |
1377 | | #undef DEFINE_INST |
1378 | | }; |
1379 | | |
1380 | | const char *ovs_instruction_name_from_type(enum ovs_instruction_type type); |
1381 | | int ovs_instruction_type_from_name(const char *name); |
1382 | | enum ovs_instruction_type ovs_instruction_type_from_ofpact_type( |
1383 | | enum ofpact_type, enum ofp_version); |
1384 | | enum ofperr ovs_instruction_type_from_inst_type( |
1385 | | enum ovs_instruction_type *instruction_type, const uint16_t inst_type); |
1386 | | |
1387 | | ovs_be32 ovsinst_bitmap_to_openflow(uint32_t ovsinst_bitmap, enum ofp_version); |
1388 | | uint32_t ovsinst_bitmap_from_openflow(ovs_be32 ofpit_bitmap, |
1389 | | enum ofp_version); |
1390 | | |
1391 | | #ifdef __cplusplus |
1392 | | } |
1393 | | #endif |
1394 | | |
1395 | | #endif /* ofp-actions.h */ |