From 7d7d973d8b37a791d0c153dbcf55a559418bab6b Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Wed, 3 Sep 2008 17:51:42 -0700 Subject: [PATCH] Add serial number to description status message. --- datapath/datapath.c | 28 ++++++++++++++++------------ ext | 1 - include/openflow.h | 20 +++++++++++--------- lib/ofp-print.c | 17 +++++++++-------- switch/datapath.c | 16 +++++++++------- switch/switch.c | 17 ++++++++++++----- utilities/dpctl.c | 8 ++++---- 7 files changed, 61 insertions(+), 46 deletions(-) delete mode 160000 ext diff --git a/datapath/datapath.c b/datapath/datapath.c index d68151d0..d405fc15 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -43,19 +43,22 @@ /* Strings to describe the manufacturer, hardware, and software. This data - * is queriable through the version stats message. */ -static char mfr_desc[VERSION_STR_LEN] = "Nicira Networks"; -static char hw_desc[VERSION_STR_LEN] = "Reference Linux Kernel Module"; -static char sw_desc[VERSION_STR_LEN] = VERSION; + * is queriable through the switch description stats message. */ +static char mfr_desc[DESC_STR_LEN] = "Nicira Networks"; +static char hw_desc[DESC_STR_LEN] = "Reference Linux Kernel Module"; +static char sw_desc[DESC_STR_LEN] = VERSION; +static char serial_num[SERIAL_NUM_LEN] = "None"; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) module_param_string(mfr_desc, mfr_desc, sizeof mfr_desc, 0444); module_param_string(hw_desc, hw_desc, sizeof hw_desc, 0444); module_param_string(sw_desc, sw_desc, sizeof sw_desc, 0444); +module_param_string(serial_num, serial_num, sizeof serial_num, 0444); #else MODULE_PARM(mfr_desc, "s"); MODULE_PARM(hw_desc, "s"); MODULE_PARM(sw_desc, "s"); +MODULE_PARM(serial_num, "s"); #endif @@ -1218,20 +1221,21 @@ static struct nla_policy dp_genl_openflow_policy[DP_GENL_A_MAX + 1] = { [DP_GENL_A_DP_IDX] = { .type = NLA_U32 }, }; -static int version_stats_dump(struct datapath *dp, void *state, +static int desc_stats_dump(struct datapath *dp, void *state, void *body, int *body_len) { - struct ofp_version_stats *ovs = body; - int n_bytes = sizeof *ovs; + struct ofp_desc_stats *ods = body; + int n_bytes = sizeof *ods; if (n_bytes > *body_len) { return -ENOBUFS; } *body_len = n_bytes; - strncpy(ovs->mfr_desc, mfr_desc, sizeof ovs->mfr_desc); - strncpy(ovs->hw_desc, hw_desc, sizeof ovs->hw_desc); - strncpy(ovs->sw_desc, sw_desc, sizeof ovs->sw_desc); + strncpy(ods->mfr_desc, mfr_desc, sizeof ods->mfr_desc); + strncpy(ods->hw_desc, hw_desc, sizeof ods->hw_desc); + strncpy(ods->sw_desc, sw_desc, sizeof ods->sw_desc); + strncpy(ods->serial_num, serial_num, sizeof ods->serial_num); return 0; } @@ -1507,11 +1511,11 @@ struct stats_type { }; static const struct stats_type stats[] = { - [OFPST_VERSION] = { + [OFPST_DESC] = { 0, 0, NULL, - version_stats_dump, + desc_stats_dump, NULL }, [OFPST_FLOW] = { diff --git a/ext b/ext deleted file mode 160000 index 4cf18a51..00000000 --- a/ext +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4cf18a517a2663e945529a16e5d18e3b676c2687 diff --git a/include/openflow.h b/include/openflow.h index 7456a6e4..1ad8227e 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -446,8 +446,8 @@ OFP_ASSERT(sizeof(struct ofp_error_msg) == 12); enum ofp_stats_types { /* Description of this OpenFlow switch. * The request body is empty. - * The reply body is struct ofp_version_stats. */ - OFPST_VERSION, + * The reply body is struct ofp_desc_stats. */ + OFPST_DESC, /* Individual flow statistics. * The request body is struct ofp_flow_stats_request. @@ -498,15 +498,17 @@ struct ofp_stats_reply { }; OFP_ASSERT(sizeof(struct ofp_stats_reply) == 12); -#define VERSION_STR_LEN 256 -/* Body of reply to OFPST_VERSION request. Each entry is a NULL-terminated +#define DESC_STR_LEN 256 +#define SERIAL_NUM_LEN 32 +/* Body of reply to OFPST_DESC request. Each entry is a NULL-terminated * ASCII string. */ -struct ofp_version_stats { - char mfr_desc[VERSION_STR_LEN]; /* Manufacturer description. */ - char hw_desc[VERSION_STR_LEN]; /* Hardware description. */ - char sw_desc[VERSION_STR_LEN]; /* Software description. */ +struct ofp_desc_stats { + char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */ + char hw_desc[DESC_STR_LEN]; /* Hardware description. */ + char sw_desc[DESC_STR_LEN]; /* Software description. */ + char serial_num[SERIAL_NUM_LEN]; /* Serial number. */ }; -OFP_ASSERT(sizeof(struct ofp_version_stats) == 768); +OFP_ASSERT(sizeof(struct ofp_desc_stats) == 800); /* 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 d758680f..7cfe0a3d 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -633,14 +633,15 @@ ofp_print_port_status(struct ds *string, const void *oh, size_t len, } static void -ofp_version_stats_reply(struct ds *string, const void *body, size_t len, +ofp_desc_stats_reply(struct ds *string, const void *body, size_t len, int verbosity) { - const struct ofp_version_stats *vs = body; + const struct ofp_desc_stats *ods = body; - ds_put_format(string, "Manufacturer: %s\n", vs->mfr_desc); - ds_put_format(string, "Hardware: %s\n", vs->hw_desc); - ds_put_format(string, "Software: %s\n", vs->sw_desc); + ds_put_format(string, "Manufacturer: %s\n", ods->mfr_desc); + 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); } static void @@ -852,10 +853,10 @@ print_stats(struct ds *string, int type, const void *body, size_t body_len, }; static const struct stats_type stats_types[] = { - [OFPST_VERSION] = { - "version", + [OFPST_DESC] = { + "description", { 0, 0, NULL }, - { 0, SIZE_MAX, ofp_version_stats_reply }, + { 0, SIZE_MAX, ofp_desc_stats_reply }, }, [OFPST_FLOW] = { "flow", diff --git a/switch/datapath.c b/switch/datapath.c index 4776c619..c25bc3e1 100644 --- a/switch/datapath.c +++ b/switch/datapath.c @@ -66,6 +66,7 @@ enum br_port_status { extern char mfr_desc; extern char hw_desc; extern char sw_desc; +extern char serial_num; /* Capabilities supported by this implementation. */ #define OFP_SUPPORTED_CAPABILITIES ( OFPC_FLOW_STATS \ @@ -1239,14 +1240,15 @@ recv_flow(struct datapath *dp, const struct sender *sender UNUSED, } } -static int version_stats_dump(struct datapath *dp, void *state, +static int desc_stats_dump(struct datapath *dp, void *state, struct buffer *buffer) { - struct ofp_version_stats *ovs = buffer_put_uninit(buffer, sizeof *ovs); + struct ofp_desc_stats *ods = buffer_put_uninit(buffer, sizeof *ods); - strncpy(ovs->mfr_desc, &mfr_desc, sizeof ovs->mfr_desc); - strncpy(ovs->hw_desc, &hw_desc, sizeof ovs->hw_desc); - strncpy(ovs->sw_desc, &sw_desc, sizeof ovs->sw_desc); + strncpy(ods->mfr_desc, &mfr_desc, sizeof ods->mfr_desc); + strncpy(ods->hw_desc, &hw_desc, sizeof ods->hw_desc); + strncpy(ods->sw_desc, &sw_desc, sizeof ods->sw_desc); + strncpy(ods->serial_num, &serial_num, sizeof ods->serial_num); return 0; } @@ -1470,11 +1472,11 @@ struct stats_type { }; static const struct stats_type stats[] = { - [OFPST_VERSION] = { + [OFPST_DESC] = { 0, 0, NULL, - version_stats_dump, + desc_stats_dump, NULL }, [OFPST_FLOW] = { diff --git a/switch/switch.c b/switch/switch.c index 28a6b427..9d307db9 100644 --- a/switch/switch.c +++ b/switch/switch.c @@ -59,10 +59,11 @@ /* Strings to describe the manufacturer, hardware, and software. This data - * is queriable through the version stats message. */ -char mfr_desc[VERSION_STR_LEN] = "Nicira Networks"; -char hw_desc[VERSION_STR_LEN] = "Reference User-Space Switch"; -char sw_desc[VERSION_STR_LEN] = VERSION; + * is queriable through the switch description stats message. */ +char mfr_desc[DESC_STR_LEN] = "Nicira Networks"; +char hw_desc[DESC_STR_LEN] = "Reference User-Space Switch"; +char sw_desc[DESC_STR_LEN] = VERSION; +char serial_num[SERIAL_NUM_LEN] = "None"; static void parse_options(int argc, char *argv[]); static void usage(void) NO_RETURN; @@ -163,7 +164,8 @@ parse_options(int argc, char *argv[]) OPT_MAX_BACKOFF = UCHAR_MAX + 1, OPT_MFR_DESC, OPT_HW_DESC, - OPT_SW_DESC + OPT_SW_DESC, + OPT_SERIAL_NUM }; static struct option long_options[] = { @@ -180,6 +182,7 @@ parse_options(int argc, char *argv[]) {"mfr-desc", required_argument, 0, OPT_MFR_DESC}, {"hw-desc", required_argument, 0, OPT_HW_DESC}, {"sw-desc", required_argument, 0, OPT_SW_DESC}, + {"serial_num", required_argument, 0, OPT_SERIAL_NUM}, VCONN_SSL_LONG_OPTIONS {0, 0, 0, 0}, }; @@ -259,6 +262,10 @@ parse_options(int argc, char *argv[]) strncpy(sw_desc, optarg, sizeof sw_desc); break; + case OPT_SERIAL_NUM: + strncpy(serial_num, optarg, sizeof serial_num); + break; + case 'l': if (listen_vconn_name) { fatal(0, "-l or --listen may be only specified once"); diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 381a1c78..62c93c67 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -194,7 +194,7 @@ usage(void) "\nFor local datapaths and remote switches:\n" " show SWITCH show basic information\n" " status SWITCH [KEY] report statistics (about KEY)\n" - " dump-version SWITCH print version information\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-ports SWITCH print port statistics\n" @@ -436,9 +436,9 @@ do_status(int argc, char *argv[]) } static void -do_dump_version(int argc, char *argv[]) +do_dump_desc(int argc, char *argv[]) { - dump_trivial_stats_transaction(argv[1], OFPST_VERSION); + dump_trivial_stats_transaction(argv[1], OFPST_DESC); } static void @@ -1096,7 +1096,7 @@ static struct command all_commands[] = { { "help", 0, INT_MAX, do_help }, { "monitor", 1, 1, do_monitor }, - { "dump-version", 1, 1, do_dump_version }, + { "dump-desc", 1, 1, do_dump_desc }, { "dump-tables", 1, 1, do_dump_tables }, { "dump-flows", 1, 2, do_dump_flows }, { "dump-aggregate", 1, 2, do_dump_aggregate }, -- 2.30.2