the correct error in that case is OFPERR_OFPBRC_BAD_STAT, not OFPERR_OFPBRC_BAD_TYPE.
Signed-off-by: YAMAMOTO Takashi <yamam...@valinux.co.jp> --- lib/ofp-msgs.c | 26 ++++++++++++++++++++------ lib/ofp-msgs.h | 1 + ofproto/ofproto.c | 8 ++++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index d136f73..18c9d40 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -260,22 +260,28 @@ ofphdrs_decode_assert(struct ofphdrs *hdrs, } static bool -ofphdrs_is_stat(const struct ofphdrs *hdrs) +ofp_is_stat(enum ofp_version version, uint8_t type) { - switch ((enum ofp_version) hdrs->version) { + + switch (version) { case OFP10_VERSION: - return (hdrs->type == OFPT10_STATS_REQUEST || - hdrs->type == OFPT10_STATS_REPLY); + return (type == OFPT10_STATS_REQUEST || type == OFPT10_STATS_REPLY); case OFP11_VERSION: case OFP12_VERSION: case OFP13_VERSION: - return (hdrs->type == OFPT11_STATS_REQUEST || - hdrs->type == OFPT11_STATS_REPLY); + return (type == OFPT11_STATS_REQUEST || type == OFPT11_STATS_REPLY); } return false; } +static bool +ofphdrs_is_stat(const struct ofphdrs *hdrs) +{ + + return ofp_is_stat((enum ofp_version) hdrs->version, hdrs->type); +} + size_t ofphdrs_len(const struct ofphdrs *hdrs) { @@ -811,6 +817,14 @@ ofpmsg_body(const struct ofp_header *oh) ofphdrs_decode_assert(&hdrs, oh, ntohs(oh->length)); return (const uint8_t *) oh + ofphdrs_len(&hdrs); } + +/* Return if it's a stat/multipart (OFPST) message. */ +bool +ofpmsg_is_stat(const struct ofp_header *oh) +{ + + return ofp_is_stat(oh->version, oh->type); +} static ovs_be16 *ofpmp_flags__(const struct ofp_header *); diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h index bfc84f3..dd4909b 100644 --- a/lib/ofp-msgs.h +++ b/lib/ofp-msgs.h @@ -584,6 +584,7 @@ enum ofptype ofptype_from_ofpraw(enum ofpraw); /* OpenFlow message properties. */ void ofpmsg_update_length(struct ofpbuf *); const void *ofpmsg_body(const struct ofp_header *); +bool ofpmsg_is_stat(const struct ofp_header *); /* Multipart messages (aka "statistics"). * diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 6d625c2..b51b00f 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -5785,7 +5785,7 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg) /* FIXME: Change the following once they are implemented: */ case OFPTYPE_QUEUE_GET_CONFIG_REQUEST: case OFPTYPE_TABLE_FEATURES_STATS_REQUEST: - return OFPERR_OFPBRC_BAD_TYPE; + /* fallthrough */ case OFPTYPE_HELLO: case OFPTYPE_ERROR: @@ -5816,7 +5816,11 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg) case OFPTYPE_METER_FEATURES_STATS_REPLY: case OFPTYPE_TABLE_FEATURES_STATS_REPLY: default: - return OFPERR_OFPBRC_BAD_TYPE; + if (ofpmsg_is_stat(oh)) { + return OFPERR_OFPBRC_BAD_STAT; + } else { + return OFPERR_OFPBRC_BAD_TYPE; + } } } -- 1.8.3.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev