]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/ofproto-dpif-xlate.h
windows: Incorrect check while fetching adapter addresses
[mirror_ovs.git] / ofproto / ofproto-dpif-xlate.h
CommitLineData
99520767 1/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
9583bc14
EJ
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License. */
14
e1ec7dd4
EJ
15#ifndef OFPROTO_DPIF_XLATE_H
16#define OFPROTO_DPIF_XLATE_H 1
9583bc14 17
cf62fa4c 18#include "dp-packet.h"
9583bc14 19#include "flow.h"
064d7f84 20#include "openvswitch/meta-flow.h"
9583bc14 21#include "odp-util.h"
64c96779 22#include "openvswitch/ofpbuf.h"
ec7ceaed 23#include "ofproto-dpif-mirror.h"
e672ff9b 24#include "ofproto-dpif-rid.h"
9583bc14 25#include "ofproto-dpif.h"
70742c7f
EJ
26#include "ofproto.h"
27#include "stp.h"
0477baa9 28#include "ovs-lldp.h"
9583bc14 29
46c88433
EJ
30struct bfd;
31struct bond;
89a8a7f0 32struct dpif;
46c88433
EJ
33struct lacp;
34struct dpif_ipfix;
35struct dpif_sflow;
36struct mac_learning;
6d95c4e8 37struct mcast_snooping;
b256dc52 38struct xlate_cache;
46c88433 39
9583bc14 40struct xlate_out {
9583bc14 41 enum slow_path_reason slow; /* 0 if fast path may be used. */
9583bc14 42
fbf5d6ec
JR
43 struct recirc_refs recircs; /* Recirc action IDs on which references are
44 * held. */
9583bc14
EJ
45};
46
47struct xlate_in {
48 struct ofproto_dpif *ofproto;
1f4a8933 49 ovs_version_t tables_version; /* Lookup in this version. */
9583bc14
EJ
50
51 /* Flow to which the OpenFlow actions apply. xlate_actions() will modify
52 * this flow when actions change header fields. */
53 struct flow flow;
54
8d8ab6c2
JG
55 /* Pointer to the original flow received during the upcall. xlate_actions()
56 * will never modify this flow. */
57 const struct flow *upcall_flow;
58
9583bc14
EJ
59 /* The packet corresponding to 'flow', or a null pointer if we are
60 * revalidating without a packet to refer to. */
cf62fa4c 61 const struct dp_packet *packet;
9583bc14
EJ
62
63 /* Should OFPP_NORMAL update the MAC learning table? Should "learn"
df70a773
JR
64 * actions update the flow table? Should FIN_TIMEOUT change the
65 * timeouts? Or should controller action send packet to the controller?
9583bc14
EJ
66 *
67 * We want to update these tables if we are actually processing a packet,
68 * or if we are accounting for packets that the datapath has processed, but
df70a773
JR
69 * not if we are just revalidating, or if we want to execute the
70 * side-effects later via the xlate cache. */
71 bool allow_side_effects;
9583bc14 72
10c44245
EJ
73 /* The rule initiating translation or NULL. If both 'rule' and 'ofpacts'
74 * are NULL, xlate_actions() will do the initial rule lookup itself. */
9583bc14
EJ
75 struct rule_dpif *rule;
76
77 /* The actions to translate. If 'rule' is not NULL, these may be NULL. */
78 const struct ofpact *ofpacts;
79 size_t ofpacts_len;
80
81 /* Union of the set of TCP flags seen so far in this flow. (Used only by
82 * NXAST_FIN_TIMEOUT. Set to zero to avoid updating updating rules'
83 * timeouts.) */
a66733a8 84 uint16_t tcp_flags;
9583bc14
EJ
85
86 /* If nonnull, flow translation calls this function just before executing a
87 * resubmit or OFPP_TABLE action. In addition, disables logging of traces
88 * when the recursion depth is exceeded.
89 *
90 * 'rule' is the rule being submitted into. It will be null if the
91 * resubmit or OFPP_TABLE action didn't find a matching rule.
92 *
9a9b001a
BP
93 * 'indentation' is the resubmit recursion depth at time of invocation,
94 * suitable for indenting the output.
4d0acc70 95 *
9583bc14
EJ
96 * This is normally null so the client has to set it manually after
97 * calling xlate_in_init(). */
4d0acc70 98 void (*resubmit_hook)(struct xlate_in *, struct rule_dpif *rule,
9a9b001a 99 int indentation);
9583bc14
EJ
100
101 /* If nonnull, flow translation calls this function to report some
102 * significant decision, e.g. to explain why OFPP_NORMAL translation
9a9b001a
BP
103 * dropped a packet. 'indentation' is the resubmit recursion depth at time
104 * of invocation, suitable for indenting the output. */
105 void (*report_hook)(struct xlate_in *, int indentation,
c1b3756c 106 const char *format, va_list args);
9583bc14
EJ
107
108 /* If nonnull, flow translation credits the specified statistics to each
109 * rule reached through a resubmit or OFPP_TABLE action.
110 *
111 * This is normally null so the client has to set it manually after
112 * calling xlate_in_init(). */
113 const struct dpif_flow_stats *resubmit_stats;
b256dc52 114
790c5d26
BP
115 /* Counters carried over from a pre-existing translation of a related flow.
116 * This can occur due to, e.g., the translation of an ARP packet that was
117 * generated as the result of outputting to a tunnel port. In that case,
118 * the original flow going to the tunnel is the related flow. Since the
119 * two flows are different, they should not use the same xlate_ctx
120 * structure. However, we still need limit the maximum recursion across
121 * the entire translation.
cdd42eda
JG
122 *
123 * These fields are normally set to zero, so the client has to set them
790c5d26
BP
124 * manually after calling xlate_in_init(). In that case, they should be
125 * copied from the same-named fields in the related flow's xlate_ctx.
126 *
127 * These fields are really implementation details; the client doesn't care
128 * about what they mean. See the corresponding fields in xlate_ctx for
129 * real documentation. */
9a9b001a 130 int indentation;
790c5d26 131 int depth;
cdd42eda
JG
132 int resubmits;
133
b256dc52
JS
134 /* If nonnull, flow translation populates this cache with references to all
135 * modules that are affected by translation. This 'xlate_cache' may be
136 * passed to xlate_push_stats() to perform the same function as
137 * xlate_actions() without the full cost of translation.
138 *
139 * This is normally null so the client has to set it manually after
140 * calling xlate_in_init(). */
141 struct xlate_cache *xcache;
cc377352 142
1520ef4f
BP
143 /* If nonnull, flow translation puts the resulting datapath actions in this
144 * buffer. If null, flow translation will not produce datapath actions. */
cc377352 145 struct ofpbuf *odp_actions;
e672ff9b 146
49a73e0c
BP
147 /* If nonnull, flow translation populates this with wildcards relevant in
148 * translation. Any fields that were used to calculate the action are set,
149 * to allow caching and kernel wildcarding to work. For example, if the
150 * flow lookup involved performing the "normal" action on IPv4 and ARP
151 * packets, 'wc' would have the 'in_port' (always set), 'dl_type' (flow
152 * match), 'vlan_tci' (normal action), and 'dl_dst' (normal action) fields
153 * set. */
154 struct flow_wildcards *wc;
155
1d361a81
BP
156 /* The frozen state to be resumed, as returned by xlate_lookup(). */
157 const struct frozen_state *frozen_state;
9583bc14
EJ
158};
159
34dd0d78 160void xlate_ofproto_set(struct ofproto_dpif *, const char *name, struct dpif *,
ec89fc6f 161 const struct mac_learning *, struct stp *,
9efd308e 162 struct rstp *, const struct mcast_snooping *,
ec89fc6f 163 const struct mbridge *, const struct dpif_sflow *,
ce3955be 164 const struct dpif_ipfix *, const struct netflow *,
b440dd8c
JS
165 bool forward_bpdu, bool has_in_band,
166 const struct dpif_backer_support *support);
84f0f298 167void xlate_remove_ofproto(struct ofproto_dpif *);
46c88433
EJ
168
169void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *,
170 const char *name, enum port_vlan_mode, int vlan,
171 unsigned long *trunks, bool use_priority_tags,
172 const struct bond *, const struct lacp *,
c005f976 173 bool floodable, bool protected);
84f0f298 174void xlate_bundle_remove(struct ofbundle *);
46c88433
EJ
175
176void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *,
177 struct ofport_dpif *, ofp_port_t, odp_port_t,
0477baa9
DF
178 const struct netdev *, const struct cfm *, const struct bfd *,
179 const struct lldp *, struct ofport_dpif *peer,
180 int stp_port_no, const struct rstp_port *rstp_port,
9efd308e 181 const struct ofproto_port_queue *qdscp,
dd8cd4b4
SH
182 size_t n_qdscp, enum ofputil_port_config,
183 enum ofputil_port_state, bool is_tunnel,
84f0f298
RW
184 bool may_enable);
185void xlate_ofport_remove(struct ofport_dpif *);
46c88433 186
ef377a58
JR
187struct ofproto_dpif * xlate_lookup_ofproto(const struct dpif_backer *,
188 const struct flow *,
189 ofp_port_t *ofp_in_port);
5c476ea3
JR
190int xlate_lookup(const struct dpif_backer *, const struct flow *,
191 struct ofproto_dpif **, struct dpif_ipfix **,
192 struct dpif_sflow **, struct netflow **,
193 ofp_port_t *ofp_in_port);
8449c4d6 194
fff1b9c0
JR
195enum xlate_error {
196 XLATE_OK = 0,
197 XLATE_BRIDGE_NOT_FOUND,
198 XLATE_RECURSION_TOO_DEEP,
199 XLATE_TOO_MANY_RESUBMITS,
200 XLATE_STACK_TOO_DEEP,
201 XLATE_NO_RECIRCULATION_CONTEXT,
202 XLATE_RECIRCULATION_CONFLICT,
203 XLATE_TOO_MANY_MPLS_LABELS,
8d8ab6c2 204 XLATE_INVALID_TUNNEL_METADATA,
fff1b9c0
JR
205};
206
207const char *xlate_strerror(enum xlate_error error);
208
209enum xlate_error xlate_actions(struct xlate_in *, struct xlate_out *);
210
1f4a8933 211void xlate_in_init(struct xlate_in *, struct ofproto_dpif *, ovs_version_t,
cc377352 212 const struct flow *, ofp_port_t in_port, struct rule_dpif *,
49a73e0c 213 uint16_t tcp_flags, const struct dp_packet *packet,
1520ef4f 214 struct flow_wildcards *, struct ofpbuf *odp_actions);
9583bc14 215void xlate_out_uninit(struct xlate_out *);
10e57640 216
77ab5fd2
BP
217enum ofperr xlate_resume(struct ofproto_dpif *,
218 const struct ofputil_packet_in_private *,
219 struct ofpbuf *odp_actions, enum slow_path_reason *);
220
2eb79142 221int xlate_send_packet(const struct ofport_dpif *, bool oam, struct dp_packet *);
91d6cd12 222
901a517e
JR
223void xlate_mac_learning_update(const struct ofproto_dpif *ofproto,
224 ofp_port_t in_port, struct eth_addr dl_src,
225 int vlan, bool is_grat_arp);
b256dc52 226
84f0f298
RW
227void xlate_txn_start(void);
228void xlate_txn_commit(void);
229
9583bc14 230#endif /* ofproto-dpif-xlate.h */