X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Ffail-open.c;h=97fee3eb9279b323f61c5c95fe703d63d66b52ec;hb=1bfe968160d7cc030e44481ba3a2ac68824c2869;hp=a86ee391b12dbfc8d56c8cdb55b1fb27965de50e;hpb=fa37b408eac875cbc0d7adbbb3f7a004371172da;p=openvswitch diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c index a86ee391..97fee3eb 100644 --- a/ofproto/fail-open.c +++ b/ofproto/fail-open.c @@ -1,5 +1,5 @@ /* - * 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. @@ -18,6 +18,7 @@ #include "fail-open.h" #include #include +#include "classifier.h" #include "flow.h" #include "mac-learning.h" #include "odp-util.h" @@ -27,13 +28,12 @@ #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. * @@ -72,7 +72,6 @@ struct fail_open { 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; }; @@ -257,14 +256,14 @@ static void 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); } } @@ -283,7 +282,7 @@ fail_open_flushed(struct fail_open *fo) 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. */ @@ -291,41 +290,25 @@ fail_open_flushed(struct fail_open *fo) 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; @@ -354,7 +337,6 @@ fail_open_destroy(struct fail_open *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); }