summaryrefslogtreecommitdiff
path: root/utilities/ovs-ofctl.c
Commit message (Collapse)AuthorAgeFilesLines
* ofp-monitor: Support flow monitoring for OpenFlow 1.3, 1.4+.Vasu Dasari2022-04-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extended OpenFlow monitoring support * OpenFlow 1.3 with ONF extensions * OpenFlow 1.4+ as defined in OpenFlow specification 1.4+. ONF extensions are similar to Nicira extensions except for onf_flow_monitor_request{} where out_port is defined as 32-bit number OF(1.1) number, oxm match formats are used in update and request messages. Flow monitoring support in 1.4+ is slightly different from Nicira and ONF extensions. * More flow monitoring flags are defined. * Monitor add/modify/delete command is introduced in flow_monitor request message. * Addition of out_group as part of flow_monitor request message Description of changes: 1. Generate ofp-msgs.inc to be able to support 1.3, 1.4+ flow Monitoring messages. include/openvswitch/ofp-msgs.h 2. Modify openflow header files with protocol specific headers. include/openflow/openflow-1.3.h include/openflow/openflow-1.4.h 3. Modify OvS abstraction of openflow headers. ofp-monitor.h leverages enums from on nicira extensions for creating protocol abstraction headers. OF(1.4+) enums are superset of nicira extensions. include/openvswitch/ofp-monitor.h 4. Changes to these files reflect encoding and decoding of new protocol messages. lib/ofp-monitor.c 5. Changes to modules using ofp-monitor APIs. Most of the changes here are to migrate enums from nicira to OF 1.4+ versions. ofproto/connmgr.c ofproto/connmgr.h ofproto/ofproto-provider.h ofproto/ofproto.c 6. Extended protocol decoding tests to verify all protocol versions FLOW_MONITOR_CANCEL FLOW_MONITOR_PAUSED FLOW_MONITOR_RESUMED FLOW_MONITOR request FLOW_MONITOR reply tests/ofp-print.at 7. Modify flow monitoring tests to be able executed by all protocol versions. tests/ofproto.at 7. Modified documentation highlighting the change utilities/ovs-ofctl.8.in NEWS Signed-off-by: Vasu Dasari <vdasari@gmail.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2021-June/383915.html Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ofp-monitor: Extend Flow Monitoring support for OF 1.0-1.2 with Nicira ↵Vasu Dasari2022-04-281-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <vdasari@gmail.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2020-December/050820.html Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* list: use short version of safe loops if possible.Adrian Moreno2022-03-301-2/+2
| | | | | | | | | | | | | | | Using the SHORT version of the *_SAFE loops makes the code cleaner and less error-prone. So, use the SHORT version and remove the extra variable when possible. In order to be able to use both long and short versions without changing the name of the macro for all the clients, overload the existing name and select the appropriate version depending on the number of arguments. Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ovs-ofctl: Fix coredump when using "add-groups" command.Wang Yibo2021-05-141-1/+1
| | | | | | | | | | | | When using ovs-ofctl add-groups with only "switch" argument, a coredump is generated. The main reason is that the command "ovs-ofctl add-groups" need two arguments but the limitation of min-args of this command is set to 1. Fixes: 7395c05254df ("Implement OpenFlow 1.1+ "groups" protocol.") Submitted-at: https://github.com/openvswitch/ovs/pull/360 Signed-off-by: Wang Yibo <bobxxwang@126.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ovs-ofctl: Fix segfault due to bad meter n_bands.Flavio Fernandes2021-04-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Meter commands internally use ofctl_meter_mod__() and ofctl_meter_request__() functions, which have an optional parameter called str. When str is NULL, these 2 functions initialize a struct with meter bands set as NULL. It also needs to set meter n_bands to 0. Once del-meters change in test dpif-netdev.at is added, the valgrind report on test '992: dpif-netdev - meters' shows this issue: Conditional jump or move depends on uninitialised value(s) at 0x473534: ofputil_put_bands (ofp-meter.c:207) by 0x473534: ofputil_encode_meter_mod (ofp-meter.c:557) by 0x40FBA2: ofctl_meter_mod__ (ovs-ofctl.c:4038) by 0x417BD3: ovs_cmdl_run_command__ (command-line.c:247) by 0x4078BA: main (ovs-ofctl.c:179) Uninitialised value was created by a stack allocation at 0x409350: ofctl_del_meters (ovs-ofctl.c:4088) Fixes: 3200ed5805 ("ovs-ofctl: Add meter support.") Signed-off-by: Flavio Fernandes <flavio@flaviof.com> Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ofp-monitor: Fixed the usage of 'usable_protocols' variable in ↵Ashish Varma2019-11-011-0/+8
| | | | | | | | | | | | | | | 'parse_flow_monitor_request' function. 'usable_protocols' is now getting set to OFPUTIL_P_OF10_ANY on return from 'parse_flow_monitor_request' function. The calling function now checks for the value in this variable against the 'allowed_protocols' variable. Also a check is added for a match field which is not supported in OpenFlow 1.0 and return an error. Modified the man page of ovs-ofctl to reflect Flow Monitor support as OpenFlow 1.0 Nicira extension only. Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: fix memory leak in open_vconn__() functionDamijan Skvarc2019-09-241-0/+2
| | | | | Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Free leaked minimatchYifeng Sun2019-09-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Valgrind reported: 1056: ofproto - bundle with multiple flow mods (OpenFlow 1.4) ==19220== 160 bytes in 2 blocks are definitely lost in loss record 24 of 34 ==19220== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==19220== by 0x4979A4: xmalloc (util.c:138) ==19220== by 0x42407D: miniflow_alloc (flow.c:3340) ==19220== by 0x4296CF: minimatch_init (match.c:1758) ==19220== by 0x46273D: parse_ofp_str__ (ofp-flow.c:1759) ==19220== by 0x465B9E: parse_ofp_str (ofp-flow.c:1790) ==19220== by 0x465CE0: parse_ofp_flow_mod_str (ofp-flow.c:1817) ==19220== by 0x465DF6: parse_ofp_flow_mod_file (ofp-flow.c:1876) ==19220== by 0x410BA3: ofctl_flow_mod_file.isra.19 (ovs-ofctl.c:1773) ==19220== by 0x417933: ovs_cmdl_run_command__ (command-line.c:223) ==19220== by 0x406F68: main (ovs-ofctl.c:179) This patch fixes it. Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: New testing command "parse-group".Ben Pfaff2019-06-091-1/+40
| | | | | | | This will be used in an upcoming test. Acked-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofctl: break the loop if ovs_pcap_read returns errorLi RongQing2019-02-221-0/+1
| | | | | | | otherwise packet is NULL, and dereference it to cause segfault Signed-off-by: Li RongQing <lirongqing@baidu.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Remove support for OpenFlow 1.6 (draft).Ben Pfaff2019-02-051-3/+1
| | | | | | | | | ONF abandoned the OpenFlow specification, so that OpenFlow 1.6 will never be completed. It did not contain much in the way of useful features, so remove what support Open vSwitch already had. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ovs-vswitchd: Implement OFPT_TABLE_FEATURES table modification request.Ben Pfaff2019-01-151-21/+107
| | | | | | | | | This allows a controller to change the name of OpenFlow flow tables in the OVS software switch. CC: Brad Cowie <brad@cowie.nz> Acked-by: Justin Pettit <jpettit@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* vconn: Allow timeout configuration for blocking connection.Ilya Maximets2019-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some systems in case where remote is not responding, socket could remain in SYN_SENT state for a really long time without errors waiting for connection. This leads to situations where vconn connection hangs for a few minutes waiting for connection to the DOWN remote. For example, this situation emulated by "refuse-connection" vconn testcase. This leads to test failures because Alarm signal arrives much faster than ETIMEDOUT from the socket: ./vconn.at:21: ovstest test-vconn refuse-connection tcp Alarm clock stderr: |socket_util|INFO|0:127.0.0.1: listening on port 63812 |poll_loop|DBG|wakeup due to 0-ms timeout |poll_loop|DBG|wakeup due to 10155-ms timeout |fatal_signal|WARN|terminating with signal 14 (Alarm clock) ./vconn.at:21: exit code was 142, expected 0 vconn.at:21: 535. tcp vconn - refuse connection (vconn.at:21): FAILED This patch allowes to specify timeout value for vconn blocking connections. If the connection takes more time, socket will be closed with ETIMEDOUT error code. Negative value could be used to wait infinitely. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-table: Always format the table number in table features.Ben Pfaff2018-10-261-1/+0
| | | | | | | | | | | Table features should indicate the table number as well as the table name. Before this, the first line for each table looked like this: table myname ("myname"): but it's more useful if it's: table 123 ("myname"): Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ofp-table: Better summarize table features and statistics.Ben Pfaff2018-10-261-4/+9
| | | | | | | | | | | | | | | | Before this patch, most dump-table-stats outputs would contain about 250 lines of the form: table #: ditto With this patch, they have one line like this: tables 2...254: ditto which is much easier to read. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* pcap-file: Add nanosecond resolution pcap support.Mark Michelson2018-10-051-9/+11
| | | | | | | | | | | | PCAP header magic numbers are different for microsecond and nanosecond resolution timestamps. This patch adds support for understanding the difference and reporting the time correctly with ovs_pcap_read(). When writing pcap files, OVS will always use microsecond resolution, so no new calculations were added to those functions. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofproto: Handle OpenFlow version mismatch for requestforward with groups.Ben Pfaff2018-09-261-2/+3
| | | | | | | | | | | | | | | OpenFlow 1.4+ supports a feature called requestforward. When a controller enables this feature, the switch sends that controller a copy of other controllers' group and meter modification requests. OpenFlow 1.5 supports some group features not in OpenFlow 1.4. When OVS attempted to forward such requests to an OpenFlow 1.4 controller, it reported an error and exited. This commit fixes the problem by making OVS properly translate the messages to OpenFlow 1.4 format. Reported-by: Pierre Cregut <pierre.cregut@orange.com> Tested-by: Pierre Cregut <pierre.cregut@orange.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-September/047453.html Signed-off-by: Ben Pfaff <blp@ovn.org>
* tests: Use environment variable for default timeout.Ilya Maximets2018-08-151-3/+3
| | | | | | | | | | | Introduce new 'OVS_CTL_TIMEOUT' environment variable that, if set, will be used as a default timeout for OVS control utilities. Setting it in 'atlocal.in' will cover all the hangs inside the testsuite, even when utils called in a subshell. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* utilities: Fix and unify parsing of timeout option.Ilya Maximets2018-08-151-5/+3
| | | | | | | | | | | | | | Parsing of the '--timeout' option implemented differently for every single control utility and, which is more important, highly inaccurate. In most cases unsigned result of 'strtoul' stored in signed variable. Parsing failures are not tracked. 'ovs-appctl' even uses just 'atoi' without any checking of the argument or result. This patch unifies the parsing by using 'str_to_uint'. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofctl: Fixup compare_flows functionAlin Gabriel Serdean2018-08-081-2/+4
| | | | | | | | | | | | | In the case there was no sorting criteria the flows on Windows were being rearranged because it was always returning zero. Also check if there we need sorting to save a few cycles. CC: Ben Pfaff <blp@ovn.org> Co-authored-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Better validate OpenFlow message length in "ofp-parse-pcap".Ben Pfaff2018-08-061-1/+2
| | | | | | | Reported-by: Oscar Wilde <xdxiaobin@gmail.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-July/047070.html Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Aaron Conole <aconole@redhat.com>
* ofp-actions: Split ofpacts_check__() into many functions.Ben Pfaff2018-07-311-9/+10
| | | | | | | | | | | ofpacts_check__() was a huge switch statement with special cases for many different kinds of actions. This made it unwieldy and put the special cases far away from the rest of the code related to a given action. This commit refactors the code to avoid the problem. Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Yifeng Sun <pkusunyifeng@gmail.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* ovs-ofctl: New helper command "parse-packet".Ben Pfaff2018-07-121-0/+19
| | | | | | | | | This was useful for testing commit 4fe080160685 ("flow: Fix buffer overread for crafted IPv6 packets."). Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Yifeng Sun <pkusunyifeng@gmail.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* ovs-ofctl: Prefer "del-meters" and "dump-meters".Justin Pettit2018-07-061-8/+6
| | | | | | | | | | | | | | | | | | Previously to delete or dump the meter table, separate commands had to be used depending on whether one wanted to operate on a single or all meters. This change makes it so that the "meter" argument is always optional regardless of the command. This is a bit more consistent with other OVS commands and makes it easier when experimenting to not have to distinguish between the two cases. This also fixes an error in the ovs-ofctl man page that show the plural version of the command supported an optional "meter" argument. "del-meter" and "dump-meter" can still be used, but their use is no longer documented. Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Fix "ovs-ofctl snoop".Ashish Varma2018-04-251-0/+5
| | | | | | | | | | | | | | In case where "use_names" is set (e.g. in an interactive session) to show the port and table names when ovs-ofctl is run with snoop command, ovs-ofctl would get stuck in an endless loop inside "table_iterator_next" function's while loop checking for "while (ti->send_xid != recv_xid)". This would happening because the "vconn" to "<bridge>.snoop" socket would not respond to TABLE_FEATURES_REQUEST sent by ovs-ofctl. This commit disables showing port or table names in the snoop command. Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Add '--no-names' to usage message.Tonghao Zhang2018-04-041-0/+1
| | | | | | | | | | | | By default, ovs-ofctl can accept and display port names in place of numbers. ovs-ofctl tool exports only the option --names, but not --no-names in command help information. Fixes: 50f96b10e1c8 ("Support accepting and displaying port names in OVS tools.") Cc: Ben Pfaff <blp@ovn.org> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-flow: Reduce memory consumption for ofputil_flow_mod, using minimatch.Ben Pfaff2018-03-311-32/+49
| | | | | | | | | | | | | | | | | | | | | | | Until now, struct ofputil_flow_mod, which represents an OpenFlow flow table modification request, has incorporated a struct match, which made the overall ofputil_flow_mod about 2.5 kB. This is OK for a small number of flows, but absurdly inflates memory requirements when there are hundreds of thousands of flows. This commit fixes the problem by changing struct match to struct minimatch inside ofputil_flow_mod, which reduces its size to about 100 bytes plus the actual size of the flow match (usually a few dozen bytes). This affects memory usage of ovs-ofctl (when it adds a large number of flows) more than ovs-vswitchd. Reported-by: Michael Ben-Ami <mbenami@digitalocean.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Armando Migliaccio <armamig@gmail.com> Tested-by: Armando Migliaccio <armamig@gmail.com> Reviewed-by: Jan Scheurich <jan.scheurich@ericsson.com> Tested-by: Jan Scheurich <jan.scheurich@ericsson.com> Tested-by: Yifeng Sun <pkusunyifeng@gmail.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* ofp-print: Move much of the printing code into message-specific files.Ben Pfaff2018-03-141-5/+7
| | | | | | | | | | | Until now, the ofp-print code has had a lot of logic specific to individual messages. This code is better put with the other code specific to those messages, so this commit starts to migrate it. There is more work of a similar type to do, but this is a reasonable start. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ofp-packet: Better abstract packet-in format.Ben Pfaff2018-03-141-5/+5
| | | | | | | | | | This commit relieves the caller of code that deals with the format of packet-in messages from some of the burden of understanding the packet format. It also renames the constants to appear to be at a higher level of abstraction. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ofp-util: Use consistent naming convention.Ben Pfaff2018-02-281-2/+2
| | | | | | | | Most of the tree now uses "encode" as the verb for making an OpenFlow message, so adopt it here in this very old code as well. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* Don't shadow variables.Justin Pettit2018-02-281-12/+12
| | | | | | | Rename the remaining variables that were shadowing another definition. Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Make ofp-print able to read raw data from a file.Ben Pfaff2018-02-161-25/+35
| | | | | | | | Occasionally someone sends me raw OpenFlow data in a file and this saves time converting it to hex. Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* ofp-util, ofp-parse: Break up into many separate modules.Ben Pfaff2018-02-131-0/+9
| | | | | | | | | | | | ofp-util had been far too large and monolithic for a long time. This commit breaks it up into units that make some logical sense. It also moves the pieces of ofp-parse that were specific to each unit into the relevant unit. Most of this commit is just moving code around. Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* Support accepting and displaying table names in OVS tools.Ben Pfaff2018-02-011-52/+242
| | | | | | | | | | | | | | | | | | | | | | | | OpenFlow has little-known support for naming tables. Open vSwitch has supported table names for ages, but it has never used or displayed them outside of commands dedicated to table manipulation. This commit adds support for table names in ovs-ofctl. When a table has a name, it displays that name in flows and actions, so that, for example, the following: table=1, arp, actions=resubmit(,2) might become: table=ingress_acl, arp, actions=resubmit(,mac_learning) given appropriately named tables. For backward compatibility, only interactive ovs-ofctl commands by default display table names; to display them in scripts, use the new --names option. This feature was inspired by a talk that Kei Nohguchi presented at Open vSwitch 2017 Fall Conference. CC: Kei Nohguchi <kei@nohguchi.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* ofp-actions: Make formatting and parsing functions take a struct argument.Ben Pfaff2018-01-311-6/+13
| | | | | | | | | | An upcoming commit will add another parameter for parsing and formatting actions. It is much easier to add these parameters if they are encapsulated in a struct, so this commit first makes that change. Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com> Acked-by: Mark Michelson <mmichels@redhat.com>
* classifier: Refactor interface for classifier_remove().Ben Pfaff2018-01-311-1/+1
| | | | | | | | | | | | | | Until now, classifier_remove() returned either null or the classifier rule passed to it, which is an unusual interface. This commit changes it to return true if it succeeds or false on failure. In addition, most of classifier_remove()'s callers know ahead of time that it must succeed, even though most of them didn't bother with an assertion, so this commit adds a classifier_remove_assert() function as a helper. Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Yifeng Sun <pkusunyifeng@gmail.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* ovs-ofctl: Fix typo in comment.Ben Pfaff2018-01-271-2/+2
| | | | Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Add "compose-packet" command for testing flow_compose().Ben Pfaff2018-01-271-0/+72
| | | | | | | | | | I don't feel obligated to add a bunch of automatic tests for flow_compose(), but this is handy for manual testing or for simple packet generation. Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Yifeng Sun <pkusunyifeng@gmail.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
* lib: Move lib/poll-loop.h to include/openvswitchXiao Liang2017-11-031-1/+1
| | | | | | | | Poll-loop is the core to implement main loop. It should be available in libopenvswitch. Signed-off-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Avoid unnecessary flow replacement in "replace-flows" command.Ben Pfaff2017-08-031-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ovs-ofctl "diff-flows" and "replace-flows" command compare the flows in two flow tables. Until now, the "replace-flows" command has considered certain almost meaningless differences related to the version of OpenFlow used to add a flow as significant, which caused it to replace a flow by an identical-in-practice version, e.g. in the following, the "replace-flows" command prints a FLOW_MOD that adds the flow that was already added previously: $ cat > flows actions=resubmit(,1) $ ovs-vsctl add-br br0 $ ovs-ofctl del-flows br0 $ ovs-ofctl add-flows br0 flows $ ovs-ofctl -vvconn replace-flows br0 flows 2>&1 | grep FLOW_MOD Re-adding an existing flow has some effects, for example, it resets the flow's duration, so it's better to avoid it. This commit fixes the problem using the same trick previously used for a similar problem with the "diff-flows" command, which was fixed in commit 98f7f427bf8b ("ovs-ofctl: Avoid printing false differences on "ovs-ofctl diff-flows"."). Reported-by: Kevin Lin <kevin@quilt.io> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ofp-parse: Fix small memory leak when calling parse_ofp_meter_mod_str().Justin Pettit2017-07-051-0/+4
| | | | | | | | | | | | The function parse_ofp_meter_mod_str() allocates a buffer called 'bands', which parse_ofp_meter_mod_str__() then steals for the member 'mm->meter.bands'. Calling functions didn't free that stolen value and the comments for those function didn't indicate that was necessary. Found by valgrind. Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* userspace: Introduce packet_type in OF 1.5 packet-outZoltán Balogh2017-06-271-0/+1
| | | | | | | | | | | | | Introducing packet_type in OF 1.5 packet-out. Partly based on Jean Tourrilhes's work. Add test cases for OF1.5 packet-out Add negative test case for OF1.5 packet-out Signed-off-by: Jean Tourrilhes <jt@labs.hpe.com> Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com> Co-authored-by: Jan Scheurich <jan.scheurich@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".Ben Pfaff2017-06-141-3/+9
| | | | | | | | | | | It's pretty common to want to omit statistics from output, to make it easier to read. This commit adds an ovs-ofctl option to make that easy. A lot of the OVS internal tests could use this, too, in place of ofctl_strip. This commit adopts it for a subset. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Aaron Conole <aconole@redhat.com>
* ovs-ofctl: Avoid read overrun in ofperr_decode_msg().Ben Pfaff2017-06-141-4/+6
| | | | | | | | | | | | | | | | | | | vconn_add_bundle_error() was keeping at most 64 bytes of an OpenFlow error message, then it was passing it to ofperr_decode_msg(), which assumed that the full message was available. This led to a buffer overread. There's no good reason why it was only keeping the first 64 bytes, so this commit changes it to keep the whole error message, sidestepping the problem. struct vconn_bundle_error only existed for this special case, so remove it in favor of a chain of ofpbufs. Found via gcc's address sanitizer. Reported-by: Lance Richardson <lrichard@redhat.com> Fixes: 506c1ddb3404 ("vconn: Better bundle error management.") Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jarno Rajahlame <jarno@ovn.org>
* ovs-ofctl: Close pcap file at end of ofctl_ofp_parse_pcap().Ben Pfaff2017-06-011-0/+1
| | | | | | | | | | Seem wise even if not mandatory. Found by Coverity. Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763047&defectInstanceId=4305314&mergedDefectId=180420 Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* Support accepting and displaying port names in OVS tools.Ben Pfaff2017-05-311-62/+182
| | | | | | | | | | | | | | Until now, most ovs-ofctl commands have not accepted names for ports, only numbers, and have not been able to display port names either. It's a lot easier for users if they can use and see meaningful names instead of arbitrary numbers. This commit adds that support. For backward compatibility, only interactive ovs-ofctl commands by default display port names; to display them in scripts, use the new --names option. Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Aaron Conole <aconole@redhat.com>
* ofproto: Add pipeline fields support for OF 1.5 packet-outYi-Hung Wei2017-05-311-8/+9
| | | | | | | | | | | | | | | | | | | | | | | This patch decodes pipeline fields from a packet-out message, and populates the pipeline fields into datapath. Error OFPERR_OFPBRC_PIPELINE_FIELDS_ONLY is returned if the match field of a packet-out messages contains any non pipeline fields. Currently, the supported pipeline fields are as following. * metadata fields: - in_port, in_port_oxm * tunnel fields: - tun_id, tun_src, tun_dst, tun_ipv6_src, tun_ipv6_dst - tun_gbp_id, tun_gpb_flags, tun_flags - tun_metadata0 - tun_metadata63 * register fields: - metadata - reg0 - reg-15, xreg0 - xreg7, xxreg0 - xxreg3 Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-util: Add flow metadata to ofputil_packet_outYi-Hung Wei2017-05-311-1/+3
| | | | | | | | | This patch adds flow metadata to ofputil_packet_out. It does not make any functional change. The flow metadata will be useful to support new packet-out message format in OpenFlow 1.5. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Add support for OpenFlow 1.6 (draft) port status and port mod messages.Ben Pfaff2017-04-071-0/+1
| | | | | | | | | OpenFlow 1.6 adds support for EUI-64 addresses for ports, and extends the maximum length of OpenFlow port names from 16 to 64 bytes. ONF-JIRA: EXT-566 Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* Fix format specifier technicalities.Ben Pfaff2017-03-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Various printf() format specifiers in the tree had minor technical issues which the Mac OS build reported, e.g. here: https://s3.amazonaws.com/archive.travis-ci.org/jobs/208718342/log.txt These tend to fall into two categories of harmless warnings: 1. Wrong width for types that are all promoted to 'int'. For example, both uint8_t and uint16_t are both promoted to 'int' as part of a call to printf(), but using PRIu8 for a uint16_t causes a warning. 2. Wrong format specifier for type promoted to 'int' due to arithmetic. For example, if 'x' is a uint8_t, then x >> 1 has type 'int' due to C's promotion rules, so the correct format specifier is %d and using PRIu8 will cause a warning. This commit fixes the warnings. I didn't see anything that rose to the level of a bug. These warnings only showed up on Mac OS X because of differences in the format specifiers that Mac OS uses for PRI*. Reported-by: Shu Shen <shu.shen@gmail.com> Acked-by: Daniele Di Proietto <diproiettod@vmware.com> Signed-off-by: Ben Pfaff <blp@ovn.org>