diff mbox series

[ovs-dev,v2,1/4] ofp-monitor: Set the table id of decoded OpenFlow 1.4 deletes.

Message ID CAB8Pm=ydOma2G19jS+CbMYpUN0E+rCF2gCxHu40p70sERzY=4A@mail.gmail.com
State New
Delegated to: Ilya Maximets
Headers show
Series ofproto: Fix flow monitor requests and oversized OpenFlow messages. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_FreeBSD_Build_and_Test success github build: passed

Commit Message

Alejandro Pacheco Oct. 18, 2026, 5:50 a.m. UTC
From: Alejandro Pacheco <alepacheco99@gmail.com>
ofputil_decode_flow_monitor_request() returns early for an OpenFlow 1.4
DELETE command, before it sets 'table_id'.  The caller,
handle_flow_monitor_request(), still checks 'table_id' against the
number of tables for every command, so a DELETE is accepted or refused
with OFPBRC_BAD_TABLE_ID depending on whatever the stack held.

Set 'table_id' to OFPTT_ALL for a DELETE, which only uses the monitor
id.

Fixes: c3e64047d1cc ("ofp-monitor: Support flow monitoring for OpenFlow 1.3, 1.4+.")
Assisted-by: claude-opus-5-5, Claude Code
Signed-off-by: Alejandro Pacheco <alepacheco99@gmail.com>
---
 lib/ofp-monitor.c |  2 ++
 tests/ofproto.at  | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
diff mbox series

Patch

diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index 29b0c5965..91dc1a00c 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -535,6 +535,8 @@  ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
         rq->command = ofmr->command;
 
         if (ofmr->command == OFPFMC_DELETE) {
+            /* Only the monitor id matters for a delete. */
+            rq->table_id = OFPTT_ALL;
             return ofputil_pull_ofp11_match(msg, NULL, NULL, &rq->match, NULL);
         }
 
diff --git a/tests/ofproto.at b/tests/ofproto.at
index a65e612bd..220d96691 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -5023,6 +5023,40 @@  OVS_APP_EXIT_AND_WAIT([ovs-ofctl])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto - OpenFlow14 flow monitor delete])
+AT_KEYWORDS([monitor])
+OVS_VSWITCHD_START
+
+ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
+AT_CAPTURE_FILE([monitor.log])
+
+# Add monitor 5, then delete it in a second request.
+ovs-appctl -t ovs-ofctl ofctl/send 0512002800000002001000000000000000000005ffffffffffffffff000fff000001000400000000
+ovs-appctl -t ovs-ofctl ofctl/send 0512002800000003001000000000000000000005ffffffffffffffff0000ff020001000400000000
+ovs-appctl -t ovs-ofctl ofctl/barrier
+
+AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
+send: OFPST_FLOW_MONITOR request (OF1.4):
+ id=5 flags=initial,add,delete,modify
+OFPST_FLOW_MONITOR reply (OF1.4):
+send: OFPST_FLOW_MONITOR request (OF1.4):
+ id=5 command=delete
+OFPST_FLOW_MONITOR reply (OF1.4):
+OFPT_BARRIER_REPLY (OF1.4):
+])
+
+# No monitor is left to report additions.
+ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
+ovs-ofctl add-flow br0 udp,actions=normal
+ovs-appctl -t ovs-ofctl ofctl/barrier
+AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
+OFPT_BARRIER_REPLY (OF1.4):
+])
+
+OVS_APP_EXIT_AND_WAIT([ovs-ofctl])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
 AT_KEYWORDS([monitor])
 OVS_VSWITCHD_START