]> git.proxmox.com Git - mirror_ovs.git/blob - ovn/lib/actions.h
ovn: Add 'na' action and lflow for ND
[mirror_ovs.git] / ovn / lib / actions.h
1 /*
2 * Copyright (c) 2015, 2016 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 OVN_ACTIONS_H
18 #define OVN_ACTIONS_H 1
19
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include "compiler.h"
23 #include "util.h"
24
25 struct expr;
26 struct lexer;
27 struct ofpbuf;
28 struct shash;
29 struct simap;
30
31 enum action_opcode {
32 /* "arp { ...actions... }".
33 *
34 * The actions, in OpenFlow 1.3 format, follow the action_header.
35 */
36 ACTION_OPCODE_ARP,
37
38 /* "put_arp(port, ip, mac)"
39 *
40 * Arguments are passed through the packet metadata and data, as follows:
41 *
42 * MFF_REG0 = ip
43 * MFF_LOG_INPORT = port
44 * MFF_ETH_SRC = mac
45 */
46 ACTION_OPCODE_PUT_ARP,
47
48 /* "result = put_dhcp_opts(offer_ip, option, ...)".
49 *
50 * Arguments follow the action_header, in this format:
51 * - A 32-bit or 64-bit OXM header designating the result field.
52 * - A 32-bit integer specifying a bit offset within the result field.
53 * - The 32-bit DHCP offer IP.
54 * - Any number of DHCP options.
55 */
56 ACTION_OPCODE_PUT_DHCP_OPTS,
57
58 /* "na { ...actions... }".
59 *
60 * The actions, in OpenFlow 1.3 format, follow the action_header.
61 */
62 ACTION_OPCODE_NA,
63 };
64
65 /* Header. */
66 struct action_header {
67 ovs_be32 opcode; /* One of ACTION_OPCODE_* */
68 uint8_t pad[4];
69 };
70 BUILD_ASSERT_DECL(sizeof(struct action_header) == 8);
71
72 struct action_params {
73 /* A table of "struct expr_symbol"s to support (as one would provide to
74 * expr_parse()). */
75 const struct shash *symtab;
76
77 /* hmap of 'struct dhcp_opts_map' to support 'put_dhcp_opts' action */
78 const struct hmap *dhcp_opts;
79
80 /* Looks up logical port 'port_name'. If found, stores its port number in
81 * '*portp' and returns true; otherwise, returns false. */
82 bool (*lookup_port)(const void *aux, const char *port_name,
83 unsigned int *portp);
84 const void *aux;
85
86 /* A map from a port name to its connection tracking zone. */
87 const struct simap *ct_zones;
88
89 /* OVN maps each logical flow table (ltable), one-to-one, onto a physical
90 * OpenFlow flow table (ptable). A number of parameters describe this
91 * mapping and data related to flow tables:
92 *
93 * - 'first_ptable' and 'n_tables' define the range of OpenFlow tables
94 * to which the logical "next" action should be able to jump.
95 * Logical table 0 maps to OpenFlow table 'first_ptable', logical
96 * table 1 to 'first_ptable + 1', and so on. If 'n_tables' is 0
97 * then "next" is disallowed entirely.
98 *
99 * - 'cur_ltable' is an offset from 'first_ptable' (e.g. 0 <=
100 * cur_ltable < n_ptables) of the logical flow that contains the
101 * actions. If cur_ltable + 1 < n_tables, then this defines the
102 * default table that "next" will jump to.
103 *
104 * - 'output_ptable' should be the OpenFlow table to which the logical
105 * "output" action will resubmit. */
106 uint8_t n_tables; /* Number of flow tables. */
107 uint8_t first_ptable; /* First OpenFlow table. */
108 uint8_t cur_ltable; /* 0 <= cur_ltable < n_tables. */
109 uint8_t output_ptable; /* OpenFlow table for 'output' to resubmit. */
110 uint8_t arp_ptable; /* OpenFlow table for 'get_arp' to resubmit. */
111 };
112
113 char *actions_parse(struct lexer *, const struct action_params *,
114 struct ofpbuf *ofpacts, struct expr **prereqsp)
115 OVS_WARN_UNUSED_RESULT;
116 char *actions_parse_string(const char *s, const struct action_params *,
117 struct ofpbuf *ofpacts, struct expr **prereqsp)
118 OVS_WARN_UNUSED_RESULT;
119
120 #endif /* ovn/actions.h */