/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "fail-open.h"
#include <inttypes.h>
#include <stdlib.h>
+#include "classifier.h"
#include "flow.h"
#include "mac-learning.h"
#include "odp-util.h"
#include "pktbuf.h"
#include "poll-loop.h"
#include "rconn.h"
-#include "status.h"
#include "timeval.h"
#include "vconn.h"
-
-#define THIS_MODULE VLM_fail_open
#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(fail_open);
+
/*
* Fail-open mode.
*
struct rconn **controllers;
size_t n_controllers;
int last_disconn_secs;
- struct status_category *ss_cat;
long long int next_bogus_packet_in;
struct rconn_packet_counter *bogus_packet_counter;
};
fail_open_recover(struct fail_open *fo)
{
if (fail_open_is_active(fo)) {
- flow_t flow;
+ struct cls_rule rule;
VLOG_WARN("No longer in fail-open mode");
fo->last_disconn_secs = 0;
fo->next_bogus_packet_in = LLONG_MAX;
- memset(&flow, 0, sizeof flow);
- ofproto_delete_flow(fo->ofproto, &flow, OVSFW_ALL, FAIL_OPEN_PRIORITY);
+ cls_rule_init_catchall(&rule, FAIL_OPEN_PRIORITY);
+ ofproto_delete_flow(fo->ofproto, &rule);
}
}
bool open = disconn_secs >= trigger_duration(fo);
if (open) {
union ofp_action action;
- flow_t flow;
+ struct cls_rule rule;
/* Set up a flow that matches every packet and directs them to
* OFPP_NORMAL. */
action.type = htons(OFPAT_OUTPUT);
action.output.len = htons(sizeof action);
action.output.port = htons(OFPP_NORMAL);
- memset(&flow, 0, sizeof flow);
- ofproto_add_flow(fo->ofproto, &flow, OVSFW_ALL, FAIL_OPEN_PRIORITY,
- &action, 1, 0);
- }
-}
-static void
-fail_open_status_cb(struct status_reply *sr, void *fo_)
-{
- struct fail_open *fo = fo_;
- int cur_duration = failure_duration(fo);
- int trigger = trigger_duration(fo);
-
- status_reply_put(sr, "trigger-duration=%d", trigger);
- status_reply_put(sr, "current-duration=%d", cur_duration);
- status_reply_put(sr, "triggered=%s",
- cur_duration >= trigger ? "true" : "false");
+ cls_rule_init_catchall(&rule, FAIL_OPEN_PRIORITY);
+ ofproto_add_flow(fo->ofproto, &rule, &action, 1);
+ }
}
-/* Creates and returns a new struct fail_open for 'ofproto', registering switch
- * status with 'switch_status'.
+/* Creates and returns a new struct fail_open for 'ofproto'.
*
* The caller should register its set of controllers with
* fail_open_set_controllers(). (There should be at least one controller,
* otherwise there isn't any point in having the struct fail_open around.) */
struct fail_open *
-fail_open_create(struct ofproto *ofproto, struct switch_status *switch_status)
+fail_open_create(struct ofproto *ofproto)
{
struct fail_open *fo = xmalloc(sizeof *fo);
fo->ofproto = ofproto;
fo->controllers = NULL;
fo->n_controllers = 0;
fo->last_disconn_secs = 0;
- fo->ss_cat = switch_status_register(switch_status, "fail-open",
- fail_open_status_cb, fo);
fo->next_bogus_packet_in = LLONG_MAX;
fo->bogus_packet_counter = rconn_packet_counter_create();
return fo;
fail_open_recover(fo);
free(fo->controllers);
/* We don't own the rconns behind fo->controllers. */
- switch_status_unregister(fo->ss_cat);
rconn_packet_counter_destroy(fo->bogus_packet_counter);
free(fo);
}