]> git.proxmox.com Git - mirror_ovs.git/blob - include/openvswitch/ofp-actions.h
conntrack: Force commit.
[mirror_ovs.git] / include / openvswitch / ofp-actions.h
1 /*
2 * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 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-util.h"
26 #include "openvswitch/ofp-errors.h"
27 #include "openvswitch/types.h"
28
29 struct vl_mff_map;
30
31 /* List of OVS abstracted actions.
32 *
33 * This macro is used directly only internally by this header, but the list is
34 * still of interest to developers.
35 *
36 * Each OFPACT invocation has the following parameters:
37 *
38 * 1. <ENUM>, used below in the enum definition of OFPACT_<ENUM>, and
39 * elsewhere.
40 *
41 * 2. <STRUCT> corresponding to a structure "struct <STRUCT>", that must be
42 * defined below. This structure must be an abstract definition of the
43 * action. Its first member must have type "struct ofpact" and name
44 * "ofpact". It may be fixed length or end with a flexible array member
45 * (e.g. "int member[];").
46 *
47 * 3. <MEMBER>, which has one of two possible values:
48 *
49 * - If "struct <STRUCT>" is fixed-length, it must be "ofpact".
50 *
51 * - If "struct <STRUCT>" is variable-length, it must be the name of the
52 * flexible array member.
53 *
54 * 4. <NAME>, a quoted string that gives the name of the action, for use in
55 * parsing actions from text.
56 */
57 #define OFPACTS \
58 /* Output. */ \
59 OFPACT(OUTPUT, ofpact_output, ofpact, "output") \
60 OFPACT(GROUP, ofpact_group, ofpact, "group") \
61 OFPACT(CONTROLLER, ofpact_controller, userdata, "controller") \
62 OFPACT(ENQUEUE, ofpact_enqueue, ofpact, "enqueue") \
63 OFPACT(OUTPUT_REG, ofpact_output_reg, ofpact, "output_reg") \
64 OFPACT(BUNDLE, ofpact_bundle, slaves, "bundle") \
65 \
66 /* Header changes. */ \
67 OFPACT(SET_FIELD, ofpact_set_field, ofpact, "set_field") \
68 OFPACT(SET_VLAN_VID, ofpact_vlan_vid, ofpact, "set_vlan_vid") \
69 OFPACT(SET_VLAN_PCP, ofpact_vlan_pcp, ofpact, "set_vlan_pcp") \
70 OFPACT(STRIP_VLAN, ofpact_null, ofpact, "strip_vlan") \
71 OFPACT(PUSH_VLAN, ofpact_null, ofpact, "push_vlan") \
72 OFPACT(SET_ETH_SRC, ofpact_mac, ofpact, "mod_dl_src") \
73 OFPACT(SET_ETH_DST, ofpact_mac, ofpact, "mod_dl_dst") \
74 OFPACT(SET_IPV4_SRC, ofpact_ipv4, ofpact, "mod_nw_src") \
75 OFPACT(SET_IPV4_DST, ofpact_ipv4, ofpact, "mod_nw_dst") \
76 OFPACT(SET_IP_DSCP, ofpact_dscp, ofpact, "mod_nw_tos") \
77 OFPACT(SET_IP_ECN, ofpact_ecn, ofpact, "mod_nw_ecn") \
78 OFPACT(SET_IP_TTL, ofpact_ip_ttl, ofpact, "mod_nw_ttl") \
79 OFPACT(SET_L4_SRC_PORT, ofpact_l4_port, ofpact, "mod_tp_src") \
80 OFPACT(SET_L4_DST_PORT, ofpact_l4_port, ofpact, "mod_tp_dst") \
81 OFPACT(REG_MOVE, ofpact_reg_move, ofpact, "move") \
82 OFPACT(STACK_PUSH, ofpact_stack, ofpact, "push") \
83 OFPACT(STACK_POP, ofpact_stack, ofpact, "pop") \
84 OFPACT(DEC_TTL, ofpact_cnt_ids, cnt_ids, "dec_ttl") \
85 OFPACT(SET_MPLS_LABEL, ofpact_mpls_label, ofpact, "set_mpls_label") \
86 OFPACT(SET_MPLS_TC, ofpact_mpls_tc, ofpact, "set_mpls_tc") \
87 OFPACT(SET_MPLS_TTL, ofpact_mpls_ttl, ofpact, "set_mpls_ttl") \
88 OFPACT(DEC_MPLS_TTL, ofpact_null, ofpact, "dec_mpls_ttl") \
89 OFPACT(PUSH_MPLS, ofpact_push_mpls, ofpact, "push_mpls") \
90 OFPACT(POP_MPLS, ofpact_pop_mpls, ofpact, "pop_mpls") \
91 \
92 /* Metadata. */ \
93 OFPACT(SET_TUNNEL, ofpact_tunnel, ofpact, "set_tunnel") \
94 OFPACT(SET_QUEUE, ofpact_queue, ofpact, "set_queue") \
95 OFPACT(POP_QUEUE, ofpact_null, ofpact, "pop_queue") \
96 OFPACT(FIN_TIMEOUT, ofpact_fin_timeout, ofpact, "fin_timeout") \
97 \
98 /* Flow table interaction. */ \
99 OFPACT(RESUBMIT, ofpact_resubmit, ofpact, "resubmit") \
100 OFPACT(LEARN, ofpact_learn, specs, "learn") \
101 OFPACT(CONJUNCTION, ofpact_conjunction, ofpact, "conjunction") \
102 \
103 /* Arithmetic. */ \
104 OFPACT(MULTIPATH, ofpact_multipath, ofpact, "multipath") \
105 \
106 /* Other. */ \
107 OFPACT(NOTE, ofpact_note, data, "note") \
108 OFPACT(EXIT, ofpact_null, ofpact, "exit") \
109 OFPACT(SAMPLE, ofpact_sample, ofpact, "sample") \
110 OFPACT(UNROLL_XLATE, ofpact_unroll_xlate, ofpact, "unroll_xlate") \
111 OFPACT(CT, ofpact_conntrack, ofpact, "ct") \
112 OFPACT(CT_CLEAR, ofpact_null, ofpact, "ct_clear") \
113 OFPACT(NAT, ofpact_nat, ofpact, "nat") \
114 OFPACT(OUTPUT_TRUNC, ofpact_output_trunc,ofpact, "output_trunc") \
115 OFPACT(CLONE, ofpact_nest, actions, "clone") \
116 \
117 /* Debugging actions. \
118 * \
119 * These are intentionally undocumented, subject to change, and \
120 * only accepted if ovs-vswitchd is started with --enable-dummy. */ \
121 OFPACT(DEBUG_RECIRC, ofpact_null, ofpact, "debug_recirc") \
122 \
123 /* Instructions. */ \
124 OFPACT(METER, ofpact_meter, ofpact, "meter") \
125 OFPACT(CLEAR_ACTIONS, ofpact_null, ofpact, "clear_actions") \
126 OFPACT(WRITE_ACTIONS, ofpact_nest, actions, "write_actions") \
127 OFPACT(WRITE_METADATA, ofpact_metadata, ofpact, "write_metadata") \
128 OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact, "goto_table")
129
130 /* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
131 enum OVS_PACKED_ENUM ofpact_type {
132 #define OFPACT(ENUM, STRUCT, MEMBER, NAME) OFPACT_##ENUM,
133 OFPACTS
134 #undef OFPACT
135 };
136
137 /* Define N_OFPACTS to the number of types of ofpacts. */
138 enum {
139 #define OFPACT(ENUM, STRUCT, MEMBER, NAME) + 1
140 N_OFPACTS = OFPACTS
141 #undef OFPACT
142 };
143
144 /* Header for an action.
145 *
146 * Each action is a structure "struct ofpact_*" that begins with "struct
147 * ofpact", usually followed by other data that describes the action. Actions
148 * are padded out to a multiple of OFPACT_ALIGNTO bytes in length.
149 *
150 * The 'raw' member is special:
151 *
152 * - Most "struct ofpact"s correspond to one particular kind of OpenFlow
153 * action, at least in a given OpenFlow version. For example,
154 * OFPACT_SET_VLAN_VID corresponds to OFPAT10_SET_VLAN_VID in OpenFlow
155 * 1.0.
156 *
157 * For such actions, the 'raw' member is not meaningful and generally
158 * should be zero.
159 *
160 * - A few "struct ofpact"s correspond to multiple OpenFlow actions. For
161 * example, OFPACT_SET_TUNNEL can be NXAST_SET_TUNNEL or
162 * NXAST_SET_TUNNEL64. In these cases, if the "struct ofpact" originated
163 * from OpenFlow, then we want to make sure that, if it gets translated
164 * back to OpenFlow later, it is translated back to the same action type.
165 * (Otherwise, we'd violate the promise made in the topics/design doc, in
166 * the "Action Reproduction" section.)
167 *
168 * For such actions, the 'raw' member should be the "enum ofp_raw_action"
169 * originally extracted from the OpenFlow action. (If the action didn't
170 * originate from OpenFlow, then setting 'raw' to zero should be fine:
171 * code to translate the ofpact to OpenFlow must tolerate this case.)
172 */
173 struct ofpact {
174 /* We want the space advantage of an 8-bit type here on every
175 * implementation, without giving up the advantage of having a useful type
176 * on implementations that support packed enums. */
177 #ifdef HAVE_PACKED_ENUM
178 enum ofpact_type type; /* OFPACT_*. */
179 #else
180 uint8_t type; /* OFPACT_* */
181 #endif
182
183 uint8_t raw; /* Original type when added, if any. */
184 uint16_t len; /* Length of the action, in bytes, including
185 * struct ofpact, excluding padding. */
186 };
187 BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4);
188
189 /* Alignment. */
190 #define OFPACT_ALIGNTO 8
191 #define OFPACT_ALIGN(SIZE) ROUND_UP(SIZE, OFPACT_ALIGNTO)
192 #define OFPACT_PADDED_MEMBERS(MEMBERS) PADDED_MEMBERS(OFPACT_ALIGNTO, MEMBERS)
193
194 /* Returns the ofpact following 'ofpact'. */
195 static inline struct ofpact *
196 ofpact_next(const struct ofpact *ofpact)
197 {
198 return (void *) ((uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len));
199 }
200
201 struct ofpact *ofpact_next_flattened(const struct ofpact *);
202
203 static inline struct ofpact *
204 ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
205 {
206 return (void *) ((uint8_t *) ofpacts + ofpacts_len);
207 }
208
209 static inline const struct ofpact *
210 ofpact_find_type_flattened(const struct ofpact *a, enum ofpact_type type,
211 const struct ofpact * const end)
212 {
213 while (a < end) {
214 if (a->type == type) {
215 return a;
216 }
217 a = ofpact_next_flattened(a);
218 }
219 return NULL;
220 }
221
222 #define OFPACT_FIND_TYPE_FLATTENED(A, TYPE, END) \
223 ofpact_get_##TYPE##_nullable( \
224 ofpact_find_type_flattened(A, OFPACT_##TYPE, END))
225
226 /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
227 * starting at OFPACTS. */
228 #define OFPACT_FOR_EACH(POS, OFPACTS, OFPACTS_LEN) \
229 for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
230 (POS) = ofpact_next(POS))
231
232 /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
233 * starting at OFPACTS.
234 *
235 * For ofpacts that contain nested ofpacts, this visits each of the inner
236 * ofpacts as well. */
237 #define OFPACT_FOR_EACH_FLATTENED(POS, OFPACTS, OFPACTS_LEN) \
238 for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
239 (POS) = ofpact_next_flattened(POS))
240
241 #define OFPACT_FOR_EACH_TYPE_FLATTENED(POS, TYPE, OFPACTS, OFPACTS_LEN) \
242 for ((POS) = OFPACT_FIND_TYPE_FLATTENED(OFPACTS, TYPE, \
243 ofpact_end(OFPACTS, OFPACTS_LEN)); \
244 (POS); \
245 (POS) = OFPACT_FIND_TYPE_FLATTENED( \
246 ofpact_next_flattened(&(POS)->ofpact), TYPE, \
247 ofpact_end(OFPACTS, OFPACTS_LEN)))
248 \f
249 /* Action structure for each OFPACT_*. */
250
251 /* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS.
252 *
253 * Used for OFPAT10_STRIP_VLAN, NXAST_POP_QUEUE, NXAST_EXIT,
254 * OFPAT11_POP_VLAN, OFPIT11_CLEAR_ACTIONS.
255 *
256 * Action structure for actions that do not have any extra data beyond the
257 * action type. */
258 struct ofpact_null {
259 struct ofpact ofpact;
260 };
261
262 /* OFPACT_OUTPUT.
263 *
264 * Used for OFPAT10_OUTPUT. */
265 struct ofpact_output {
266 struct ofpact ofpact;
267 ofp_port_t port; /* Output port. */
268 uint16_t max_len; /* Max send len, for port OFPP_CONTROLLER. */
269 };
270
271 /* OFPACT_CONTROLLER.
272 *
273 * Used for NXAST_CONTROLLER. */
274 struct ofpact_controller {
275 OFPACT_PADDED_MEMBERS(
276 struct ofpact ofpact;
277 uint16_t max_len; /* Max length to send to controller. */
278 uint16_t controller_id; /* Controller ID to send packet-in. */
279 enum ofp_packet_in_reason reason; /* Reason to put in packet-in. */
280
281 /* If true, this action freezes packet traversal of the OpenFlow
282 * tables and adds a continuation to the packet-in message, that
283 * a controller can use to resume that traversal. */
284 bool pause;
285
286 /* Arbitrary data to include in the packet-in message (currently,
287 * only in NXT_PACKET_IN2). */
288 uint16_t userdata_len;
289 );
290 uint8_t userdata[0];
291 };
292
293 /* OFPACT_ENQUEUE.
294 *
295 * Used for OFPAT10_ENQUEUE. */
296 struct ofpact_enqueue {
297 struct ofpact ofpact;
298 ofp_port_t port;
299 uint32_t queue;
300 };
301
302 /* OFPACT_OUTPUT_REG.
303 *
304 * Used for NXAST_OUTPUT_REG. */
305 struct ofpact_output_reg {
306 struct ofpact ofpact;
307 uint16_t max_len;
308 struct mf_subfield src;
309 };
310
311 /* OFPACT_OUTPUT_TRUNC.
312 *
313 * Used for NXAST_OUTPUT_TRUNC. */
314 struct ofpact_output_trunc {
315 struct ofpact ofpact;
316 ofp_port_t port; /* Output port. */
317 uint32_t max_len; /* Max send len. */
318 };
319
320 /* Bundle slave choice algorithm to apply.
321 *
322 * In the descriptions below, 'slaves' is the list of possible slaves in the
323 * order they appear in the OpenFlow action. */
324 enum nx_bd_algorithm {
325 /* Chooses the first live slave listed in the bundle.
326 *
327 * O(n_slaves) performance. */
328 NX_BD_ALG_ACTIVE_BACKUP = 0,
329
330 /* Highest Random Weight.
331 *
332 * for i in [0,n_slaves):
333 * weights[i] = hash(flow, i)
334 * slave = { slaves[i] such that weights[i] >= weights[j] for all j != i }
335 *
336 * Redistributes 1/n_slaves of traffic when a slave's liveness changes.
337 * O(n_slaves) performance.
338 *
339 * Uses the 'fields' and 'basis' parameters. */
340 NX_BD_ALG_HRW = 1
341 };
342
343 /* OFPACT_BUNDLE.
344 *
345 * Used for NXAST_BUNDLE. */
346 struct ofpact_bundle {
347 struct ofpact ofpact;
348
349 /* Slave choice algorithm to apply to hash value. */
350 enum nx_bd_algorithm algorithm;
351
352 /* What fields to hash and how. */
353 enum nx_hash_fields fields;
354 uint16_t basis; /* Universal hash parameter. */
355
356 struct mf_subfield dst;
357
358 /* Slaves for output. */
359 unsigned int n_slaves;
360 ofp_port_t slaves[];
361 };
362
363 /* OFPACT_SET_VLAN_VID.
364 *
365 * We keep track if vlan was present at action validation time to avoid a
366 * PUSH_VLAN when translating to OpenFlow 1.1+.
367 *
368 * We also keep the originating OFPUTIL action code in ofpact.compat.
369 *
370 * Used for OFPAT10_SET_VLAN_VID and OFPAT11_SET_VLAN_VID. */
371 struct ofpact_vlan_vid {
372 struct ofpact ofpact;
373 uint16_t vlan_vid; /* VLAN VID in low 12 bits, 0 in other bits. */
374 bool push_vlan_if_needed; /* OF 1.0 semantics if true. */
375 bool flow_has_vlan; /* VLAN present at action validation time? */
376 };
377
378 /* OFPACT_SET_VLAN_PCP.
379 *
380 * We keep track if vlan was present at action validation time to avoid a
381 * PUSH_VLAN when translating to OpenFlow 1.1+.
382 *
383 * We also keep the originating OFPUTIL action code in ofpact.compat.
384 *
385 * Used for OFPAT10_SET_VLAN_PCP and OFPAT11_SET_VLAN_PCP. */
386 struct ofpact_vlan_pcp {
387 struct ofpact ofpact;
388 uint8_t vlan_pcp; /* VLAN PCP in low 3 bits, 0 in other bits. */
389 bool push_vlan_if_needed; /* OF 1.0 semantics if true. */
390 bool flow_has_vlan; /* VLAN present at action validation time? */
391 };
392
393 /* OFPACT_SET_ETH_SRC, OFPACT_SET_ETH_DST.
394 *
395 * Used for OFPAT10_SET_DL_SRC, OFPAT10_SET_DL_DST. */
396 struct ofpact_mac {
397 struct ofpact ofpact;
398 struct eth_addr mac;
399 };
400
401 /* OFPACT_SET_IPV4_SRC, OFPACT_SET_IPV4_DST.
402 *
403 * Used for OFPAT10_SET_NW_SRC, OFPAT10_SET_NW_DST. */
404 struct ofpact_ipv4 {
405 struct ofpact ofpact;
406 ovs_be32 ipv4;
407 };
408
409 /* OFPACT_SET_IP_DSCP.
410 *
411 * Used for OFPAT10_SET_NW_TOS. */
412 struct ofpact_dscp {
413 struct ofpact ofpact;
414 uint8_t dscp; /* DSCP in high 6 bits, rest ignored. */
415 };
416
417 /* OFPACT_SET_IP_ECN.
418 *
419 * Used for OFPAT11_SET_NW_ECN. */
420 struct ofpact_ecn {
421 struct ofpact ofpact;
422 uint8_t ecn; /* ECN in low 2 bits, rest ignored. */
423 };
424
425 /* OFPACT_SET_IP_TTL.
426 *
427 * Used for OFPAT11_SET_NW_TTL. */
428 struct ofpact_ip_ttl {
429 struct ofpact ofpact;
430 uint8_t ttl;
431 };
432
433 /* OFPACT_SET_L4_SRC_PORT, OFPACT_SET_L4_DST_PORT.
434 *
435 * Used for OFPAT10_SET_TP_SRC, OFPAT10_SET_TP_DST. */
436 struct ofpact_l4_port {
437 struct ofpact ofpact;
438 uint16_t port; /* TCP, UDP or SCTP port number. */
439 uint8_t flow_ip_proto; /* IP proto from corresponding match, or 0 */
440 };
441
442 /* OFPACT_REG_MOVE.
443 *
444 * Used for NXAST_REG_MOVE. */
445 struct ofpact_reg_move {
446 struct ofpact ofpact;
447 struct mf_subfield src;
448 struct mf_subfield dst;
449 };
450
451 /* OFPACT_STACK_PUSH.
452 *
453 * Used for NXAST_STACK_PUSH and NXAST_STACK_POP. */
454 struct ofpact_stack {
455 struct ofpact ofpact;
456 struct mf_subfield subfield;
457 };
458
459 /* OFPACT_SET_FIELD.
460 *
461 * Used for NXAST_REG_LOAD and OFPAT12_SET_FIELD. */
462 struct ofpact_set_field {
463 OFPACT_PADDED_MEMBERS(
464 struct ofpact ofpact;
465 bool flow_has_vlan; /* VLAN present at action validation time. */
466 const struct mf_field *field;
467 );
468 union mf_value value[]; /* Significant value bytes followed by
469 * significant mask bytes. */
470 };
471 BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value)
472 % OFPACT_ALIGNTO == 0);
473 BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value)
474 == sizeof(struct ofpact_set_field));
475
476 /* Use macro to not have to deal with constness. */
477 #define ofpact_set_field_mask(SF) \
478 ALIGNED_CAST(union mf_value *, \
479 (uint8_t *)(SF)->value + (SF)->field->n_bytes)
480
481 /* OFPACT_PUSH_VLAN/MPLS/PBB
482 *
483 * Used for NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */
484 struct ofpact_push_mpls {
485 struct ofpact ofpact;
486 ovs_be16 ethertype;
487 };
488
489 /* OFPACT_POP_MPLS
490 *
491 * Used for NXAST_POP_MPLS, OFPAT11_POP_MPLS.. */
492 struct ofpact_pop_mpls {
493 struct ofpact ofpact;
494 ovs_be16 ethertype;
495 };
496
497 /* OFPACT_SET_TUNNEL.
498 *
499 * Used for NXAST_SET_TUNNEL, NXAST_SET_TUNNEL64. */
500 struct ofpact_tunnel {
501 struct ofpact ofpact;
502 uint64_t tun_id;
503 };
504
505 /* OFPACT_SET_QUEUE.
506 *
507 * Used for NXAST_SET_QUEUE. */
508 struct ofpact_queue {
509 struct ofpact ofpact;
510 uint32_t queue_id;
511 };
512
513 /* OFPACT_FIN_TIMEOUT.
514 *
515 * Used for NXAST_FIN_TIMEOUT. */
516 struct ofpact_fin_timeout {
517 struct ofpact ofpact;
518 uint16_t fin_idle_timeout;
519 uint16_t fin_hard_timeout;
520 };
521
522 /* OFPACT_WRITE_METADATA.
523 *
524 * Used for NXAST_WRITE_METADATA. */
525 struct ofpact_metadata {
526 struct ofpact ofpact;
527 ovs_be64 metadata;
528 ovs_be64 mask;
529 };
530
531 /* OFPACT_METER.
532 *
533 * Used for OFPIT13_METER. */
534 struct ofpact_meter {
535 struct ofpact ofpact;
536 uint32_t meter_id;
537 uint32_t provider_meter_id;
538 };
539
540 /* OFPACT_WRITE_ACTIONS, OFPACT_CLONE.
541 *
542 * Used for OFPIT11_WRITE_ACTIONS, NXAST_CLONE. */
543 struct ofpact_nest {
544 OFPACT_PADDED_MEMBERS(struct ofpact ofpact;);
545 struct ofpact actions[];
546 };
547 BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions) % OFPACT_ALIGNTO == 0);
548 BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions)
549 == sizeof(struct ofpact_nest));
550
551 static inline size_t
552 ofpact_nest_get_action_len(const struct ofpact_nest *on)
553 {
554 return on->ofpact.len - offsetof(struct ofpact_nest, actions);
555 }
556
557 /* Bits for 'flags' in struct nx_action_conntrack.
558 *
559 * If NX_CT_F_COMMIT is set, then the connection entry is moved from the
560 * unconfirmed to confirmed list in the tracker.
561 * If NX_CT_F_FORCE is set, in addition to NX_CT_F_COMMIT, then the conntrack
562 * entry is replaced with a new one in case the original direction of the
563 * existing entry is opposite of the current packet direction.
564 */
565 enum nx_conntrack_flags {
566 NX_CT_F_COMMIT = 1 << 0,
567 NX_CT_F_FORCE = 1 << 1,
568 };
569
570 /* Magic value for struct nx_action_conntrack 'recirc_table' field, to specify
571 * that the packet should not be recirculated. */
572 #define NX_CT_RECIRC_NONE OFPTT_ALL
573
574 #if !defined(IPPORT_FTP)
575 #define IPPORT_FTP 21
576 #endif
577
578 #if !defined(IPPORT_TFTP)
579 #define IPPORT_TFTP 69
580 #endif
581
582 /* OFPACT_CT.
583 *
584 * Used for NXAST_CT. */
585 struct ofpact_conntrack {
586 OFPACT_PADDED_MEMBERS(
587 struct ofpact ofpact;
588 uint16_t flags;
589 uint16_t zone_imm;
590 struct mf_subfield zone_src;
591 uint16_t alg;
592 uint8_t recirc_table;
593 );
594 struct ofpact actions[0];
595 };
596 BUILD_ASSERT_DECL(offsetof(struct ofpact_conntrack, actions)
597 % OFPACT_ALIGNTO == 0);
598 BUILD_ASSERT_DECL(offsetof(struct ofpact_conntrack, actions)
599 == sizeof(struct ofpact_conntrack));
600
601 static inline size_t
602 ofpact_ct_get_action_len(const struct ofpact_conntrack *oc)
603 {
604 return oc->ofpact.len - offsetof(struct ofpact_conntrack, actions);
605 }
606
607 void ofpacts_execute_action_set(struct ofpbuf *action_list,
608 const struct ofpbuf *action_set);
609
610 /* Bits for 'flags' in struct nx_action_nat.
611 */
612 enum nx_nat_flags {
613 NX_NAT_F_SRC = 1 << 0, /* Mutually exclusive with NX_NAT_F_DST. */
614 NX_NAT_F_DST = 1 << 1,
615 NX_NAT_F_PERSISTENT = 1 << 2,
616 NX_NAT_F_PROTO_HASH = 1 << 3, /* Mutually exclusive with PROTO_RANDOM. */
617 NX_NAT_F_PROTO_RANDOM = 1 << 4,
618 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)
619 };
620
621 /* OFPACT_NAT.
622 *
623 * Used for NXAST_NAT. */
624 struct ofpact_nat {
625 struct ofpact ofpact;
626 uint8_t range_af; /* AF_UNSPEC, AF_INET, or AF_INET6 */
627 uint16_t flags; /* NX_NAT_F_* */
628 struct {
629 struct {
630 uint16_t min;
631 uint16_t max;
632 } proto;
633 union {
634 struct {
635 ovs_be32 min;
636 ovs_be32 max;
637 } ipv4;
638 struct {
639 struct in6_addr min;
640 struct in6_addr max;
641 } ipv6;
642 } addr;
643 } range;
644 };
645
646
647 /* OFPACT_RESUBMIT.
648 *
649 * Used for NXAST_RESUBMIT, NXAST_RESUBMIT_TABLE, NXAST_RESUBMIT_TABLE_CT. */
650 struct ofpact_resubmit {
651 struct ofpact ofpact;
652 ofp_port_t in_port;
653 uint8_t table_id;
654 bool with_ct_orig; /* Resubmit with Conntrack original direction tuple
655 * fields in place of IP header fields. */
656 };
657
658 /* Bits for 'flags' in struct nx_action_learn.
659 *
660 * If NX_LEARN_F_SEND_FLOW_REM is set, then the learned flows will have their
661 * OFPFF_SEND_FLOW_REM flag set.
662 *
663 * If NX_LEARN_F_DELETE_LEARNED is set, then removing this action will delete
664 * all the flows from the learn action's 'table_id' that have the learn
665 * action's 'cookie'. Important points:
666 *
667 * - The deleted flows include those created by this action, those created
668 * by other learn actions with the same 'table_id' and 'cookie', those
669 * created by flow_mod requests by a controller in the specified table
670 * with the specified cookie, and those created through any other
671 * means.
672 *
673 * - If multiple flows specify "learn" actions with
674 * NX_LEARN_F_DELETE_LEARNED with the same 'table_id' and 'cookie', then
675 * no deletion occurs until all of those "learn" actions are deleted.
676 *
677 * - Deleting a flow that contains a learn action is the most obvious way
678 * to delete a learn action. Modifying a flow's actions, or replacing it
679 * by a new flow, can also delete a learn action. Finally, replacing a
680 * learn action with NX_LEARN_F_DELETE_LEARNED with a learn action
681 * without that flag also effectively deletes the learn action and can
682 * trigger flow deletion.
683 *
684 * NX_LEARN_F_DELETE_LEARNED was added in Open vSwitch 2.4. */
685 enum nx_learn_flags {
686 NX_LEARN_F_SEND_FLOW_REM = 1 << 0,
687 NX_LEARN_F_DELETE_LEARNED = 1 << 1,
688 };
689
690 #define NX_LEARN_N_BITS_MASK 0x3ff
691
692 #define NX_LEARN_SRC_FIELD (0 << 13) /* Copy from field. */
693 #define NX_LEARN_SRC_IMMEDIATE (1 << 13) /* Copy from immediate value. */
694 #define NX_LEARN_SRC_MASK (1 << 13)
695
696 #define NX_LEARN_DST_MATCH (0 << 11) /* Add match criterion. */
697 #define NX_LEARN_DST_LOAD (1 << 11) /* Add NXAST_REG_LOAD action. */
698 #define NX_LEARN_DST_OUTPUT (2 << 11) /* Add OFPAT_OUTPUT action. */
699 #define NX_LEARN_DST_RESERVED (3 << 11) /* Not yet defined. */
700 #define NX_LEARN_DST_MASK (3 << 11)
701
702 /* Part of struct ofpact_learn, below. */
703 struct ofpact_learn_spec {
704 OFPACT_PADDED_MEMBERS(
705 struct mf_subfield src; /* NX_LEARN_SRC_FIELD only. */
706 struct mf_subfield dst; /* NX_LEARN_DST_MATCH,
707 * NX_LEARN_DST_LOAD only. */
708 uint16_t src_type; /* One of NX_LEARN_SRC_*. */
709 uint16_t dst_type; /* One of NX_LEARN_DST_*. */
710 uint8_t n_bits; /* Number of bits in source and dest. */
711 );
712 /* Followed by 'DIV_ROUND_UP(n_bits, 8)' bytes of immediate data for
713 * match 'dst_type's NX_LEARN_DST_MATCH and NX_LEARN_DST_LOAD when
714 * NX_LEARN_SRC_IMMEDIATE is set in 'src_type', followed by zeroes to align
715 * to OFPACT_ALIGNTO. */
716 };
717 BUILD_ASSERT_DECL(sizeof(struct ofpact_learn_spec) % OFPACT_ALIGNTO == 0);
718
719 static inline const void *
720 ofpact_learn_spec_imm(const struct ofpact_learn_spec *spec)
721 {
722 return spec + 1;
723 }
724
725 static inline const struct ofpact_learn_spec *
726 ofpact_learn_spec_next(const struct ofpact_learn_spec *spec)
727 {
728 if (spec->src_type == NX_LEARN_SRC_IMMEDIATE) {
729 unsigned int n_bytes = OFPACT_ALIGN(DIV_ROUND_UP(spec->n_bits, 8));
730 return ALIGNED_CAST(const struct ofpact_learn_spec *,
731 (const uint8_t *)(spec + 1) + n_bytes);
732 }
733 return spec + 1;
734 }
735
736 /* OFPACT_LEARN.
737 *
738 * Used for NXAST_LEARN. */
739 struct ofpact_learn {
740 OFPACT_PADDED_MEMBERS(
741 struct ofpact ofpact;
742
743 uint16_t idle_timeout; /* Idle time before discarding (seconds). */
744 uint16_t hard_timeout; /* Max time before discarding (seconds). */
745 uint16_t priority; /* Priority level of flow entry. */
746 uint8_t table_id; /* Table to insert flow entry. */
747 enum nx_learn_flags flags; /* NX_LEARN_F_*. */
748 ovs_be64 cookie; /* Cookie for new flow. */
749 uint16_t fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */
750 uint16_t fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */
751 );
752
753 struct ofpact_learn_spec specs[];
754 };
755
756 static inline const struct ofpact_learn_spec *
757 ofpact_learn_spec_end(const struct ofpact_learn *learn)
758 {
759 return ALIGNED_CAST(const struct ofpact_learn_spec *,
760 ofpact_next(&learn->ofpact));
761 }
762
763 #define OFPACT_LEARN_SPEC_FOR_EACH(SPEC, LEARN) \
764 for ((SPEC) = (LEARN)->specs; \
765 (SPEC) < ofpact_learn_spec_end(LEARN); \
766 (SPEC) = ofpact_learn_spec_next(SPEC))
767
768 /* Multipath link choice algorithm to apply.
769 *
770 * In the descriptions below, 'n_links' is max_link + 1. */
771 enum nx_mp_algorithm {
772 /* link = hash(flow) % n_links.
773 *
774 * Redistributes all traffic when n_links changes. O(1) performance. See
775 * RFC 2992.
776 *
777 * Use UINT16_MAX for max_link to get a raw hash value. */
778 NX_MP_ALG_MODULO_N = 0,
779
780 /* link = hash(flow) / (MAX_HASH / n_links).
781 *
782 * Redistributes between one-quarter and one-half of traffic when n_links
783 * changes. O(1) performance. See RFC 2992.
784 */
785 NX_MP_ALG_HASH_THRESHOLD = 1,
786
787 /* Highest Random Weight.
788 *
789 * for i in [0,n_links):
790 * weights[i] = hash(flow, i)
791 * link = { i such that weights[i] >= weights[j] for all j != i }
792 *
793 * Redistributes 1/n_links of traffic when n_links changes. O(n_links)
794 * performance. If n_links is greater than a threshold (currently 64, but
795 * subject to change), Open vSwitch will substitute another algorithm
796 * automatically. See RFC 2992. */
797 NX_MP_ALG_HRW = 2,
798
799 /* Iterative Hash.
800 *
801 * i = 0
802 * repeat:
803 * i = i + 1
804 * link = hash(flow, i) % arg
805 * while link > max_link
806 *
807 * Redistributes 1/n_links of traffic when n_links changes. O(1)
808 * performance when arg/max_link is bounded by a constant.
809 *
810 * Redistributes all traffic when arg changes.
811 *
812 * arg must be greater than max_link and for best performance should be no
813 * more than approximately max_link * 2. If arg is outside the acceptable
814 * range, Open vSwitch will automatically substitute the least power of 2
815 * greater than max_link.
816 *
817 * This algorithm is specific to Open vSwitch.
818 */
819 NX_MP_ALG_ITER_HASH = 3,
820 };
821
822 /* OFPACT_CONJUNCTION.
823 *
824 * Used for NXAST_CONJUNCTION. */
825 struct ofpact_conjunction {
826 struct ofpact ofpact;
827 uint8_t clause;
828 uint8_t n_clauses;
829 uint32_t id;
830 };
831
832 /* OFPACT_MULTIPATH.
833 *
834 * Used for NXAST_MULTIPATH. */
835 struct ofpact_multipath {
836 struct ofpact ofpact;
837
838 /* What fields to hash and how. */
839 enum nx_hash_fields fields;
840 uint16_t basis; /* Universal hash parameter. */
841
842 /* Multipath link choice algorithm to apply to hash value. */
843 enum nx_mp_algorithm algorithm;
844 uint16_t max_link; /* Number of output links, minus 1. */
845 uint32_t arg; /* Algorithm-specific argument. */
846
847 /* Where to store the result. */
848 struct mf_subfield dst;
849 };
850
851 /* OFPACT_NOTE.
852 *
853 * Used for NXAST_NOTE. */
854 struct ofpact_note {
855 struct ofpact ofpact;
856 size_t length;
857 uint8_t data[];
858 };
859
860 /* Direction of sampled packets. */
861 enum nx_action_sample_direction {
862 /* OVS will attempt to infer the sample's direction based on whether
863 * 'sampling_port' is the packet's output port. This is generally
864 * effective except when sampling happens as part of an output to a patch
865 * port, which doesn't involve a datapath output action. */
866 NX_ACTION_SAMPLE_DEFAULT,
867
868 /* Explicit direction. This is useful for sampling packets coming in from
869 * or going out of a patch port, where the direction cannot be inferred. */
870 NX_ACTION_SAMPLE_INGRESS,
871 NX_ACTION_SAMPLE_EGRESS
872 };
873
874 /* OFPACT_SAMPLE.
875 *
876 * Used for NXAST_SAMPLE, NXAST_SAMPLE2, and NXAST_SAMPLE3. */
877 struct ofpact_sample {
878 struct ofpact ofpact;
879 uint16_t probability; /* Always positive. */
880 uint32_t collector_set_id;
881 uint32_t obs_domain_id;
882 uint32_t obs_point_id;
883 ofp_port_t sampling_port;
884 enum nx_action_sample_direction direction;
885 };
886
887 /* OFPACT_DEC_TTL.
888 *
889 * Used for OFPAT11_DEC_NW_TTL, NXAST_DEC_TTL and NXAST_DEC_TTL_CNT_IDS. */
890 struct ofpact_cnt_ids {
891 struct ofpact ofpact;
892
893 /* Controller ids. */
894 unsigned int n_controllers;
895 uint16_t cnt_ids[];
896 };
897
898 /* OFPACT_SET_MPLS_LABEL.
899 *
900 * Used for OFPAT11_SET_MPLS_LABEL and NXAST_SET_MPLS_LABEL */
901 struct ofpact_mpls_label {
902 struct ofpact ofpact;
903
904 ovs_be32 label;
905 };
906
907 /* OFPACT_SET_MPLS_TC.
908 *
909 * Used for OFPAT11_SET_MPLS_TC and NXAST_SET_MPLS_TC */
910 struct ofpact_mpls_tc {
911 struct ofpact ofpact;
912
913 uint8_t tc;
914 };
915
916 /* OFPACT_SET_MPLS_TTL.
917 *
918 * Used for OFPAT11_SET_MPLS_TTL and NXAST_SET_MPLS_TTL */
919 struct ofpact_mpls_ttl {
920 struct ofpact ofpact;
921
922 uint8_t ttl;
923 };
924
925 /* OFPACT_GOTO_TABLE
926 *
927 * Used for OFPIT11_GOTO_TABLE */
928 struct ofpact_goto_table {
929 struct ofpact ofpact;
930 uint8_t table_id;
931 };
932
933 /* OFPACT_GROUP.
934 *
935 * Used for OFPAT11_GROUP. */
936 struct ofpact_group {
937 struct ofpact ofpact;
938 uint32_t group_id;
939 };
940
941 /* OFPACT_UNROLL_XLATE.
942 *
943 * Used only internally. */
944 struct ofpact_unroll_xlate {
945 struct ofpact ofpact;
946
947 /* Metadata in xlate context, visible to controller via PACKET_INs. */
948 uint8_t rule_table_id; /* 0xFF if none. */
949 ovs_be64 rule_cookie; /* OVS_BE64_MAX if none. */
950 };
951
952 /* Converting OpenFlow to ofpacts. */
953 enum ofperr ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
954 unsigned int actions_len,
955 enum ofp_version version,
956 const struct vl_mff_map *,
957 struct ofpbuf *ofpacts);
958 enum ofperr
959 ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
960 unsigned int instructions_len,
961 enum ofp_version version,
962 const struct vl_mff_map *vl_mff_map,
963 struct ofpbuf *ofpacts);
964 enum ofperr ofpacts_check(struct ofpact[], size_t ofpacts_len,
965 struct match *, ofp_port_t max_ports,
966 uint8_t table_id, uint8_t n_tables,
967 enum ofputil_protocol *usable_protocols);
968 enum ofperr ofpacts_check_consistency(struct ofpact[], size_t ofpacts_len,
969 struct match *, ofp_port_t max_ports,
970 uint8_t table_id, uint8_t n_tables,
971 enum ofputil_protocol usable_protocols);
972 enum ofperr ofpact_check_output_port(ofp_port_t port, ofp_port_t max_ports);
973
974 /* Converting ofpacts to OpenFlow. */
975 size_t ofpacts_put_openflow_actions(const struct ofpact[], size_t ofpacts_len,
976 struct ofpbuf *openflow, enum ofp_version);
977 void ofpacts_put_openflow_instructions(const struct ofpact[],
978 size_t ofpacts_len,
979 struct ofpbuf *openflow,
980 enum ofp_version ofp_version);
981
982 /* Sets of supported actions. */
983 ovs_be32 ofpact_bitmap_to_openflow(uint64_t ofpacts_bitmap, enum ofp_version);
984 uint64_t ofpact_bitmap_from_openflow(ovs_be32 ofpat_bitmap, enum ofp_version);
985 void ofpact_bitmap_format(uint64_t ofpacts_bitmap, struct ds *);
986
987 /* Working with ofpacts. */
988 bool ofpacts_output_to_port(const struct ofpact[], size_t ofpacts_len,
989 ofp_port_t port);
990 bool ofpacts_output_to_group(const struct ofpact[], size_t ofpacts_len,
991 uint32_t group_id);
992 bool ofpacts_equal(const struct ofpact a[], size_t a_len,
993 const struct ofpact b[], size_t b_len);
994 const struct mf_field *ofpact_get_mf_dst(const struct ofpact *ofpact);
995 uint32_t ofpacts_get_meter(const struct ofpact[], size_t ofpacts_len);
996
997 /* Formatting and parsing ofpacts. */
998 void ofpacts_format(const struct ofpact[], size_t ofpacts_len, struct ds *);
999 char *ofpacts_parse_actions(const char *, struct ofpbuf *ofpacts,
1000 enum ofputil_protocol *usable_protocols)
1001 OVS_WARN_UNUSED_RESULT;
1002 char *ofpacts_parse_instructions(const char *, struct ofpbuf *ofpacts,
1003 enum ofputil_protocol *usable_protocols)
1004 OVS_WARN_UNUSED_RESULT;
1005 const char *ofpact_name(enum ofpact_type);
1006
1007 /* Internal use by the helpers below. */
1008 void ofpact_init(struct ofpact *, enum ofpact_type, size_t len);
1009 void *ofpact_put(struct ofpbuf *, enum ofpact_type, size_t len);
1010 void *ofpact_finish(struct ofpbuf *, struct ofpact *);
1011
1012 /* For each OFPACT_<ENUM> with a corresponding struct <STRUCT>, this defines
1013 * the following commonly useful functions:
1014 *
1015 * struct <STRUCT> *ofpact_put_<ENUM>(struct ofpbuf *ofpacts);
1016 *
1017 * Appends a new 'ofpact', of length OFPACT_<ENUM>_SIZE, to 'ofpacts',
1018 * initializes it with ofpact_init_<ENUM>(), and returns it. Also sets
1019 * 'ofpacts->header' to the returned action.
1020 *
1021 * After using this function to add a variable-length action, add the
1022 * elements of the flexible array (e.g. with ofpbuf_put()), then use
1023 * ofpact_finish() to pad the action to a multiple of OFPACT_ALIGNTO bytes
1024 * and update its embedded length field. (Keep in mind the need to refresh
1025 * the structure from 'ofpacts->header' after adding data to 'ofpacts'.)
1026 *
1027 * struct <STRUCT> *ofpact_get_<ENUM>(const struct ofpact *ofpact);
1028 *
1029 * Returns 'ofpact' cast to "struct <STRUCT> *". 'ofpact->type' must be
1030 * OFPACT_<ENUM>.
1031 *
1032 * void ofpact_finish_<ENUM>(struct ofpbuf *ofpacts, struct <STRUCT> **ap);
1033 *
1034 * Finishes composing variable-length action '*ap' (begun using
1035 * ofpact_put_<NAME>() on 'ofpacts'), by padding the action to a multiple
1036 * of OFPACT_ALIGNTO bytes and updating its embedded length field.
1037 *
1038 * May reallocate 'ofpacts', and so as a convenience automatically updates
1039 * '*ap' to point to the new location. If the caller has other pointers
1040 * within 'ap' or 'ofpacts', it needs to update them manually.
1041 *
1042 * as well as the following more rarely useful definitions:
1043 *
1044 * void ofpact_init_<ENUM>(struct <STRUCT> *ofpact);
1045 *
1046 * Initializes the parts of 'ofpact' that identify it as having type
1047 * OFPACT_<ENUM> and length OFPACT_<ENUM>_SIZE and zeros the rest.
1048 *
1049 * <ENUM>_SIZE
1050 *
1051 * The size of the action structure. For a fixed-length action, this is
1052 * sizeof(struct <STRUCT>) rounded up to a multiple of OFPACT_ALIGNTO. For
1053 * a variable-length action, this is the offset to the variable-length
1054 * part.
1055 */
1056 #define OFPACT(ENUM, STRUCT, MEMBER, NAME) \
1057 BUILD_ASSERT_DECL(offsetof(struct STRUCT, ofpact) == 0); \
1058 \
1059 enum { OFPACT_##ENUM##_SIZE \
1060 = (offsetof(struct STRUCT, MEMBER) \
1061 ? offsetof(struct STRUCT, MEMBER) \
1062 : OFPACT_ALIGN(sizeof(struct STRUCT))) }; \
1063 \
1064 static inline struct STRUCT * \
1065 ofpact_get_##ENUM(const struct ofpact *ofpact) \
1066 { \
1067 ovs_assert(ofpact->type == OFPACT_##ENUM); \
1068 return ALIGNED_CAST(struct STRUCT *, ofpact); \
1069 } \
1070 \
1071 static inline struct STRUCT * \
1072 ofpact_get_##ENUM##_nullable(const struct ofpact *ofpact) \
1073 { \
1074 ovs_assert(!ofpact || ofpact->type == OFPACT_##ENUM); \
1075 return ALIGNED_CAST(struct STRUCT *, ofpact); \
1076 } \
1077 \
1078 static inline struct STRUCT * \
1079 ofpact_put_##ENUM(struct ofpbuf *ofpacts) \
1080 { \
1081 return ofpact_put(ofpacts, OFPACT_##ENUM, \
1082 OFPACT_##ENUM##_SIZE); \
1083 } \
1084 \
1085 static inline void \
1086 ofpact_init_##ENUM(struct STRUCT *ofpact) \
1087 { \
1088 ofpact_init(&ofpact->ofpact, OFPACT_##ENUM, \
1089 OFPACT_##ENUM##_SIZE); \
1090 } \
1091 \
1092 static inline void \
1093 ofpact_finish_##ENUM(struct ofpbuf *ofpbuf, struct STRUCT **ofpactp) \
1094 { \
1095 struct ofpact *ofpact = &(*ofpactp)->ofpact; \
1096 ovs_assert(ofpact->type == OFPACT_##ENUM); \
1097 *ofpactp = ofpact_finish(ofpbuf, ofpact); \
1098 }
1099 OFPACTS
1100 #undef OFPACT
1101
1102 /* Additional functions for composing ofpacts. */
1103 struct ofpact_set_field *ofpact_put_set_field(struct ofpbuf *ofpacts,
1104 const struct mf_field *,
1105 const void *value,
1106 const void *mask);
1107 struct ofpact_set_field *ofpact_put_reg_load(struct ofpbuf *ofpacts,
1108 const struct mf_field *,
1109 const void *value,
1110 const void *mask);
1111 struct ofpact_set_field *ofpact_put_reg_load2(struct ofpbuf *ofpacts,
1112 const struct mf_field *,
1113 const void *value,
1114 const void *mask);
1115
1116 /* OpenFlow 1.1 instructions.
1117 * The order is sorted in execution order. Not in the value of OFPIT11_xxx.
1118 * It is enforced on parser from text string.
1119 */
1120 #define OVS_INSTRUCTIONS \
1121 DEFINE_INST(OFPIT13_METER, \
1122 ofp13_instruction_meter, false, \
1123 "meter") \
1124 \
1125 DEFINE_INST(OFPIT11_APPLY_ACTIONS, \
1126 ofp11_instruction_actions, true, \
1127 "apply_actions") \
1128 \
1129 DEFINE_INST(OFPIT11_CLEAR_ACTIONS, \
1130 ofp11_instruction, false, \
1131 "clear_actions") \
1132 \
1133 DEFINE_INST(OFPIT11_WRITE_ACTIONS, \
1134 ofp11_instruction_actions, true, \
1135 "write_actions") \
1136 \
1137 DEFINE_INST(OFPIT11_WRITE_METADATA, \
1138 ofp11_instruction_write_metadata, false, \
1139 "write_metadata") \
1140 \
1141 DEFINE_INST(OFPIT11_GOTO_TABLE, \
1142 ofp11_instruction_goto_table, false, \
1143 "goto_table")
1144
1145 enum ovs_instruction_type {
1146 #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) OVSINST_##ENUM,
1147 OVS_INSTRUCTIONS
1148 #undef DEFINE_INST
1149 };
1150
1151 enum {
1152 #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
1153 N_OVS_INSTRUCTIONS = OVS_INSTRUCTIONS
1154 #undef DEFINE_INST
1155 };
1156
1157 const char *ovs_instruction_name_from_type(enum ovs_instruction_type type);
1158 int ovs_instruction_type_from_name(const char *name);
1159 enum ovs_instruction_type ovs_instruction_type_from_ofpact_type(
1160 enum ofpact_type);
1161 enum ofperr ovs_instruction_type_from_inst_type(
1162 enum ovs_instruction_type *instruction_type, const uint16_t inst_type);
1163
1164 ovs_be32 ovsinst_bitmap_to_openflow(uint32_t ovsinst_bitmap, enum ofp_version);
1165 uint32_t ovsinst_bitmap_from_openflow(ovs_be32 ofpit_bitmap,
1166 enum ofp_version);
1167
1168 #endif /* ofp-actions.h */