From: Justin Pettit Date: Wed, 13 Jan 2010 07:01:25 +0000 (-0800) Subject: ofproto: Add user-specifiable datapath description (OpenFlow 1.0) X-Git-Tag: v1.0.0~259^2~105 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=8abc4ed712a755b0454e41cccad3ad33fa167f15;p=sliver-openvswitch.git ofproto: Add user-specifiable datapath description (OpenFlow 1.0) In OpenFlow 1.0, a "dp_desc" character array was added to the ofp_desc_stats structure that allows a human readable description of the datapath to be provided. NOTE: OVS at this point is not wire-compatible with OpenFlow 1.0 until the final commit in this OpenFlow 1.0 set. --- diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h index 50fee6eea..4835b8a99 100644 --- a/include/openflow/openflow.h +++ b/include/openflow/openflow.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * 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. @@ -725,8 +725,10 @@ struct ofp_desc_stats { char hw_desc[DESC_STR_LEN]; /* Hardware description. */ char sw_desc[DESC_STR_LEN]; /* Software description. */ char serial_num[SERIAL_NUM_LEN]; /* Serial number. */ + char dp_desc[DESC_STR_LEN]; /* Human readable description of + the datapath. */ }; -OFP_ASSERT(sizeof(struct ofp_desc_stats) == 800); +OFP_ASSERT(sizeof(struct ofp_desc_stats) == 1056); /* Body for ofp_stats_request of type OFPST_FLOW. */ struct ofp_flow_stats_request { diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 04bfe2f1d..19058b45b 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -927,6 +927,7 @@ ofp_desc_stats_reply(struct ds *string, const void *body, ds_put_format(string, "Hardware: %s\n", ods->hw_desc); ds_put_format(string, "Software: %s\n", ods->sw_desc); ds_put_format(string, "Serial Num: %s\n", ods->serial_num); + ds_put_format(string, "DP Description: %s\n", ods->dp_desc); } static void diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index f22c2070c..14a425db2 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -189,6 +189,7 @@ struct ofproto { char *hardware; /* Hardware. */ char *software; /* Software version. */ char *serial; /* Serial number. */ + char *dp_desc; /* Datapath description. */ /* Datapath. */ struct dpif *dpif; @@ -300,6 +301,7 @@ ofproto_create(const char *datapath, const char *datapath_type, p->hardware = xstrdup("Reference Implementation"); p->software = xstrdup(VERSION BUILDNR); p->serial = xstrdup("None"); + p->dp_desc = xstrdup("None"); /* Initialize datapath. */ p->dpif = dpif; @@ -387,7 +389,8 @@ ofproto_set_max_backoff(struct ofproto *p, int max_backoff) void ofproto_set_desc(struct ofproto *p, const char *manufacturer, const char *hardware, - const char *software, const char *serial) + const char *software, const char *serial, + const char *dp_desc) { if (manufacturer) { free(p->manufacturer); @@ -405,6 +408,10 @@ ofproto_set_desc(struct ofproto *p, free(p->serial); p->serial = xstrdup(serial); } + if (dp_desc) { + free(p->dp_desc); + p->dp_desc = xstrdup(dp_desc); + } } int @@ -2385,6 +2392,7 @@ handle_desc_stats_request(struct ofproto *p, struct ofconn *ofconn, strncpy(ods->hw_desc, p->hardware, sizeof ods->hw_desc); strncpy(ods->sw_desc, p->software, sizeof ods->sw_desc); strncpy(ods->serial_num, p->serial, sizeof ods->serial_num); + strncpy(ods->dp_desc, p->dp_desc, sizeof ods->dp_desc); queue_tx(msg, ofconn, ofconn->reply_counter); return 0; diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index a94c8b59b..668cdffb6 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -67,7 +67,8 @@ void ofproto_set_probe_interval(struct ofproto *, int probe_interval); void ofproto_set_max_backoff(struct ofproto *, int max_backoff); void ofproto_set_desc(struct ofproto *, const char *manufacturer, const char *hardware, - const char *software, const char *serial); + const char *software, const char *serial, + const char *dp_desc); int ofproto_set_in_band(struct ofproto *, bool in_band); int ofproto_set_discovery(struct ofproto *, bool discovery, const char *accept_controller_re, diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 1b8e7ebdf..011be3797 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -71,6 +71,7 @@ struct ofsettings { const char *hw_desc; /* Hardware. */ const char *sw_desc; /* Software version. */ const char *serial_desc; /* Serial number. */ + const char *dp_desc; /* Serial number. */ /* Related vconns and network devices. */ const char *controller_name; /* Controller (if not discovery mode). */ @@ -171,7 +172,8 @@ main(int argc, char *argv[]) if (s.datapath_id) { ofproto_set_datapath_id(ofproto, s.datapath_id); } - ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc, s.serial_desc); + ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc, + s.serial_desc, s.dp_desc); if (!s.listeners.n) { svec_add_nocopy(&s.listeners, xasprintf("punix:%s/%s.mgmt", ovs_rundir, s.dp_name)); @@ -242,6 +244,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) OPT_HARDWARE, OPT_SOFTWARE, OPT_SERIAL, + OPT_DP_DESC, OPT_ACCEPT_VCONN, OPT_NO_RESOLV_CONF, OPT_BR_NAME, @@ -269,6 +272,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) {"hardware", required_argument, 0, OPT_HARDWARE}, {"software", required_argument, 0, OPT_SOFTWARE}, {"serial", required_argument, 0, OPT_SERIAL}, + {"dp_desc", required_argument, 0, OPT_DP_DESC}, {"accept-vconn", required_argument, 0, OPT_ACCEPT_VCONN}, {"no-resolv-conf", no_argument, 0, OPT_NO_RESOLV_CONF}, {"config", required_argument, 0, 'F'}, @@ -307,6 +311,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) s->hw_desc = NULL; s->sw_desc = NULL; s->serial_desc = NULL; + s->dp_desc = NULL; svec_init(&s->listeners); svec_init(&s->snoops); s->fail_mode = FAIL_OPEN; @@ -353,6 +358,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s) s->serial_desc = optarg; break; + case OPT_DP_DESC: + s->dp_desc = optarg; + break; + case OPT_ACCEPT_VCONN: s->accept_controller_re = optarg; break; @@ -526,6 +535,7 @@ usage(void) " --hardware=HW Identify hardware as HW\n" " --software=SW Identify software as SW\n" " --serial=SERIAL Identify serial number as SERIAL\n" + " --dp_desc=DP_DESC Identify dp description as DP_DESC\n" "\nController discovery options:\n" " --accept-vconn=REGEX accept matching discovered controllers\n" " --no-resolv-conf do not update /etc/resolv.conf\n"