2009-07-08 13:19:16 -07:00
|
|
|
/*
|
openflow: Better abstract handling of packet-in messages.
Packet-in messages have been a bit of a mess. First, their abstraction
in the form of struct ofputil_packet_in has some fields that are used
in a clear way for incoming and outgoing packet-ins, and others
(packet_len, total_len, buffer_id) have have confusing meanings or
usage pattern depending on their direction.
Second, it's very confusing how a packet-in has both a reason (OFPR_*)
and a miss type (OFPROTO_PACKET_IN_*) and how those add up to the
actual reason that is used "on the wire" for each OpenFlow version (and
even whether the packet-in is sent at all!).
Finally, there's all kind of low-level detail randomly scattered between
connmgr, ofproto-dpif-xlate, and ofp-util.
This commit attempts to clear up some of the confusion. It simplifies
the struct ofputil_packet_in abstraction by removing the members that
didn't have a clear and consistent meaning between incoming and outgoing
packet-ins. It gets rid of OFPROTO_PACKET_IN_*, instead adding a couple
of nonstandard OFPR_* reasons that add up to what OFPROTO_PACKET_IN_*
was meant to say (in what I hope is a clearer way). And it consolidates
the tricky parts into ofp-util, where I hope it will be easier to
understand all in one place.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
2016-01-20 09:57:16 -08:00
|
|
|
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016 Nicira, Inc.
|
2009-07-08 13:19:16 -07:00
|
|
|
*
|
2009-06-15 15:11:30 -07:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
2009-07-08 13:19:16 -07:00
|
|
|
*
|
2009-06-15 15:11:30 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-07-08 13:19:16 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdlib.h>
|
2010-10-20 16:46:48 -07:00
|
|
|
#include "classifier.h"
|
2011-03-29 12:24:28 -07:00
|
|
|
#include "connmgr.h"
|
2016-04-14 15:20:19 -07:00
|
|
|
#include "dp-packet.h"
|
|
|
|
#include "fail-open.h"
|
2009-07-08 13:19:16 -07:00
|
|
|
#include "flow.h"
|
|
|
|
#include "mac-learning.h"
|
|
|
|
#include "odp-util.h"
|
2016-04-14 15:20:19 -07:00
|
|
|
#include "openvswitch/ofp-actions.h"
|
|
|
|
#include "openvswitch/ofpbuf.h"
|
|
|
|
#include "openvswitch/vconn.h"
|
|
|
|
#include "openvswitch/vlog.h"
|
2009-07-08 13:19:16 -07:00
|
|
|
#include "ofproto.h"
|
2011-07-01 14:13:56 -07:00
|
|
|
#include "ofproto-provider.h"
|
2017-11-03 13:53:53 +08:00
|
|
|
#include "openvswitch/poll-loop.h"
|
2017-08-17 00:06:24 +08:00
|
|
|
#include "openvswitch/rconn.h"
|
2009-07-08 13:19:16 -07:00
|
|
|
#include "timeval.h"
|
|
|
|
|
2010-10-19 14:47:01 -07:00
|
|
|
VLOG_DEFINE_THIS_MODULE(fail_open);
|
2010-07-16 11:02:49 -07:00
|
|
|
|
2009-09-16 15:12:19 -07:00
|
|
|
/*
|
|
|
|
* Fail-open mode.
|
|
|
|
*
|
|
|
|
* In fail-open mode, the switch detects when the controller cannot be
|
|
|
|
* contacted or when the controller is dropping switch connections because the
|
|
|
|
* switch does not pass its admission control policy. In those situations the
|
|
|
|
* switch sets up flows itself using the "normal" action.
|
|
|
|
*
|
|
|
|
* There is a little subtlety to implementation, to properly handle the case
|
|
|
|
* where the controller allows switch connections but drops them a few seconds
|
|
|
|
* later for admission control reasons. Because of this case, we don't want to
|
|
|
|
* just stop setting up flows when we connect to the controller: if we did,
|
|
|
|
* then new flow setup and existing flows would stop during the duration of
|
|
|
|
* connection to the controller, and thus the whole network would go down for
|
|
|
|
* that period of time.
|
|
|
|
*
|
2010-04-07 12:57:21 -07:00
|
|
|
* So, instead, we add some special cases when we are connected to a
|
|
|
|
* controller, but not yet sure that it has admitted us:
|
2009-09-16 15:12:19 -07:00
|
|
|
*
|
|
|
|
* - We set up flows immediately ourselves, but simultaneously send out an
|
|
|
|
* OFPT_PACKET_IN to the controller. We put a special bogus buffer-id in
|
|
|
|
* these OFPT_PACKET_IN messages so that duplicate packets don't get sent
|
|
|
|
* out to the network when the controller replies.
|
|
|
|
*
|
|
|
|
* - We also send out OFPT_PACKET_IN messages for totally bogus packets
|
|
|
|
* every so often, in case no real new flows are arriving in the network.
|
|
|
|
*
|
|
|
|
* - We don't flush the flow table at the time we connect, because this
|
|
|
|
* could cause network stuttering in a switch with lots of flows or very
|
|
|
|
* high-bandwidth flows by suddenly throwing lots of packets down to
|
|
|
|
* userspace.
|
|
|
|
*/
|
|
|
|
|
2009-07-08 13:19:16 -07:00
|
|
|
struct fail_open {
|
|
|
|
struct ofproto *ofproto;
|
2011-03-29 12:24:28 -07:00
|
|
|
struct connmgr *connmgr;
|
2009-07-08 13:19:16 -07:00
|
|
|
int last_disconn_secs;
|
2009-09-16 15:12:19 -07:00
|
|
|
long long int next_bogus_packet_in;
|
|
|
|
struct rconn_packet_counter *bogus_packet_counter;
|
2015-01-06 09:27:32 -08:00
|
|
|
bool fail_open_active;
|
2009-07-08 13:19:16 -07:00
|
|
|
};
|
|
|
|
|
2016-09-13 14:46:16 -07:00
|
|
|
static void fail_open_recover(struct fail_open *) OVS_REQUIRES(ofproto_mutex);
|
2010-02-23 15:14:15 -08:00
|
|
|
|
2010-04-20 10:43:42 -07:00
|
|
|
/* Returns the number of seconds of disconnection after which fail-open mode
|
|
|
|
* should activate. */
|
|
|
|
static int
|
|
|
|
trigger_duration(const struct fail_open *fo)
|
2009-07-08 13:19:16 -07:00
|
|
|
{
|
2011-03-29 12:24:28 -07:00
|
|
|
if (!connmgr_has_controllers(fo->connmgr)) {
|
2010-04-20 10:43:42 -07:00
|
|
|
/* Shouldn't ever arrive here, but if we do, never fail open. */
|
|
|
|
return INT_MAX;
|
|
|
|
} else {
|
|
|
|
/* Otherwise, every controller must have a chance to send an
|
|
|
|
* inactivity probe and reconnect before we fail open, so take the
|
|
|
|
* maximum probe interval and multiply by 3:
|
|
|
|
*
|
|
|
|
* - The first interval is the idle time before sending an inactivity
|
|
|
|
* probe.
|
|
|
|
*
|
|
|
|
* - The second interval is the time allowed for a response to the
|
|
|
|
* inactivity probe.
|
|
|
|
*
|
|
|
|
* - The third interval is the time allowed to reconnect after no
|
|
|
|
* response is received.
|
|
|
|
*/
|
2011-03-29 12:24:28 -07:00
|
|
|
return connmgr_get_max_probe_interval(fo->connmgr) * 3;
|
2010-04-20 10:43:42 -07:00
|
|
|
}
|
2009-09-16 15:12:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns true if 'fo' is currently in fail-open mode, otherwise false. */
|
|
|
|
bool
|
|
|
|
fail_open_is_active(const struct fail_open *fo)
|
|
|
|
{
|
|
|
|
return fo->last_disconn_secs != 0;
|
|
|
|
}
|
2009-07-08 13:19:16 -07:00
|
|
|
|
2009-09-16 15:12:19 -07:00
|
|
|
static void
|
2011-03-29 12:24:28 -07:00
|
|
|
send_bogus_packet_ins(struct fail_open *fo)
|
2009-09-16 15:12:19 -07:00
|
|
|
{
|
2015-08-28 14:55:11 -07:00
|
|
|
struct eth_addr mac;
|
2015-02-22 03:21:09 -08:00
|
|
|
struct dp_packet b;
|
2009-07-08 13:19:16 -07:00
|
|
|
|
2015-02-22 03:21:09 -08:00
|
|
|
dp_packet_init(&b, 128);
|
2015-08-28 14:55:11 -07:00
|
|
|
eth_addr_nicira_random(&mac);
|
2012-06-07 18:24:29 -07:00
|
|
|
compose_rarp(&b, mac);
|
2009-09-16 15:12:19 -07:00
|
|
|
|
2016-01-18 20:12:30 -08:00
|
|
|
struct ofproto_async_msg am = {
|
|
|
|
.oam = OAM_PACKET_IN,
|
|
|
|
.pin = {
|
|
|
|
.up = {
|
2017-07-30 17:40:32 -07:00
|
|
|
.base = {
|
Implement serializing the state of packet traversal in "continuations".
One purpose of OpenFlow packet-in messages is to allow a controller to
interpose on the path of a packet through the flow tables. If, for
example, the controller needs to modify a packet in some way that the
switch doesn't directly support, the controller should be able to
program the switch to send it the packet, then modify the packet and
send it back to the switch to continue through the flow table.
That's the theory. In practice, this doesn't work with any but the
simplest flow tables. Packet-in messages simply don't include enough
context to allow the flow table traversal to continue. For example:
* Via "resubmit" actions, an Open vSwitch packet can have an
effective "call stack", but a packet-in can't describe it, and
so it would be lost.
* A packet-in can't preserve the stack used by NXAST_PUSH and
NXAST_POP actions.
* A packet-in can't preserve the OpenFlow 1.1+ action set.
* A packet-in can't preserve the state of Open vSwitch mirroring
or connection tracking.
This commit introduces a solution called "continuations". A continuation
is the state of a packet's traversal through OpenFlow flow tables. A
"controller" action with the "pause" flag, which is newly implemented in
this commit, generates a continuation and sends it to the OpenFlow
controller in a packet-in asynchronous message (only NXT_PACKET_IN2
supports continuations, so the controller must configure them with
NXT_SET_PACKET_IN_FORMAT). The controller processes the packet-in,
possibly modifying some of its data, and sends it back to the switch with
an NXT_RESUME request, which causes flow table traversal to continue. In
principle, a single packet can be paused and resumed multiple times.
Another way to look at it is:
- "pause" is an extension of the existing OFPAT_CONTROLLER
action. It sends the packet to the controller, with full
pipeline context (some of which is switch implementation
dependent, and may thus vary from switch to switch).
- A continuation is an extension of OFPT_PACKET_IN, allowing for
implementation dependent metadata.
- NXT_RESUME is an extension of OFPT_PACKET_OUT, with the
semantics that the pipeline processing is continued with the
original translation context from where it was left at the time
it was paused.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
2016-02-19 16:10:06 -08:00
|
|
|
.packet = dp_packet_data(&b),
|
|
|
|
.packet_len = dp_packet_size(&b),
|
|
|
|
.flow_metadata.flow.in_port.ofp_port = OFPP_LOCAL,
|
|
|
|
.flow_metadata.wc.masks.in_port.ofp_port
|
2016-01-18 20:12:30 -08:00
|
|
|
= u16_to_ofp(UINT16_MAX),
|
Implement serializing the state of packet traversal in "continuations".
One purpose of OpenFlow packet-in messages is to allow a controller to
interpose on the path of a packet through the flow tables. If, for
example, the controller needs to modify a packet in some way that the
switch doesn't directly support, the controller should be able to
program the switch to send it the packet, then modify the packet and
send it back to the switch to continue through the flow table.
That's the theory. In practice, this doesn't work with any but the
simplest flow tables. Packet-in messages simply don't include enough
context to allow the flow table traversal to continue. For example:
* Via "resubmit" actions, an Open vSwitch packet can have an
effective "call stack", but a packet-in can't describe it, and
so it would be lost.
* A packet-in can't preserve the stack used by NXAST_PUSH and
NXAST_POP actions.
* A packet-in can't preserve the OpenFlow 1.1+ action set.
* A packet-in can't preserve the state of Open vSwitch mirroring
or connection tracking.
This commit introduces a solution called "continuations". A continuation
is the state of a packet's traversal through OpenFlow flow tables. A
"controller" action with the "pause" flag, which is newly implemented in
this commit, generates a continuation and sends it to the OpenFlow
controller in a packet-in asynchronous message (only NXT_PACKET_IN2
supports continuations, so the controller must configure them with
NXT_SET_PACKET_IN_FORMAT). The controller processes the packet-in,
possibly modifying some of its data, and sends it back to the switch with
an NXT_RESUME request, which causes flow table traversal to continue. In
principle, a single packet can be paused and resumed multiple times.
Another way to look at it is:
- "pause" is an extension of the existing OFPAT_CONTROLLER
action. It sends the packet to the controller, with full
pipeline context (some of which is switch implementation
dependent, and may thus vary from switch to switch).
- A continuation is an extension of OFPT_PACKET_IN, allowing for
implementation dependent metadata.
- NXT_RESUME is an extension of OFPT_PACKET_OUT, with the
semantics that the pipeline processing is continued with the
original translation context from where it was left at the time
it was paused.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
2016-02-19 16:10:06 -08:00
|
|
|
.reason = OFPR_NO_MATCH,
|
|
|
|
.cookie = OVS_BE64_MAX,
|
|
|
|
},
|
2016-01-18 20:12:30 -08:00
|
|
|
},
|
|
|
|
.max_len = UINT16_MAX,
|
|
|
|
}
|
openflow: Better abstract handling of packet-in messages.
Packet-in messages have been a bit of a mess. First, their abstraction
in the form of struct ofputil_packet_in has some fields that are used
in a clear way for incoming and outgoing packet-ins, and others
(packet_len, total_len, buffer_id) have have confusing meanings or
usage pattern depending on their direction.
Second, it's very confusing how a packet-in has both a reason (OFPR_*)
and a miss type (OFPROTO_PACKET_IN_*) and how those add up to the
actual reason that is used "on the wire" for each OpenFlow version (and
even whether the packet-in is sent at all!).
Finally, there's all kind of low-level detail randomly scattered between
connmgr, ofproto-dpif-xlate, and ofp-util.
This commit attempts to clear up some of the confusion. It simplifies
the struct ofputil_packet_in abstraction by removing the members that
didn't have a clear and consistent meaning between incoming and outgoing
packet-ins. It gets rid of OFPROTO_PACKET_IN_*, instead adding a couple
of nonstandard OFPR_* reasons that add up to what OFPROTO_PACKET_IN_*
was meant to say (in what I hope is a clearer way). And it consolidates
the tricky parts into ofp-util, where I hope it will be easier to
understand all in one place.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
2016-01-20 09:57:16 -08:00
|
|
|
};
|
2016-01-18 20:12:30 -08:00
|
|
|
connmgr_send_async_msg(fo->connmgr, &am);
|
2012-03-12 14:27:25 -07:00
|
|
|
|
2015-02-22 03:21:09 -08:00
|
|
|
dp_packet_uninit(&b);
|
2009-09-16 15:12:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-02 12:46:28 -07:00
|
|
|
static void
|
|
|
|
fail_open_del_normal_flow(struct fail_open *fo)
|
|
|
|
OVS_REQUIRES(ofproto_mutex)
|
|
|
|
{
|
|
|
|
struct match match;
|
|
|
|
|
|
|
|
match_init_catchall(&match);
|
|
|
|
ofproto_delete_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fail_open_add_normal_flow(struct fail_open *fo)
|
|
|
|
{
|
|
|
|
struct ofpbuf ofpacts;
|
|
|
|
struct match match;
|
|
|
|
|
|
|
|
/* Set up a flow that matches every packet and directs them to
|
|
|
|
* OFPP_NORMAL. */
|
ofp-actions: Make all actions a multiple of OFPACT_ALIGNTO bytes.
The functions to put ofpacts into ofpbufs have always padded them to
OFPACT_ALIGNTO boundaries, but the underlying structures weren't
necessarily padded out. That led to difficulties in a few places where
structures were allocated on the stack instead in an ofpbuf, because
functions like ofpact_init_*() would access beyond the end of the actual
structure. This is true, for example, in test_multipath_main() in
tests/test-multipath.c, which allocates a struct ofpact_multipath on the
stack, and in lswitch_handshake() in learning-switch.c, which allocates
a struct ofpact_output on the stack.
It's possible to fix these individual cases, but it's possible that there
are others that haven't been identified. This commit addresses the issue
another way, by padding all of the ofpact structures to a full multiple
of OFPACT_ALIGNTO and adding assertions to ensure that it can't be screwed
up in the future.
This commit removes the OFPACT_*_SIZE enums, because they are now
equivalent to sizeof(struct ofpact_*) in every case.
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-11-14 16:07:30 -08:00
|
|
|
ofpbuf_init(&ofpacts, sizeof(struct ofpact_output));
|
2018-04-02 12:46:28 -07:00
|
|
|
ofpact_put_OUTPUT(&ofpacts)->port = OFPP_NORMAL;
|
|
|
|
|
|
|
|
match_init_catchall(&match);
|
|
|
|
ofproto_add_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY,
|
|
|
|
ofpacts.data, ofpacts.size);
|
|
|
|
|
|
|
|
ofpbuf_uninit(&ofpacts);
|
|
|
|
}
|
|
|
|
|
2010-04-20 10:43:42 -07:00
|
|
|
/* Enter fail-open mode if we should be in it. */
|
2009-09-16 15:12:19 -07:00
|
|
|
void
|
|
|
|
fail_open_run(struct fail_open *fo)
|
|
|
|
{
|
2011-03-29 12:24:28 -07:00
|
|
|
int disconn_secs = connmgr_failure_duration(fo->connmgr);
|
2010-04-20 10:43:42 -07:00
|
|
|
|
2009-09-16 15:12:19 -07:00
|
|
|
/* Enter fail-open mode if 'fo' is not in it but should be. */
|
2021-06-10 15:49:33 -07:00
|
|
|
if (disconn_secs > 0 && disconn_secs >= trigger_duration(fo)) {
|
2009-09-16 15:12:19 -07:00
|
|
|
if (!fail_open_is_active(fo)) {
|
2009-08-10 18:09:33 -07:00
|
|
|
VLOG_WARN("Could not connect to controller (or switch failed "
|
|
|
|
"controller's post-connection admission control "
|
|
|
|
"policy) for %d seconds, failing open", disconn_secs);
|
2009-07-08 13:19:16 -07:00
|
|
|
fo->last_disconn_secs = disconn_secs;
|
|
|
|
|
|
|
|
/* Flush all OpenFlow and datapath flows. We will set up our
|
|
|
|
* fail-open rule from fail_open_flushed() when
|
|
|
|
* ofproto_flush_flows() calls back to us. */
|
|
|
|
ofproto_flush_flows(fo->ofproto);
|
2009-09-16 15:12:19 -07:00
|
|
|
} else if (disconn_secs > fo->last_disconn_secs + 60) {
|
|
|
|
VLOG_INFO("Still in fail-open mode after %d seconds disconnected "
|
|
|
|
"from controller", disconn_secs);
|
|
|
|
fo->last_disconn_secs = disconn_secs;
|
2009-07-08 13:19:16 -07:00
|
|
|
}
|
|
|
|
}
|
2009-09-16 15:12:19 -07:00
|
|
|
|
|
|
|
/* Schedule a bogus packet-in if we're connected and in fail-open. */
|
|
|
|
if (fail_open_is_active(fo)) {
|
2011-03-29 12:24:28 -07:00
|
|
|
if (connmgr_is_any_controller_connected(fo->connmgr)) {
|
2009-09-16 15:12:19 -07:00
|
|
|
bool expired = time_msec() >= fo->next_bogus_packet_in;
|
|
|
|
if (expired) {
|
2010-04-20 10:43:42 -07:00
|
|
|
send_bogus_packet_ins(fo);
|
2009-09-16 15:12:19 -07:00
|
|
|
}
|
|
|
|
if (expired || fo->next_bogus_packet_in == LLONG_MAX) {
|
|
|
|
fo->next_bogus_packet_in = time_msec() + 2000;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fo->next_bogus_packet_in = LLONG_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-08 13:19:16 -07:00
|
|
|
}
|
|
|
|
|
2009-09-16 15:12:19 -07:00
|
|
|
/* If 'fo' is currently in fail-open mode and its rconn has connected to the
|
|
|
|
* controller, exits fail open mode. */
|
2009-07-08 13:19:16 -07:00
|
|
|
void
|
2009-09-16 15:12:19 -07:00
|
|
|
fail_open_maybe_recover(struct fail_open *fo)
|
2014-01-10 11:36:35 -08:00
|
|
|
OVS_EXCLUDED(ofproto_mutex)
|
2009-07-08 13:19:16 -07:00
|
|
|
{
|
2011-03-29 12:24:28 -07:00
|
|
|
if (fail_open_is_active(fo)
|
|
|
|
&& connmgr_is_any_controller_admitted(fo->connmgr)) {
|
2016-09-13 14:46:16 -07:00
|
|
|
ovs_mutex_lock(&ofproto_mutex);
|
2010-02-23 15:14:15 -08:00
|
|
|
fail_open_recover(fo);
|
2016-09-13 14:46:16 -07:00
|
|
|
ovs_mutex_unlock(&ofproto_mutex);
|
2010-02-23 15:14:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fail_open_recover(struct fail_open *fo)
|
2016-09-13 14:46:16 -07:00
|
|
|
OVS_REQUIRES(ofproto_mutex)
|
2010-02-23 15:14:15 -08:00
|
|
|
{
|
2011-03-29 12:24:28 -07:00
|
|
|
VLOG_WARN("No longer in fail-open mode");
|
|
|
|
fo->last_disconn_secs = 0;
|
|
|
|
fo->next_bogus_packet_in = LLONG_MAX;
|
2009-09-16 15:12:19 -07:00
|
|
|
|
2018-04-02 12:46:28 -07:00
|
|
|
fail_open_del_normal_flow(fo);
|
2009-09-16 15:12:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fail_open_wait(struct fail_open *fo)
|
|
|
|
{
|
|
|
|
if (fo->next_bogus_packet_in != LLONG_MAX) {
|
2010-05-12 12:53:07 -07:00
|
|
|
poll_timer_wait_until(fo->next_bogus_packet_in);
|
2009-09-16 15:12:19 -07:00
|
|
|
}
|
2009-07-08 13:19:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fail_open_flushed(struct fail_open *fo)
|
2013-09-12 20:45:15 -07:00
|
|
|
OVS_EXCLUDED(ofproto_mutex)
|
2009-07-08 13:19:16 -07:00
|
|
|
{
|
2011-03-29 12:24:28 -07:00
|
|
|
int disconn_secs = connmgr_failure_duration(fo->connmgr);
|
2010-04-20 10:43:42 -07:00
|
|
|
bool open = disconn_secs >= trigger_duration(fo);
|
2009-07-08 13:19:16 -07:00
|
|
|
if (open) {
|
2018-04-02 12:46:28 -07:00
|
|
|
fail_open_add_normal_flow(fo);
|
2009-07-08 13:19:16 -07:00
|
|
|
}
|
2015-01-06 09:27:32 -08:00
|
|
|
fo->fail_open_active = open;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the number of fail-open rules currently installed in the flow
|
|
|
|
* table. */
|
|
|
|
int
|
|
|
|
fail_open_count_rules(const struct fail_open *fo)
|
|
|
|
{
|
|
|
|
return fo->fail_open_active != 0;
|
2009-07-08 13:19:16 -07:00
|
|
|
}
|
|
|
|
|
2011-03-29 12:24:28 -07:00
|
|
|
/* Creates and returns a new struct fail_open for 'ofproto' and 'mgr'. */
|
2009-07-08 13:19:16 -07:00
|
|
|
struct fail_open *
|
2011-03-29 12:24:28 -07:00
|
|
|
fail_open_create(struct ofproto *ofproto, struct connmgr *mgr)
|
2009-07-08 13:19:16 -07:00
|
|
|
{
|
|
|
|
struct fail_open *fo = xmalloc(sizeof *fo);
|
|
|
|
fo->ofproto = ofproto;
|
2011-03-29 12:24:28 -07:00
|
|
|
fo->connmgr = mgr;
|
2009-07-08 13:19:16 -07:00
|
|
|
fo->last_disconn_secs = 0;
|
2009-09-16 15:12:19 -07:00
|
|
|
fo->next_bogus_packet_in = LLONG_MAX;
|
|
|
|
fo->bogus_packet_counter = rconn_packet_counter_create();
|
2015-01-06 09:27:32 -08:00
|
|
|
fo->fail_open_active = false;
|
2009-07-08 13:19:16 -07:00
|
|
|
return fo;
|
|
|
|
}
|
|
|
|
|
2010-04-20 10:43:42 -07:00
|
|
|
/* Destroys 'fo'. */
|
2009-07-08 13:19:16 -07:00
|
|
|
void
|
|
|
|
fail_open_destroy(struct fail_open *fo)
|
2016-09-13 14:46:16 -07:00
|
|
|
OVS_REQUIRES(ofproto_mutex)
|
2009-07-08 13:19:16 -07:00
|
|
|
{
|
|
|
|
if (fo) {
|
2011-03-29 12:24:28 -07:00
|
|
|
if (fail_open_is_active(fo)) {
|
|
|
|
fail_open_recover(fo);
|
|
|
|
}
|
|
|
|
/* We don't own fo->connmgr. */
|
2009-09-16 15:12:19 -07:00
|
|
|
rconn_packet_counter_destroy(fo->bogus_packet_counter);
|
2009-07-08 13:19:16 -07:00
|
|
|
free(fo);
|
|
|
|
}
|
|
|
|
}
|