]> git.proxmox.com Git - ovs.git/blame - ovn/lib/actions.h
ovn: Support multiple addresses on a single logical router port.
[ovs.git] / ovn / lib / actions.h
CommitLineData
3b7cb7e1 1/*
6335d074 2 * Copyright (c) 2015, 2016 Nicira, Inc.
3b7cb7e1
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef OVN_ACTIONS_H
18#define OVN_ACTIONS_H 1
19
f1c16a85 20#include <stdbool.h>
3b7cb7e1
BP
21#include <stdint.h>
22#include "compiler.h"
467085fd
GS
23#include "hmap.h"
24#include "openvswitch/dynamic-string.h"
6335d074 25#include "util.h"
3b7cb7e1
BP
26
27struct expr;
28struct lexer;
29struct ofpbuf;
30struct shash;
31struct simap;
32
467085fd
GS
33#define MAX_OVN_GROUPS 65535
34
35struct group_table {
36 unsigned long *group_ids; /* Used as a bitmap with value set
37 * for allocated group ids in either
38 * desired_groups or existing_groups. */
39 struct hmap desired_groups;
40 struct hmap existing_groups;
41};
42
43struct group_info {
44 struct hmap_node hmap_node;
45 struct ds group;
46 uint32_t group_id;
47};
48
6335d074
BP
49enum action_opcode {
50 /* "arp { ...actions... }".
51 *
52 * The actions, in OpenFlow 1.3 format, follow the action_header.
53 */
54 ACTION_OPCODE_ARP,
0bac7164
BP
55
56 /* "put_arp(port, ip, mac)"
57 *
58 * Arguments are passed through the packet metadata and data, as follows:
59 *
60 * MFF_REG0 = ip
61 * MFF_LOG_INPORT = port
62 * MFF_ETH_SRC = mac
63 */
64 ACTION_OPCODE_PUT_ARP,
42814145
NS
65
66 /* "result = put_dhcp_opts(offer_ip, option, ...)".
67 *
68 * Arguments follow the action_header, in this format:
69 * - A 32-bit or 64-bit OXM header designating the result field.
70 * - A 32-bit integer specifying a bit offset within the result field.
71 * - The 32-bit DHCP offer IP.
72 * - Any number of DHCP options.
73 */
74 ACTION_OPCODE_PUT_DHCP_OPTS,
e75451fe
ZKL
75
76 /* "na { ...actions... }".
77 *
78 * The actions, in OpenFlow 1.3 format, follow the action_header.
79 */
80 ACTION_OPCODE_NA,
6335d074
BP
81};
82
83/* Header. */
84struct action_header {
85 ovs_be32 opcode; /* One of ACTION_OPCODE_* */
86 uint8_t pad[4];
87};
88BUILD_ASSERT_DECL(sizeof(struct action_header) == 8);
89
1d7b2ece
BP
90struct action_params {
91 /* A table of "struct expr_symbol"s to support (as one would provide to
92 * expr_parse()). */
93 const struct shash *symtab;
94
42814145
NS
95 /* hmap of 'struct dhcp_opts_map' to support 'put_dhcp_opts' action */
96 const struct hmap *dhcp_opts;
97
f1c16a85
BP
98 /* Looks up logical port 'port_name'. If found, stores its port number in
99 * '*portp' and returns true; otherwise, returns false. */
100 bool (*lookup_port)(const void *aux, const char *port_name,
101 unsigned int *portp);
102 const void *aux;
1d7b2ece
BP
103
104 /* A map from a port name to its connection tracking zone. */
105 const struct simap *ct_zones;
106
467085fd
GS
107 /* A struct to figure out the group_id for group actions. */
108 struct group_table *group_table;
109
1d7b2ece
BP
110 /* OVN maps each logical flow table (ltable), one-to-one, onto a physical
111 * OpenFlow flow table (ptable). A number of parameters describe this
112 * mapping and data related to flow tables:
113 *
114 * - 'first_ptable' and 'n_tables' define the range of OpenFlow tables
115 * to which the logical "next" action should be able to jump.
116 * Logical table 0 maps to OpenFlow table 'first_ptable', logical
117 * table 1 to 'first_ptable + 1', and so on. If 'n_tables' is 0
118 * then "next" is disallowed entirely.
119 *
120 * - 'cur_ltable' is an offset from 'first_ptable' (e.g. 0 <=
121 * cur_ltable < n_ptables) of the logical flow that contains the
122 * actions. If cur_ltable + 1 < n_tables, then this defines the
123 * default table that "next" will jump to.
124 *
125 * - 'output_ptable' should be the OpenFlow table to which the logical
126 * "output" action will resubmit. */
127 uint8_t n_tables; /* Number of flow tables. */
128 uint8_t first_ptable; /* First OpenFlow table. */
129 uint8_t cur_ltable; /* 0 <= cur_ltable < n_tables. */
130 uint8_t output_ptable; /* OpenFlow table for 'output' to resubmit. */
0bac7164 131 uint8_t arp_ptable; /* OpenFlow table for 'get_arp' to resubmit. */
1d7b2ece
BP
132};
133
134char *actions_parse(struct lexer *, const struct action_params *,
135 struct ofpbuf *ofpacts, struct expr **prereqsp)
ea53e3a8 136 OVS_WARN_UNUSED_RESULT;
1d7b2ece
BP
137char *actions_parse_string(const char *s, const struct action_params *,
138 struct ofpbuf *ofpacts, struct expr **prereqsp)
ea53e3a8 139 OVS_WARN_UNUSED_RESULT;
3b7cb7e1
BP
140
141#endif /* ovn/actions.h */