X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=secchan%2Fofproto.c;h=9f3a8496365cfab3037b84b62ce1442ecf71d19f;hb=85c74638ed99b77d6894385c3dce0175c4b4baa4;hp=aa9e44a1baef453773098260975f1687918c5f84;hpb=a14bc59fb8f27db193d74662dc9c5cb8237177ef;p=openvswitch diff --git a/secchan/ofproto.c b/secchan/ofproto.c index aa9e44a1..9f3a8496 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -26,6 +26,7 @@ #include "coverage.h" #include "discovery.h" #include "dpif.h" +#include "dynamic-string.h" #include "executer.h" #include "fail-open.h" #include "in-band.h" @@ -51,6 +52,7 @@ #include "svec.h" #include "tag.h" #include "timeval.h" +#include "unixctl.h" #include "vconn.h" #include "vconn-ssl.h" #include "xtoxll.h" @@ -333,7 +335,7 @@ ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux, /* Initialize OpenFlow connections. */ list_init(&p->all_conns); - p->controller = ofconn_create(p, rconn_create(15, 15)); + p->controller = ofconn_create(p, rconn_create(5, 8)); p->controller->pktbuf = pktbuf_create(); p->controller->miss_send_len = OFP_DEFAULT_MISS_SEND_LEN; p->listeners = NULL; @@ -431,8 +433,9 @@ ofproto_set_in_band(struct ofproto *p, bool in_band) { if (in_band != (p->in_band != NULL)) { if (in_band) { - return in_band_create(p, &p->dpif, p->switch_status, - p->controller->rconn, &p->in_band); + in_band_create(p, p->switch_status, p->controller->rconn, + &p->in_band); + return 0; } else { ofproto_set_discovery(p, false, NULL, true); in_band_destroy(p->in_band); @@ -635,6 +638,12 @@ ofproto_get_datapath_id(const struct ofproto *ofproto) return ofproto->datapath_id; } +uint64_t +ofproto_get_mgmt_id(const struct ofproto *ofproto) +{ + return ofproto->mgmt_id; +} + int ofproto_get_probe_interval(const struct ofproto *ofproto) { @@ -2464,6 +2473,59 @@ handle_flow_stats_request(struct ofproto *p, struct ofconn *ofconn, return 0; } +struct flow_stats_ds_cbdata { + struct ofproto *ofproto; + struct ds *results; +}; + +static void +flow_stats_ds_cb(struct cls_rule *rule_, void *cbdata_) +{ + struct rule *rule = rule_from_cls_rule(rule_); + struct flow_stats_ds_cbdata *cbdata = cbdata_; + struct ds *results = cbdata->results; + struct ofp_match match; + uint64_t packet_count, byte_count; + size_t act_len = sizeof *rule->actions * rule->n_actions; + + /* Don't report on subrules. */ + if (rule->super != NULL) { + return; + } + + query_stats(cbdata->ofproto, rule, &packet_count, &byte_count); + flow_to_match(&rule->cr.flow, rule->cr.wc.wildcards, &match); + + ds_put_format(results, "duration=%llds, ", + (time_msec() - rule->created) / 1000); + ds_put_format(results, "priority=%u", rule->cr.priority); + ds_put_format(results, "n_packets=%"PRIu64", ", packet_count); + ds_put_format(results, "n_bytes=%"PRIu64", ", byte_count); + ofp_print_match(results, &match, true); + ofp_print_actions(results, &rule->actions->header, act_len); + ds_put_cstr(results, "\n"); +} + +/* Adds a pretty-printed description of all flows to 'results', including + * those marked hidden by secchan (e.g., by in-band control). */ +void +ofproto_get_all_flows(struct ofproto *p, struct ds *results) +{ + struct ofp_match match; + struct cls_rule target; + struct flow_stats_ds_cbdata cbdata; + + memset(&match, 0, sizeof match); + match.wildcards = htonl(OFPFW_ALL); + + cbdata.ofproto = p; + cbdata.results = results; + + cls_rule_from_match(&target, &match, 0); + classifier_for_each_match(&p->cls, &target, CLS_INC_ALL, + flow_stats_ds_cb, &cbdata); +} + struct aggregate_stats_cbdata { struct ofproto *ofproto; uint16_t out_port;