From d8ab75cd69c6eee136636c75f5c8aa6bcd8d7a53 Mon Sep 17 00:00:00 2001 From: Vasu Dasari Date: Wed, 8 Dec 2021 18:05:22 -0500 Subject: ofp-monitor: Extend Flow Monitoring support for OF 1.0-1.2 with Nicira Extensions. Currently OVS supports flow-monitoring for OpenFlow 1.0 and Nicira Extenstions. Any other OpenFlow versioned messages are not accepted. This change will allow OpenFlow1.0-1.2 Flow Monitoring with Nicira extensions be accepted. Also made sure that flow-monitoring updates, flow monitoring pause messages, resume messages are sent in the same OpenFlow version as that of flow-monitor request. Description of changes: 1. Generate ofp-msgs.inc to be able to support 1.0-1.2 Flow Monitoring messages. include/openvswitch/ofp-msgs.h 2. Support vconn to accept user specified version and use it for vconn flow-monitoring session ofproto/ofproto.c 3. Modify APIs to use protocol as an argument to encode and decode messages include/openvswitch/ofp-monitor.h lib/ofp-monitor.c ofproto/connmgr.c ofproto/connmgr.h ofproto/ofproto.c 4. Modified following testcases to be verified across supported OF Versions ofproto - flow monitoring ofproto - flow monitoring with !own ofproto - flow monitoring with out_port ofproto - flow monitoring pause and resume ofproto - flow monitoring usable protocols tests/ofproto.at 5. Updated NEWS with the support added with this commit Signed-off-by: Vasu Dasari Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2020-December/050820.html Acked-by: Aaron Conole Signed-off-by: Ilya Maximets --- utilities/ovs-ofctl.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'utilities/ovs-ofctl.c') diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 6771973ae..b6d103ffd 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -1740,6 +1740,7 @@ ofctl_flow_mod__(const char *remote, struct ofputil_flow_mod *fms, { enum ofputil_protocol protocol; struct vconn *vconn; + struct ds ds = DS_EMPTY_INITIALIZER; size_t i; if (bundle) { @@ -1751,11 +1752,23 @@ ofctl_flow_mod__(const char *remote, struct ofputil_flow_mod *fms, for (i = 0; i < n_fms; i++) { struct ofputil_flow_mod *fm = &fms[i]; - - transact_noreply(vconn, ofputil_encode_flow_mod(fm, protocol)); + struct ofpbuf *buf = ofputil_encode_flow_mod(fm, protocol); + + /* If user has opted for verbosity of 5 or more dump the + * constructed OpenFlow packet in hex format */ + if (verbosity == 5) { + ds_put_hex_dump(&ds, buf->data, buf->size, 0, true); + } else if (verbosity > 5) { + ds_put_hex(&ds, buf->data, buf->size); + ds_put_char(&ds, '\n'); + } + transact_noreply(vconn, buf); free(CONST_CAST(struct ofpact *, fm->ofpacts)); minimatch_destroy(&fm->match); } + fputs(ds_cstr(&ds), stdout); + ds_destroy(&ds); + vconn_close(vconn); } @@ -2239,6 +2252,7 @@ ofctl_monitor(struct ovs_cmdl_context *ctx) { struct vconn *vconn; int i; + enum ofputil_protocol protocol; enum ofputil_protocol usable_protocols; /* If the user wants the invalid_ttl_to_controller feature, limit the @@ -2263,7 +2277,7 @@ ofctl_monitor(struct ovs_cmdl_context *ctx) } } - open_vconn(ctx->argv[1], &vconn); + protocol = open_vconn(ctx->argv[1], &vconn); bool resume_continuations = false; for (i = 2; i < ctx->argc; i++) { const char *arg = ctx->argv[i]; @@ -2298,7 +2312,7 @@ ofctl_monitor(struct ovs_cmdl_context *ctx) } msg = ofpbuf_new(0); - ofputil_append_flow_monitor_request(&fmr, msg); + ofputil_append_flow_monitor_request(&fmr, msg, protocol); dump_transaction(vconn, msg); fflush(stdout); } else if (!strcmp(arg, "resume")) { -- cgit v1.2.1