From 535143871351a134f9b8e44fc05ef5ef5106bf85 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Tue, 21 Aug 2012 13:55:37 +0900 Subject: [PATCH] ovs-ofctl: Use vconn as a parameter of dump_stats_transaction() In order to form a stats message for the prevailing OpenFlow version of a vconn the vconn needs to be open at the time the request is encoded. Thus there is no longer a case where it makes sense to use dump_stats_transaction() without a vconn already being open and available to pass as a parameter. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- tests/ofproto.at | 12 ++++++------ utilities/ovs-ofctl.c | 37 +++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/ofproto.at b/tests/ofproto.at index 47402f79b..a05585105 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -60,12 +60,12 @@ AT_CHECK([STRIP_XIDS stdout], [0], [dnl OFPST_QUEUE reply: 0 queues ]) AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ALL 5], [0], - [OFPT_ERROR (xid=0x1): OFPQOFC_BAD_QUEUE -OFPST_QUEUE request (xid=0x1):port=ALL queue=5 + [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE +OFPST_QUEUE request (xid=0x2):port=ALL queue=5 ]) AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0], - [OFPT_ERROR (xid=0x1): OFPQOFC_BAD_PORT -OFPST_QUEUE request (xid=0x1):port=10 queue=ALL + [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT +OFPST_QUEUE request (xid=0x2):port=10 queue=ALL ]) OVS_VSWITCHD_STOP AT_CLEANUP @@ -354,7 +354,7 @@ AT_CLEANUP AT_SETUP([ofproto - flow table configuration]) OVS_VSWITCHD_START # Check the default configuration. -(echo "OFPST_TABLE reply (xid=0x1): 255 tables +(echo "OFPST_TABLE reply (xid=0x2): 255 tables 0: classifier: wild=0x3fffff, max=1000000, active=0 lookup=0, matched=0" x=1 @@ -379,7 +379,7 @@ AT_CHECK( ]) # Check that the configuration was updated. mv expout orig-expout -(echo "OFPST_TABLE reply (xid=0x1): 255 tables +(echo "OFPST_TABLE reply (xid=0x2): 255 tables 0: main : wild=0x3fffff, max=1000000, active=0 lookup=0, matched=0 1: table1 : wild=0x3fffff, max= 1024, active=0 diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 622e32f3b..5d10b3780 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -424,7 +424,7 @@ dump_trivial_transaction(const char *vconn_name, enum ofpraw raw) } static void -dump_stats_transaction__(struct vconn *vconn, struct ofpbuf *request) +dump_stats_transaction(struct vconn *vconn, struct ofpbuf *request) { const struct ofp_header *request_oh = request->data; ovs_be32 send_xid = request_oh->xid; @@ -467,24 +467,17 @@ dump_stats_transaction__(struct vconn *vconn, struct ofpbuf *request) } static void -dump_stats_transaction(const char *vconn_name, struct ofpbuf *request) +dump_trivial_stats_transaction(const char *vconn_name, enum ofpraw raw) { + struct ofpbuf *request; struct vconn *vconn; open_vconn(vconn_name, &vconn); - dump_stats_transaction__(vconn, request); + request = ofpraw_alloc(raw, vconn_get_version(vconn), 0); + dump_stats_transaction(vconn, request); vconn_close(vconn); } -static void -dump_trivial_stats_transaction(const char *vconn_name, enum ofpraw raw) -{ - struct ofpbuf *request; - - request = ofpraw_alloc(raw, OFP10_VERSION, 0); - dump_stats_transaction(vconn_name, request); -} - /* Sends 'request', which should be a request that only has a reply if an error * occurs, and waits for it to succeed or fail. If an error does occur, prints * it and exits with an error. @@ -839,7 +832,7 @@ ofctl_dump_flows__(int argc, char *argv[], bool aggregate) struct vconn *vconn; vconn = prepare_dump_flows(argc, argv, aggregate, &request); - dump_stats_transaction__(vconn, request); + dump_stats_transaction(vconn, request); vconn_close(vconn); } @@ -956,8 +949,11 @@ ofctl_queue_stats(int argc, char *argv[]) { struct ofp10_queue_stats_request *req; struct ofpbuf *request; + struct vconn *vconn; - request = ofpraw_alloc(OFPRAW_OFPST_QUEUE_REQUEST, OFP10_VERSION, 0); + open_vconn(argv[1], &vconn); + request = ofpraw_alloc(OFPRAW_OFPST_QUEUE_REQUEST, + vconn_get_version(vconn), 0); req = ofpbuf_put_zeros(request, sizeof *req); if (argc > 2 && argv[2][0] && strcasecmp(argv[2], "all")) { @@ -973,7 +969,8 @@ ofctl_queue_stats(int argc, char *argv[]) memset(req->pad, 0, sizeof req->pad); - dump_stats_transaction(argv[1], request); + dump_stats_transaction(vconn, request); + vconn_close(vconn); } static enum ofputil_protocol @@ -1377,7 +1374,7 @@ ofctl_monitor(int argc, char *argv[]) msg = ofpbuf_new(0); ofputil_append_flow_monitor_request(&fmr, msg); - dump_stats_transaction__(vconn, msg); + dump_stats_transaction(vconn, msg); } else { ovs_fatal(0, "%s: unsupported \"monitor\" argument", arg); } @@ -1418,13 +1415,17 @@ ofctl_dump_ports(int argc, char *argv[]) { struct ofp10_port_stats_request *req; struct ofpbuf *request; + struct vconn *vconn; uint16_t port; - request = ofpraw_alloc(OFPRAW_OFPST_PORT_REQUEST, OFP10_VERSION, 0); + open_vconn(argv[1], &vconn); + request = ofpraw_alloc(OFPRAW_OFPST_PORT_REQUEST, + vconn_get_version(vconn), 0); req = ofpbuf_put_zeros(request, sizeof *req); port = argc > 2 ? str_to_port_no(argv[1], argv[2]) : OFPP_NONE; req->port_no = htons(port); - dump_stats_transaction(argv[1], request); + dump_stats_transaction(vconn, request); + vconn_close(vconn); } static void -- 2.43.0