diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h index 95c898973..663059f69 100644 --- a/include/openflow/nicira-ext.h +++ b/include/openflow/nicira-ext.h @@ -126,16 +126,9 @@ OFP_ASSERT(sizeof(struct nicira_header) == 16); /* Values for the 'subtype' member of struct nicira_header. */ enum nicira_type { - /* Switch status request. The request body is an ASCII string that - * specifies a prefix of the key names to include in the output; if it is - * the null string, then all key-value pairs are included. */ - NXT_STATUS_REQUEST, - - /* Switch status reply. The reply body is an ASCII string of key-value - * pairs in the form "key=value\n". */ - NXT_STATUS_REPLY, - /* No longer used. */ + NXT_STATUS_REQUEST__OBSOLETE, + NXT_STATUS_REPLY__OBSOLETE, NXT_ACT_SET_CONFIG__OBSOLETE, NXT_ACT_GET_CONFIG__OBSOLETE, NXT_COMMAND_REQUEST__OBSOLETE, diff --git a/lib/learning-switch.c b/lib/learning-switch.c index 5f429c124..ca970540e 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.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. @@ -238,8 +238,6 @@ lswitch_process_packet(struct lswitch *sw, struct rconn *rconn, case OFPUTIL_OFPST_PORT_REPLY: case OFPUTIL_OFPST_TABLE_REPLY: case OFPUTIL_OFPST_AGGREGATE_REPLY: - case OFPUTIL_NXT_STATUS_REQUEST: - case OFPUTIL_NXT_STATUS_REPLY: case OFPUTIL_NXT_TUN_ID_FROM_COOKIE: case OFPUTIL_NXT_ROLE_REQUEST: case OFPUTIL_NXT_ROLE_REPLY: diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 77719118c..1cd946260 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -1320,18 +1320,6 @@ ofp_print_echo(struct ds *string, const struct ofp_header *oh, int verbosity) } } -static void -ofp_print_nxt_status_message(struct ds *string, const struct ofp_header *oh) -{ - struct ofpbuf b; - - ofpbuf_use_const(&b, oh, ntohs(oh->length)); - ofpbuf_pull(&b, sizeof(struct nicira_header)); - ds_put_cstr(string, " \""); - ds_put_printable(string, b.data, b.size); - ds_put_char(string, '"'); -} - static void ofp_print_nxt_tun_id_from_cookie(struct ds *string, const struct nxt_tun_id_cookie *ntic) @@ -1508,11 +1496,6 @@ ofp_to_string__(const struct ofp_header *oh, ofp_print_ofpst_aggregate_reply(string, oh); break; - case OFPUTIL_NXT_STATUS_REQUEST: - case OFPUTIL_NXT_STATUS_REPLY: - ofp_print_nxt_status_message(string, oh); - break; - case OFPUTIL_NXT_TUN_ID_FROM_COOKIE: ofp_print_nxt_tun_id_from_cookie(string, msg); break; diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 8dbcb2b38..9c894d788 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -399,14 +399,6 @@ ofputil_decode_vendor(const struct ofp_header *oh, const struct ofputil_msg_type **typep) { static const struct ofputil_msg_type nxt_messages[] = { - { OFPUTIL_NXT_STATUS_REQUEST, - NXT_STATUS_REQUEST, "NXT_STATUS_REQUEST", - sizeof(struct nicira_header), 1 }, - - { OFPUTIL_NXT_STATUS_REPLY, - NXT_STATUS_REPLY, "NXT_STATUS_REPLY", - sizeof(struct nicira_header), 1 }, - { OFPUTIL_NXT_TUN_ID_FROM_COOKIE, NXT_TUN_ID_FROM_COOKIE, "NXT_TUN_ID_FROM_COOKIE", sizeof(struct nxt_tun_id_cookie), 0 }, diff --git a/lib/ofp-util.h b/lib/ofp-util.h index ff6faa486..439495bb1 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -71,8 +71,6 @@ enum ofputil_msg_code { OFPUTIL_OFPST_AGGREGATE_REPLY, /* NXT_* messages. */ - OFPUTIL_NXT_STATUS_REQUEST, - OFPUTIL_NXT_STATUS_REPLY, OFPUTIL_NXT_TUN_ID_FROM_COOKIE, OFPUTIL_NXT_ROLE_REQUEST, OFPUTIL_NXT_ROLE_REPLY, diff --git a/ofproto/automake.mk b/ofproto/automake.mk index 663074554..c6cb9dd49 100644 --- a/ofproto/automake.mk +++ b/ofproto/automake.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2009, 2010 Nicira Networks, Inc. +# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -24,8 +24,6 @@ ofproto_libofproto_a_SOURCES = \ ofproto/pktbuf.c \ ofproto/pktbuf.h \ ofproto/pinsched.c \ - ofproto/pinsched.h \ - ofproto/status.c \ - ofproto/status.h + ofproto/pinsched.h EXTRA_DIST += ofproto/ofproto-unixctl.man diff --git a/ofproto/discovery.c b/ofproto/discovery.c index 37d32e43f..ba489ffd8 100644 --- a/ofproto/discovery.c +++ b/ofproto/discovery.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. @@ -29,7 +29,6 @@ #include "netdev.h" #include "openflow/openflow.h" #include "packets.h" -#include "status.h" #include "stream-ssl.h" #include "vlog.h" @@ -42,7 +41,6 @@ struct discovery { regex_t *regex; struct dhclient *dhcp; int n_changes; - struct status_category *ss_cat; }; static void modify_dhcp_request(struct dhcp_msg *, void *aux); @@ -50,55 +48,9 @@ static bool validate_dhcp_offer(const struct dhcp_msg *, void *aux); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(60, 60); -static void -discovery_status_cb(struct status_reply *sr, void *d_) -{ - struct discovery *d = d_; - - status_reply_put(sr, "accept-remote=%s", d->re); - status_reply_put(sr, "n-changes=%d", d->n_changes); - if (d->dhcp) { - status_reply_put(sr, "state=%s", dhclient_get_state(d->dhcp)); - status_reply_put(sr, "state-elapsed=%u", - dhclient_get_state_elapsed(d->dhcp)); - if (dhclient_is_bound(d->dhcp)) { - uint32_t ip = dhclient_get_ip(d->dhcp); - uint32_t netmask = dhclient_get_netmask(d->dhcp); - uint32_t router = dhclient_get_router(d->dhcp); - - const struct dhcp_msg *cfg = dhclient_get_config(d->dhcp); - uint32_t dns_server; - char *domain_name; - int i; - - status_reply_put(sr, "ip="IP_FMT, IP_ARGS(&ip)); - status_reply_put(sr, "netmask="IP_FMT, IP_ARGS(&netmask)); - if (router) { - status_reply_put(sr, "router="IP_FMT, IP_ARGS(&router)); - } - - for (i = 0; dhcp_msg_get_ip(cfg, DHCP_CODE_DNS_SERVER, i, - &dns_server); - i++) { - status_reply_put(sr, "dns%d="IP_FMT, i, IP_ARGS(&dns_server)); - } - - domain_name = dhcp_msg_get_string(cfg, DHCP_CODE_DOMAIN_NAME); - if (domain_name) { - status_reply_put(sr, "domain=%s", domain_name); - free(domain_name); - } - - status_reply_put(sr, "lease-remaining=%u", - dhclient_get_lease_remaining(d->dhcp)); - } - } -} - int discovery_create(const char *re, bool update_resolv_conf, - struct dpif *dpif, struct switch_status *ss, - struct discovery **discoveryp) + struct dpif *dpif, struct discovery **discoveryp) { struct discovery *d; char local_name[IF_NAMESIZE]; @@ -133,9 +85,6 @@ discovery_create(const char *re, bool update_resolv_conf, dhclient_set_max_timeout(d->dhcp, 3); dhclient_init(d->dhcp, 0); - d->ss_cat = switch_status_register(ss, "discovery", - discovery_status_cb, d); - *discoveryp = d; return 0; @@ -157,7 +106,6 @@ discovery_destroy(struct discovery *d) regfree(d->regex); free(d->regex); dhclient_destroy(d->dhcp); - switch_status_unregister(d->ss_cat); free(d->dpif_name); free(d); } diff --git a/ofproto/discovery.h b/ofproto/discovery.h index 2288ff60f..999a603f5 100644 --- a/ofproto/discovery.h +++ b/ofproto/discovery.h @@ -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. @@ -22,11 +22,9 @@ struct dpif; struct discovery; struct settings; -struct switch_status; int discovery_create(const char *accept_controller_re, bool update_resolv_conf, - struct dpif *, struct switch_status *, - struct discovery **); + struct dpif *, struct discovery **); void discovery_destroy(struct discovery *); bool discovery_get_update_resolv_conf(const struct discovery *); void discovery_set_update_resolv_conf(struct discovery *, diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c index cd1db94c5..97fee3eb9 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. @@ -28,7 +28,6 @@ #include "pktbuf.h" #include "poll-loop.h" #include "rconn.h" -#include "status.h" #include "timeval.h" #include "vconn.h" #include "vlog.h" @@ -73,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; }; @@ -298,35 +296,19 @@ fail_open_flushed(struct fail_open *fo) } } -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"); -} - -/* 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; @@ -355,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); } diff --git a/ofproto/fail-open.h b/ofproto/fail-open.h index eab667aaa..2d0424de6 100644 --- a/ofproto/fail-open.h +++ b/ofproto/fail-open.h @@ -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. @@ -24,7 +24,6 @@ struct fail_open; struct ofproto; struct rconn; -struct switch_status; /* Priority of the rule added by the fail-open subsystem when a switch enters * fail-open mode. This priority value uniquely identifies a fail-open flow @@ -32,7 +31,7 @@ struct switch_status; * creates flows with this priority). And "f0" is mnemonic for "fail open"! */ #define FAIL_OPEN_PRIORITY 0xf0f0f0 -struct fail_open *fail_open_create(struct ofproto *, struct switch_status *); +struct fail_open *fail_open_create(struct ofproto *); void fail_open_set_controllers(struct fail_open *, struct rconn **, size_t n); void fail_open_destroy(struct fail_open *); void fail_open_wait(struct fail_open *); diff --git a/ofproto/in-band.c b/ofproto/in-band.c index 3046ba1b1..a001baf6a 100644 --- a/ofproto/in-band.c +++ b/ofproto/in-band.c @@ -35,7 +35,6 @@ #include "openflow/openflow.h" #include "packets.h" #include "poll-loop.h" -#include "status.h" #include "timeval.h" #include "vlog.h" @@ -235,7 +234,6 @@ struct in_band_remote { struct in_band { struct ofproto *ofproto; - struct status_category *ss_cat; int queue_id, prev_queue_id; /* Remote information. */ @@ -373,23 +371,6 @@ refresh_local(struct in_band *ib) return true; } -static void -in_band_status_cb(struct status_reply *sr, void *in_band_) -{ - struct in_band *in_band = in_band_; - - if (!eth_addr_is_zero(in_band->local_mac)) { - status_reply_put(sr, "local-mac="ETH_ADDR_FMT, - ETH_ADDR_ARGS(in_band->local_mac)); - } - - if (in_band->n_remotes - && !eth_addr_is_zero(in_band->remotes[0].remote_mac)) { - status_reply_put(sr, "remote-mac="ETH_ADDR_FMT, - ETH_ADDR_ARGS(in_band->remotes[0].remote_mac)); - } -} - /* Returns true if 'packet' should be sent to the local port regardless * of the flow table. */ bool @@ -704,7 +685,7 @@ in_band_flushed(struct in_band *in_band) int in_band_create(struct ofproto *ofproto, struct dpif *dpif, - struct switch_status *ss, struct in_band **in_bandp) + struct in_band **in_bandp) { struct in_band *in_band; char local_name[IF_NAMESIZE]; @@ -729,8 +710,6 @@ in_band_create(struct ofproto *ofproto, struct dpif *dpif, in_band = xzalloc(sizeof *in_band); in_band->ofproto = ofproto; - in_band->ss_cat = switch_status_register(ss, "in-band", - in_band_status_cb, in_band); in_band->queue_id = in_band->prev_queue_id = -1; in_band->next_remote_refresh = TIME_MIN; in_band->next_local_refresh = TIME_MIN; @@ -747,7 +726,6 @@ in_band_destroy(struct in_band *ib) if (ib) { drop_rules(ib); in_band_set_remotes(ib, NULL, 0); - switch_status_unregister(ib->ss_cat); netdev_close(ib->local_netdev); free(ib); } diff --git a/ofproto/in-band.h b/ofproto/in-band.h index d90dc8576..701da00ec 100644 --- a/ofproto/in-band.h +++ b/ofproto/in-band.h @@ -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. @@ -24,10 +24,8 @@ struct in_band; struct ofproto; struct rconn; struct settings; -struct switch_status; -int in_band_create(struct ofproto *, struct dpif *, struct switch_status *, - struct in_band **); +int in_band_create(struct ofproto *, struct dpif *, struct in_band **); void in_band_destroy(struct in_band *); void in_band_set_queue(struct in_band *, int queue_id); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 219862231..ffeb95248 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -54,7 +54,6 @@ #include "poll-loop.h" #include "rconn.h" #include "shash.h" -#include "status.h" #include "stream-ssl.h" #include "svec.h" #include "tag.h" @@ -334,7 +333,6 @@ struct ofconn { enum nx_role role; /* Role. */ struct hmap_node hmap_node; /* In struct ofproto's "controllers" map. */ struct discovery *discovery; /* Controller discovery object, if enabled. */ - struct status_category *ss; /* Switch status category. */ enum ofproto_band band; /* In-band or out-of-band? */ }; @@ -373,7 +371,6 @@ struct ofproto { uint32_t max_ports; /* Configuration. */ - struct switch_status *switch_status; struct fail_open *fail_open; struct netflow *netflow; struct ofproto_sflow *sflow; @@ -488,7 +485,6 @@ ofproto_create(const char *datapath, const char *datapath_type, p->max_ports = dpif_get_max_ports(dpif); /* Initialize submodules. */ - p->switch_status = switch_status_create(p); p->fail_open = NULL; p->netflow = NULL; p->sflow = NULL; @@ -571,8 +567,7 @@ add_controller(struct ofproto *ofproto, const struct ofproto_controller *c) if (is_discovery_controller(c)) { int error = discovery_create(c->accept_re, c->update_resolv_conf, - ofproto->dpif, ofproto->switch_status, - &discovery); + ofproto->dpif, &discovery); if (error) { return; } @@ -683,8 +678,7 @@ update_in_band_remotes(struct ofproto *ofproto) * even before we know any remote addresses. */ if (n_addrs || discovery) { if (!ofproto->in_band) { - in_band_create(ofproto, ofproto->dpif, ofproto->switch_status, - &ofproto->in_band); + in_band_create(ofproto, ofproto->dpif, &ofproto->in_band); } if (ofproto->in_band) { in_band_set_remotes(ofproto->in_band, addrs, n_addrs); @@ -711,7 +705,7 @@ update_fail_open(struct ofproto *p) size_t n; if (!p->fail_open) { - p->fail_open = fail_open_create(p, p->switch_status); + p->fail_open = fail_open_create(p); } n = 0; @@ -736,7 +730,6 @@ ofproto_set_controllers(struct ofproto *p, struct shash new_controllers; struct ofconn *ofconn, *next_ofconn; struct ofservice *ofservice, *next_ofservice; - bool ss_exists; size_t i; /* Create newly configured controllers and services. @@ -764,7 +757,6 @@ ofproto_set_controllers(struct ofproto *p, /* Delete controllers that are no longer configured. * Update configuration of all now-existing controllers. */ - ss_exists = false; HMAP_FOR_EACH_SAFE (ofconn, next_ofconn, hmap_node, &p->controllers) { struct ofproto_controller *c; @@ -773,9 +765,6 @@ ofproto_set_controllers(struct ofproto *p, ofconn_destroy(ofconn); } else { update_controller(ofconn, c); - if (ofconn->ss) { - ss_exists = true; - } } } @@ -797,13 +786,6 @@ ofproto_set_controllers(struct ofproto *p, update_in_band_remotes(p); update_fail_open(p); - - if (!hmap_is_empty(&p->controllers) && !ss_exists) { - ofconn = CONTAINER_OF(hmap_first(&p->controllers), - struct ofconn, hmap_node); - ofconn->ss = switch_status_register(p->switch_status, "remote", - rconn_status_cb, ofconn->rconn); - } } void @@ -1078,7 +1060,6 @@ ofproto_destroy(struct ofproto *p) } shash_destroy(&p->port_by_name); - switch_status_destroy(p->switch_status); netflow_destroy(p->netflow); ofproto_sflow_destroy(p->sflow); @@ -1843,7 +1824,6 @@ ofconn_destroy(struct ofconn *ofconn) discovery_destroy(ofconn->discovery); list_remove(&ofconn->node); - switch_status_unregister(ofconn->ss); rconn_destroy(ofconn->rconn); rconn_packet_counter_destroy(ofconn->packet_in_counter); rconn_packet_counter_destroy(ofconn->reply_counter); @@ -1958,8 +1938,7 @@ ofconn_set_rate_limit(struct ofconn *ofconn, int rate, int burst) if (rate > 0) { if (!*s) { - *s = pinsched_create(rate, burst, - ofconn->ofproto->switch_status); + *s = pinsched_create(rate, burst); } else { pinsched_set_limits(*s, rate, burst); } @@ -4359,10 +4338,6 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg) return 0; /* Nicira extension requests. */ - case OFPUTIL_NXT_STATUS_REQUEST: - return switch_status_handle_request( - ofconn->ofproto->switch_status, ofconn->rconn, oh); - case OFPUTIL_NXT_TUN_ID_FROM_COOKIE: return handle_tun_id_from_cookie(ofconn, oh); @@ -4418,7 +4393,6 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg) case OFPUTIL_OFPST_PORT_REPLY: case OFPUTIL_OFPST_TABLE_REPLY: case OFPUTIL_OFPST_AGGREGATE_REPLY: - case OFPUTIL_NXT_STATUS_REPLY: case OFPUTIL_NXT_ROLE_REPLY: case OFPUTIL_NXT_FLOW_REMOVED: case OFPUTIL_NXST_FLOW_REPLY: diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c index a307a0758..934140b2d 100644 --- a/ofproto/pinsched.c +++ b/ofproto/pinsched.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. @@ -27,7 +27,6 @@ #include "poll-loop.h" #include "random.h" #include "rconn.h" -#include "status.h" #include "timeval.h" #include "vconn.h" @@ -64,9 +63,6 @@ struct pinsched { unsigned long long n_normal; /* # txed w/o rate limit queuing. */ unsigned long long n_limited; /* # queued for rate limiting. */ unsigned long long n_queue_dropped; /* # dropped due to queue overflow. */ - - /* Switch status. */ - struct status_category *ss_cat; }; static void @@ -230,16 +226,6 @@ pinsched_send(struct pinsched *ps, uint16_t port_no, } } -static void -pinsched_status_cb(struct status_reply *sr, void *ps_) -{ - struct pinsched *ps = ps_; - - status_reply_put(sr, "normal=%llu", ps->n_normal); - status_reply_put(sr, "limited=%llu", ps->n_limited); - status_reply_put(sr, "queue-dropped=%llu", ps->n_queue_dropped); -} - void pinsched_run(struct pinsched *ps, pinsched_tx_cb *cb, void *aux) { @@ -272,7 +258,7 @@ pinsched_wait(struct pinsched *ps) /* Creates and returns a scheduler for sending packet-in messages. */ struct pinsched * -pinsched_create(int rate_limit, int burst_limit, struct switch_status *ss) +pinsched_create(int rate_limit, int burst_limit) { struct pinsched *ps; @@ -288,11 +274,6 @@ pinsched_create(int rate_limit, int burst_limit, struct switch_status *ss) ps->n_queue_dropped = 0; pinsched_set_limits(ps, rate_limit, burst_limit); - if (ss) { - ps->ss_cat = switch_status_register(ss, "rate-limit", - pinsched_status_cb, ps); - } - return ps; } @@ -308,7 +289,6 @@ pinsched_destroy(struct pinsched *ps) free(q); } hmap_destroy(&ps->queues); - switch_status_unregister(ps->ss_cat); free(ps); } } diff --git a/ofproto/pinsched.h b/ofproto/pinsched.h index 17e3db1d1..642ca30f9 100644 --- a/ofproto/pinsched.h +++ b/ofproto/pinsched.h @@ -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. @@ -20,11 +20,9 @@ #include struct ofpbuf; -struct switch_status; typedef void pinsched_tx_cb(struct ofpbuf *, void *aux); -struct pinsched *pinsched_create(int rate_limit, int burst_limit, - struct switch_status *); +struct pinsched *pinsched_create(int rate_limit, int burst_limit); void pinsched_get_limits(const struct pinsched *, int *rate_limit, int *burst_limit); void pinsched_set_limits(struct pinsched *, int rate_limit, int burst_limit); diff --git a/ofproto/status.c b/ofproto/status.c deleted file mode 100644 index 67cb27814..000000000 --- a/ofproto/status.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. - * - * 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: - * - * 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. - */ - -#include -#include "status.h" -#include -#include -#include -#include -#include -#include -#include "dynamic-string.h" -#include "list.h" -#include "ofp-util.h" -#include "ofpbuf.h" -#include "ofproto.h" -#include "openflow/nicira-ext.h" -#include "packets.h" -#include "rconn.h" -#include "svec.h" -#include "timeval.h" -#include "vconn.h" -#include "vlog.h" - -VLOG_DEFINE_THIS_MODULE(status); - -struct status_category { - struct list node; - char *name; - void (*cb)(struct status_reply *, void *aux); - void *aux; -}; - -struct switch_status { - time_t booted; - struct status_category *config_cat; - struct status_category *switch_cat; - struct list categories; -}; - -struct status_reply { - struct status_category *category; - struct ds request; - struct ds output; -}; - -int -switch_status_handle_request(struct switch_status *ss, struct rconn *rconn, - const struct ofp_header *oh) -{ - const struct nicira_header *request = (const struct nicira_header *) oh; - struct status_category *c; - struct nicira_header *reply; - struct status_reply sr; - struct ofpbuf *b; - int retval; - - sr.request.string = (void *) (request + 1); - sr.request.length = ntohs(request->header.length) - sizeof *request; - ds_init(&sr.output); - LIST_FOR_EACH (c, node, &ss->categories) { - if (!memcmp(c->name, sr.request.string, - MIN(strlen(c->name), sr.request.length))) { - sr.category = c; - c->cb(&sr, c->aux); - } - } - reply = make_nxmsg_xid(sizeof *reply + sr.output.length, - NXT_STATUS_REPLY, request->header.xid, &b); - memcpy(reply + 1, sr.output.string, sr.output.length); - retval = rconn_send(rconn, b, NULL); - if (retval && retval != EAGAIN) { - VLOG_WARN("send failed (%s)", strerror(retval)); - } - ds_destroy(&sr.output); - return 0; -} - -void -rconn_status_cb(struct status_reply *sr, void *rconn_) -{ - struct rconn *rconn = rconn_; - time_t now = time_now(); - uint32_t remote_ip = rconn_get_remote_ip(rconn); - uint32_t local_ip = rconn_get_local_ip(rconn); - - status_reply_put(sr, "name=%s", rconn_get_target(rconn)); - if (remote_ip) { - status_reply_put(sr, "remote-ip="IP_FMT, IP_ARGS(&remote_ip)); - status_reply_put(sr, "remote-port=%d", - ntohs(rconn_get_remote_port(rconn))); - status_reply_put(sr, "local-ip="IP_FMT, IP_ARGS(&local_ip)); - status_reply_put(sr, "local-port=%d", - ntohs(rconn_get_local_port(rconn))); - } - status_reply_put(sr, "state=%s", rconn_get_state(rconn)); - status_reply_put(sr, "backoff=%d", rconn_get_backoff(rconn)); - status_reply_put(sr, "probe-interval=%d", rconn_get_probe_interval(rconn)); - status_reply_put(sr, "is-connected=%s", - rconn_is_connected(rconn) ? "true" : "false"); - status_reply_put(sr, "sent-msgs=%u", rconn_packets_sent(rconn)); - status_reply_put(sr, "received-msgs=%u", rconn_packets_received(rconn)); - status_reply_put(sr, "attempted-connections=%u", - rconn_get_attempted_connections(rconn)); - status_reply_put(sr, "successful-connections=%u", - rconn_get_successful_connections(rconn)); - status_reply_put(sr, "last-connection=%ld", - (long int) (now - rconn_get_last_connection(rconn))); - status_reply_put(sr, "last-received=%ld", - (long int) (now - rconn_get_last_received(rconn))); - status_reply_put(sr, "time-connected=%lu", - rconn_get_total_time_connected(rconn)); - status_reply_put(sr, "state-elapsed=%u", rconn_get_state_elapsed(rconn)); -} - -static void -config_status_cb(struct status_reply *sr, void *ofproto_) -{ - const struct ofproto *ofproto = ofproto_; - uint64_t datapath_id; - - datapath_id = ofproto_get_datapath_id(ofproto); - if (datapath_id) { - status_reply_put(sr, "datapath-id=%016"PRIx64, datapath_id); - } -} - -static void -switch_status_cb(struct status_reply *sr, void *ss_) -{ - struct switch_status *ss = ss_; - time_t now = time_now(); - - status_reply_put(sr, "now=%ld", (long int) now); - status_reply_put(sr, "uptime=%ld", (long int) (now - ss->booted)); - status_reply_put(sr, "pid=%ld", (long int) getpid()); -} - -struct switch_status * -switch_status_create(const struct ofproto *ofproto) -{ - struct switch_status *ss = xzalloc(sizeof *ss); - ss->booted = time_now(); - list_init(&ss->categories); - ss->config_cat = switch_status_register(ss, "config", config_status_cb, - (void *) ofproto); - ss->switch_cat = switch_status_register(ss, "switch", switch_status_cb, - ss); - return ss; -} - -void -switch_status_destroy(struct switch_status *ss) -{ - if (ss) { - /* Orphan any remaining categories, so that unregistering them later - * won't write to bad memory. */ - struct status_category *c, *next; - LIST_FOR_EACH_SAFE (c, next, node, &ss->categories) { - list_init(&c->node); - } - switch_status_unregister(ss->config_cat); - switch_status_unregister(ss->switch_cat); - free(ss); - } -} - -struct status_category * -switch_status_register(struct switch_status *ss, - const char *category, - status_cb_func *cb, void *aux) -{ - struct status_category *c = xmalloc(sizeof *c); - c->cb = cb; - c->aux = aux; - c->name = xstrdup(category); - list_push_back(&ss->categories, &c->node); - return c; -} - -void -switch_status_unregister(struct status_category *c) -{ - if (c) { - if (!list_is_empty(&c->node)) { - list_remove(&c->node); - } - free(c->name); - free(c); - } -} - -void -status_reply_put(struct status_reply *sr, const char *content, ...) -{ - size_t old_length = sr->output.length; - size_t added; - va_list args; - - /* Append the status reply to the output. */ - ds_put_format(&sr->output, "%s.", sr->category->name); - va_start(args, content); - ds_put_format_valist(&sr->output, content, args); - va_end(args); - if (ds_last(&sr->output) != '\n') { - ds_put_char(&sr->output, '\n'); - } - - /* Drop what we just added if it doesn't match the request. */ - added = sr->output.length - old_length; - if (added < sr->request.length - || memcmp(&sr->output.string[old_length], - sr->request.string, sr->request.length)) { - ds_truncate(&sr->output, old_length); - } -} diff --git a/ofproto/status.h b/ofproto/status.h deleted file mode 100644 index b9db83619..000000000 --- a/ofproto/status.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. - * - * 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: - * - * 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. - */ - -#ifndef STATUS_H -#define STATUS_H 1 - -#include "compiler.h" - -struct ofp_header; -struct ofproto; -struct rconn; -struct status_reply; - -struct switch_status *switch_status_create(const struct ofproto *); -void switch_status_destroy(struct switch_status *); - -int switch_status_handle_request(struct switch_status *, struct rconn *, - const struct ofp_header *); - -typedef void status_cb_func(struct status_reply *, void *aux); -struct status_category *switch_status_register(struct switch_status *, - const char *category, - status_cb_func *, void *aux); -void switch_status_unregister(struct status_category *); - -void status_reply_put(struct status_reply *, const char *, ...) - PRINTF_FORMAT(2, 3); - -void rconn_status_cb(struct status_reply *, void *rconn_); - -#endif /* status.h */ diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 61a2f08c6..6e1e3bd4e 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -601,29 +601,6 @@ OFPT_BARRIER_REPLY (xid=0x1): ]) AT_CLEANUP -AT_SETUP([NXT_STATUS_REQUEST]) -AT_KEYWORDS([ofp-print]) -AT_CHECK([ovs-ofctl ofp-print "\ -01 04 00 16 00 00 00 01 00 00 23 20 00 00 00 00 \ -73 77 69 74 63 68 \ -"], [0], [dnl -NXT_STATUS_REQUEST (xid=0x1): "switch" -]) -AT_CLEANUP - -AT_SETUP([NXT_STATUS_REPLY]) -AT_KEYWORDS([ofp-print]) -AT_CHECK([ovs-ofctl ofp-print "\ -01 04 00 43 00 00 00 01 00 00 23 20 00 00 00 01 \ -73 77 69 74 63 68 2e 6e 6f 77 3d 31 30 36 31 36 \ -0a 73 77 69 74 63 68 2e 75 70 74 69 6d 65 3d 31 \ -31 33 36 0a 73 77 69 74 63 68 2e 70 69 64 3d 38 \ -31 31 0a \ -"], [0], [dnl -NXT_STATUS_REPLY (xid=0x1): "switch.now=10616\012switch.uptime=1136\012switch.pid=811\012" -]) -AT_CLEANUP - AT_SETUP([NXT_TUN_ID_FROM_COOKIE]) AT_KEYWORDS([ofp-print]) AT_CHECK([ovs-ofctl ofp-print "\ diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in index 3472cc1a4..ec9129d24 100644 --- a/utilities/ovs-ofctl.8.in +++ b/utilities/ovs-ofctl.8.in @@ -54,13 +54,6 @@ Prints to the console information on \fIswitch\fR, including information on its flow tables and ports. . .TP -\fBstatus \fIswitch\fR [\fIkey\fR] -Prints to the console a series of key-value pairs that report the -status of \fIswitch\fR. If \fIkey\fR is specified, only the key-value -pairs whose key names begin with \fIkey\fR are printed. If \fIkey\fR is -omitted, all key-value pairs are printed. -. -.TP \fBdump\-tables \fIswitch\fR Prints to the console statistics for each of the flow tables used by \fIswitch\fR. diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 5c89c7673..cd44cd8be 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -158,7 +158,6 @@ usage(void) "usage: %s [OPTIONS] COMMAND [ARG...]\n" "\nFor OpenFlow switches:\n" " show SWITCH show OpenFlow information\n" - " status SWITCH [KEY] report statistics (about KEY)\n" " dump-desc SWITCH print switch description\n" " dump-tables SWITCH print table stats\n" " mod-port SWITCH IFACE ACT modify port behavior\n" @@ -400,36 +399,6 @@ do_show(int argc OVS_UNUSED, char *argv[]) dump_trivial_transaction(argv[1], OFPT_GET_CONFIG_REQUEST); } -static void -do_status(int argc, char *argv[]) -{ - struct nicira_header *request, *reply; - struct vconn *vconn; - struct ofpbuf *b; - - request = make_nxmsg(sizeof *request, NXT_STATUS_REQUEST, &b); - if (argc > 2) { - ofpbuf_put(b, argv[2], strlen(argv[2])); - update_openflow_length(b); - } - open_vconn(argv[1], &vconn); - run(vconn_transact(vconn, b, &b), "talking to %s", argv[1]); - vconn_close(vconn); - - if (b->size < sizeof *reply) { - ovs_fatal(0, "short reply (%zu bytes)", b->size); - } - reply = b->data; - if (reply->header.type != OFPT_VENDOR - || reply->vendor != ntohl(NX_VENDOR_ID) - || reply->subtype != ntohl(NXT_STATUS_REPLY)) { - ofp_print(stderr, b->data, b->size, verbosity + 2); - ovs_fatal(0, "bad reply"); - } - - fwrite(reply + 1, b->size - sizeof *reply, 1, stdout); -} - static void do_dump_desc(int argc OVS_UNUSED, char *argv[]) { @@ -1063,7 +1032,6 @@ do_ofp_print(int argc, char *argv[]) static const struct command all_commands[] = { { "show", 1, 1, do_show }, - { "status", 1, 2, do_status }, { "monitor", 1, 2, do_monitor }, { "snoop", 1, 1, do_snoop }, { "dump-desc", 1, 1, do_dump_desc },