- type = ntohs(rq->type);
- if (rq->header.version != OFP_VERSION
- || rq->header.type != OFPT_STATS_REQUEST
- || ntohs(rq->header.length) != len
- || type >= ARRAY_SIZE(stats)
- || !stats[type].dump)
+ sender.xid = type = ntohs(rq->type);
+ if (rq->header.version != OFP_VERSION) {
+ dp_send_error_msg(dp, &sender, OFPET_BAD_REQUEST,
+ OFPBRC_BAD_VERSION, rq, len);
+ return -EINVAL;
+ }
+ if (rq->header.type != OFPT_STATS_REQUEST
+ || ntohs(rq->header.length) != len)
+ return -EINVAL;
+
+ if (type >= ARRAY_SIZE(stats) || !stats[type].dump) {
+ dp_send_error_msg(dp, &sender, OFPET_BAD_REQUEST,
+ OFPBRC_BAD_STAT, rq, len);