Signed-off-by: Simon Horman <[email protected]>
---
v5
* Initial Post
---
lib/ofp-util.c | 4 ++++
ofproto/ofproto.c | 27 ++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index fdded88..e8d96ff 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -899,6 +899,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = {
}
OFPST11_REQUEST(OFPST_DESC, OFPST_DESC, 0, 0),
OFPST11_REQUEST(OFPST_TABLE, OFPST_TABLE, 0, 0),
+ OFPST11_REQUEST(OFPST_PORT, OFPST_PORT,
+ sizeof(struct ofp11_port_stats_request), 0),
OFPST11_REQUEST(OFPST_PORT_DESC, OFPST_PORT_DESC, 0, 0),
#undef OFPST11_REQUEST
@@ -916,6 +918,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = {
OFPST12_REQUEST(OFPST11_AGGREGATE, OFPST_AGGREGATE,
sizeof(struct ofp11_flow_stats_request), 1),
OFPST12_REQUEST(OFPST_TABLE, OFPST_TABLE, 0, 0),
+ OFPST12_REQUEST(OFPST_PORT, OFPST_PORT,
+ sizeof(struct ofp11_port_stats_request), 0),
OFPST12_REQUEST(OFPST_PORT_DESC, OFPST_PORT_DESC, 0, 0),
#undef OFPST12_REQUEST
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index c71ec14..6d54b5a 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2336,13 +2336,34 @@ handle_port_stats_request(struct ofconn *ofconn,
const struct ofp_header *request)
{
struct ofproto *p = ofconn_get_ofproto(ofconn);
- struct ofp10_port_stats_request *psr = ofputil_stats_msg_body(request);
struct ofport *port;
struct list replies;
+ uint16_t port_no;
+
+ switch (request->version) {
+ case OFP12_VERSION:
+ case OFP11_VERSION: {
+ struct ofp11_port_stats_request *psr = ofputil_stats_msg_body(request);
+ enum ofperr error = ofputil_port_from_ofp11(psr->port_no, &port_no);
+ if (error) {
+ return error;
+ }
+ break;
+ }
+
+ case OFP10_VERSION: {
+ struct ofp10_port_stats_request *psr = ofputil_stats_msg_body(request);
+ port_no = ntohs(psr->port_no);
+ break;
+ }
+
+ default:
+ NOT_REACHED();
+ }
ofputil_start_stats_reply(request, &replies);
- if (psr->port_no != htons(OFPP_NONE)) {
- port = ofproto_get_port(p, ntohs(psr->port_no));
+ if (port_no != OFPP_NONE) {
+ port = ofproto_get_port(p, port_no);
if (port) {
append_port_stat(port, request->version, &replies);
}
--
1.7.10.2.484.gcd07cc5
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev