From 142cdb018d0f0941b2c03d4be7f9a06a0aeb5122 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 4 Nov 2013 22:34:09 -0800 Subject: [PATCH] ofp-util: Report OFPMMFC_BAD_COMMAND for bad meter mod commands. Signed-off-by: Ben Pfaff Acked-by: Jarno Rajahalme --- lib/ofp-util.c | 5 +++++ tests/ofp-print.at | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index be632e936..16b09f6ae 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -1731,6 +1731,11 @@ ofputil_decode_meter_mod(const struct ofp_header *oh, /* Translate the message. */ mm->command = ntohs(omm->command); + if (mm->command != OFPMC13_ADD && + mm->command != OFPMC13_MODIFY && + mm->command != OFPMC13_DELETE) { + return OFPERR_OFPMMFC_BAD_COMMAND; + } mm->meter.meter_id = ntohl(omm->meter_id); if (mm->command == OFPMC13_DELETE) { diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 36dad6aeb..9d01be311 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -1866,6 +1866,15 @@ OFPT_METER_MOD (OF1.3) (xid=0x8501d738): ***decode error: OFPMMFC_BAD_BAND*** ]) AT_CLEANUP +AT_SETUP([OFPT_METER_MOD request - bad command - OF1.3]) +AT_KEYWORDS([ofp-print]) +AT_CHECK([ovs-ofctl ofp-print "\ +04 1d 00 10 28 a6 26 52 00 08 00 00 00 00 00 01 +"], [0], [dnl +OFPT_METER_MOD (OF1.3) (xid=0x28a62652): ***decode error: OFPMMFC_BAD_COMMAND*** +]) +AT_CLEANUP + AT_SETUP([OFPST_METER request - OF1.3]) AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST]) AT_CHECK([ovs-ofctl ofp-print "041200180000000200090000000000000000000100000000"], [0], [dnl -- 2.47.0