/* 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,
/*
- * 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.
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:
}
}
-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)
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;
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 },
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,
-# 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
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
/*
- * 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 "netdev.h"
#include "openflow/openflow.h"
#include "packets.h"
-#include "status.h"
#include "stream-ssl.h"
#include "vlog.h"
regex_t *regex;
struct dhclient *dhcp;
int n_changes;
- struct status_category *ss_cat;
};
static void modify_dhcp_request(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];
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;
regfree(d->regex);
free(d->regex);
dhclient_destroy(d->dhcp);
- switch_status_unregister(d->ss_cat);
free(d->dpif_name);
free(d);
}
/*
- * 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.
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 *,
/*
- * 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 "pktbuf.h"
#include "poll-loop.h"
#include "rconn.h"
-#include "status.h"
#include "timeval.h"
#include "vconn.h"
#include "vlog.h"
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;
};
}
}
-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;
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);
}
/*
- * 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.
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
* 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 *);
#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
-#include "status.h"
#include "timeval.h"
#include "vlog.h"
struct in_band {
struct ofproto *ofproto;
- struct status_category *ss_cat;
int queue_id, prev_queue_id;
/* Remote information. */
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
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];
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;
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);
}
/*
- * 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.
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);
#include "poll-loop.h"
#include "rconn.h"
#include "shash.h"
-#include "status.h"
#include "stream-ssl.h"
#include "svec.h"
#include "tag.h"
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? */
};
uint32_t max_ports;
/* Configuration. */
- struct switch_status *switch_status;
struct fail_open *fail_open;
struct netflow *netflow;
struct ofproto_sflow *sflow;
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;
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;
}
* 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);
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;
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.
/* 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;
ofconn_destroy(ofconn);
} else {
update_controller(ofconn, c);
- if (ofconn->ss) {
- ss_exists = true;
- }
}
}
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
}
shash_destroy(&p->port_by_name);
- switch_status_destroy(p->switch_status);
netflow_destroy(p->netflow);
ofproto_sflow_destroy(p->sflow);
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);
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);
}
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);
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:
/*
- * 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 "poll-loop.h"
#include "random.h"
#include "rconn.h"
-#include "status.h"
#include "timeval.h"
#include "vconn.h"
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
}
}
-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)
{
/* 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;
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;
}
free(q);
}
hmap_destroy(&ps->queues);
- switch_status_unregister(ps->ss_cat);
free(ps);
}
}
/*
- * 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 <stdint.h>
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);
+++ /dev/null
-/*
- * 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 <config.h>
-#include "status.h"
-#include <arpa/inet.h>
-#include <assert.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <stdlib.h>
-#include <unistd.h>
-#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);
- }
-}
+++ /dev/null
-/*
- * 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 */
])
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 "\
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.
"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"
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[])
{
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 },