2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-29 13:27:59 +00:00

408 Commits

Author SHA1 Message Date
Ales Musil
08146bf7d9 openflow: Add extension to flush CT by generic match.
Add extension that allows to flush connections from CT
by specifying fields that the connections should be
matched against. This allows to match only some fields
of the connection e.g. source address for orig direction.

Reported-at: https://bugzilla.redhat.com/2120546
Signed-off-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2023-01-16 19:58:08 +01:00
Vasu Dasari
c3e64047d1 ofp-monitor: Support flow monitoring for OpenFlow 1.3, 1.4+.
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>
2022-04-28 21:27:11 +02:00
Vasu Dasari
d8ab75cd69 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 <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>
2022-04-28 21:26:40 +02:00
Adrian Moreno
e9bf5bffb0 list: use short version of safe loops if possible.
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>
2022-03-30 16:59:02 +02:00
Wang Yibo
f173527ec8 ovs-ofctl: Fix coredump when using "add-groups" command.
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>
2021-05-14 16:08:43 +02:00
Flavio Fernandes
31629b5383 ovs-ofctl: Fix segfault due to bad meter n_bands.
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>
2021-04-01 01:42:28 +02:00
Ashish Varma
3e613cd81c ofp-monitor: Fixed the usage of 'usable_protocols' variable in '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>
2019-11-01 14:35:00 -07:00
Damijan Skvarc
e35626355d ovs-ofctl: fix memory leak in open_vconn__() function
Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-09-24 10:18:40 -07:00
Yifeng Sun
3b6a5b737a ovs-ofctl: Free leaked minimatch
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>
2019-09-19 09:23:45 -07:00
Ben Pfaff
4304fd986e ovs-ofctl: New testing command "parse-group".
This will be used in an upcoming test.

Acked-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-06-09 16:19:30 -07:00
Li RongQing
8bdf4e674c ofctl: break the loop if ovs_pcap_read returns error
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>
2019-02-22 13:03:42 -08:00
Ben Pfaff
29718ad49d Remove support for OpenFlow 1.6 (draft).
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>
2019-02-05 09:21:19 -08:00
Ben Pfaff
4e413ac88d ovs-vswitchd: Implement OFPT_TABLE_FEATURES table modification request.
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>
2019-01-15 16:59:37 -08:00
Ilya Maximets
04895042e9 vconn: Allow timeout configuration for blocking connection.
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>
2019-01-10 15:42:54 -08:00
Ben Pfaff
b47e7e2bac ofp-table: Always format the table number in table features.
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>
2018-10-26 15:19:44 -07:00
Ben Pfaff
9d36d7d728 ofp-table: Better summarize table features and statistics.
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>
2018-10-26 15:19:37 -07:00
Mark Michelson
b6e840aed0 pcap-file: Add nanosecond resolution pcap support.
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>
2018-10-05 17:35:07 -07:00
Ben Pfaff
f836888d28 ofproto: Handle OpenFlow version mismatch for requestforward with groups.
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>
2018-09-26 13:49:43 -07:00
Ilya Maximets
9551e80bef tests: Use environment variable for default timeout.
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>
2018-08-15 11:36:18 -07:00
Ilya Maximets
cbcf40a847 utilities: Fix and unify parsing of timeout option.
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>
2018-08-15 11:36:18 -07:00
Alin Gabriel Serdean
111b58cc79 ofctl: Fixup compare_flows function
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>
2018-08-08 21:01:37 +03:00
Ben Pfaff
4111c9304d ovs-ofctl: Better validate OpenFlow message length in "ofp-parse-pcap".
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>
2018-08-06 15:17:05 -07:00
Ben Pfaff
ae6f7530bf ofp-actions: Split ofpacts_check__() into many functions.
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>
2018-07-31 13:11:13 -07:00
Ben Pfaff
19041a098e ovs-ofctl: New helper command "parse-packet".
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>
2018-07-12 16:31:00 -07:00
Justin Pettit
04f803fddc ovs-ofctl: Prefer "del-meters" and "dump-meters".
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>
2018-07-06 14:23:30 -07:00
Ashish Varma
ac4285f4d4 ovs-ofctl: Fix "ovs-ofctl snoop".
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>
2018-04-25 12:46:24 -07:00
Tonghao Zhang
ca3123807e ovs-ofctl: Add '--no-names' to usage message.
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>
2018-04-04 14:17:55 -07:00
Ben Pfaff
6a6b706065 ofp-flow: Reduce memory consumption for ofputil_flow_mod, using minimatch.
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>
2018-03-31 11:33:28 -07:00
Ben Pfaff
dfc77282c5 ofp-print: Move much of the printing code into message-specific files.
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>
2018-03-14 11:41:22 -07:00
Ben Pfaff
d8790c0843 ofp-packet: Better abstract packet-in format.
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>
2018-03-14 11:34:41 -07:00
Ben Pfaff
d9cea8f5f3 ofp-util: Use consistent naming convention.
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>
2018-02-28 16:48:54 -08:00
Justin Pettit
396d492cfa Don't shadow variables.
Rename the remaining variables that were shadowing another definition.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
2018-02-28 15:02:44 -08:00
Ben Pfaff
7080b4a268 ovs-ofctl: Make ofp-print able to read raw data from a file.
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>
2018-02-16 14:59:33 -08:00
Ben Pfaff
0d71302e36 ofp-util, ofp-parse: Break up into many separate modules.
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>
2018-02-13 10:43:13 -08:00
Ben Pfaff
4bc938ccb3 Support accepting and displaying table names in OVS tools.
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>
2018-02-01 10:08:32 -08:00
Ben Pfaff
efefbcae01 ofp-actions: Make formatting and parsing functions take a struct argument.
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>
2018-01-31 11:37:53 -08:00
Ben Pfaff
46ab60bfe5 classifier: Refactor interface for classifier_remove().
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>
2018-01-31 11:19:21 -08:00
Ben Pfaff
31bd820c1d ovs-ofctl: Fix typo in comment.
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-01-27 09:18:41 -08:00
Ben Pfaff
d060b8ab77 ovs-ofctl: Add "compose-packet" command for testing flow_compose().
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>
2018-01-27 08:58:50 -08:00
Xiao Liang
fd016ae3fb lib: Move lib/poll-loop.h to include/openvswitch
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>
2017-11-03 10:47:55 -07:00
Ben Pfaff
6cc9d77c78 ovs-ofctl: Avoid unnecessary flow replacement in "replace-flows" command.
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>
2017-08-03 13:52:37 -07:00
Justin Pettit
2f0b69ac79 ofp-parse: Fix small memory leak when calling parse_ofp_meter_mod_str().
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>
2017-07-05 23:39:29 -07:00
Zoltán Balogh
cb1145d1b9 userspace: Introduce packet_type in OF 1.5 packet-out
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>
2017-06-27 17:28:30 -04:00
Ben Pfaff
1b3758c36e ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".
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>
2017-06-14 12:50:23 -07:00
Ben Pfaff
209aa4ad13 ovs-ofctl: Avoid read overrun in ofperr_decode_msg().
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>
2017-06-14 08:21:03 -07:00
Ben Pfaff
63ae068ebf ovs-ofctl: Close pcap file at end of ofctl_ofp_parse_pcap().
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>
2017-06-01 16:20:45 -07:00
Ben Pfaff
50f96b10e1 Support accepting and displaying port names in OVS tools.
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>
2017-05-31 16:06:12 -07:00
Yi-Hung Wei
d7892c814a ofproto: Add pipeline fields support for OF 1.5 packet-out
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>
2017-05-31 14:54:10 -07:00
Yi-Hung Wei
35eb6326d5 ofp-util: Add flow metadata to ofputil_packet_out
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>
2017-05-31 14:54:09 -07:00
Ben Pfaff
2f2b904f9e Add support for OpenFlow 1.6 (draft) port status and port mod messages.
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>
2017-04-07 15:50:50 -07:00