Skip to content

Commit

Permalink
ofproto: Get rid of archaic "switch status" OpenFlow extension.
Browse files Browse the repository at this point in the history
Back in 2008 or so, I introduced this extension as a way to provide
information about switch status to the new "switch UI" program.  Since
then, the switch UI program has been removed and the important information
that was provided by the switch status extension is now available in the
database, so we might as well get rid of this extension, and that is what
this commit does.
  • Loading branch information
blp committed Mar 16, 2011
1 parent ee8b231 commit 9b45d7f
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 544 deletions.
11 changes: 2 additions & 9 deletions include/openflow/nicira-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions lib/learning-switch.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 0 additions & 17 deletions lib/ofp-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions lib/ofp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions ofproto/automake.mk
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
56 changes: 2 additions & 54 deletions ofproto/discovery.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -29,7 +29,6 @@
#include "netdev.h"
#include "openflow/openflow.h"
#include "packets.h"
#include "status.h"
#include "stream-ssl.h"
#include "vlog.h"

Expand All @@ -42,63 +41,16 @@ 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);
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];
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions ofproto/discovery.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 *,
Expand Down
25 changes: 3 additions & 22 deletions ofproto/fail-open.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions ofproto/fail-open.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -24,15 +24,14 @@
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
* (OpenFlow priorities max out at 65535 and nothing else in Open vSwitch
* 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 *);
Expand Down
24 changes: 1 addition & 23 deletions ofproto/in-band.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
#include "status.h"
#include "timeval.h"
#include "vlog.h"

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 9b45d7f

Please sign in to comment.