summaryrefslogtreecommitdiff
path: root/lib/vconn.c
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate most shadowing for local variable names.Ben Pfaff2017-08-021-1/+0
| | | | | | | | | | | | | | Shadowing is when a variable with a given name in an inner scope hides a different variable with the same name in a surrounding scope. This is generally undesirable because it can confuse programmers. This commit eliminates most of it. Found with -Wshadow=local in GCC 7. The repo is not really ready to enable this option by default because of a few cases that are harder to fix, and harmless, such as nested use of CMAP_FOR_EACH. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovs-ofctl: Avoid read overrun in ofperr_decode_msg().Ben Pfaff2017-06-141-17/+8
| | | | | | | | | | | | | | | | | | | 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>
* Support accepting and displaying port names in OVS tools.Ben Pfaff2017-05-311-5/+5
| | | | | | | | | | | | | | 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>
* ovn-trace: New --ovs option to also print OpenFlow flows.Ben Pfaff2016-12-281-1/+119
| | | | | | | | | | | Sometimes seeing the OpenFlow flows that back a given logical flow can provide additional insight. This commit adds a new --ovs option to ovn-trace that makes it connect to Open vSwitch over OpenFlow and retrieve and print the OpenFlow flows behind each logical flow encountered during a trace. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* vconn: Better bundle error management.Jarno Rajahalme2016-07-291-43/+87
| | | | | | | | | | | | | | | | It is possible that a bundle add message fails, but the following commit succeeds, since the message was not added to the bundle. Make ovs-ofctl fail also in these cases. Also, the commit should not be sent if any of the bundled messages failed. To make sure all the errors are received before the commit is sent, a barrier is required before sending the commit message. Finally, make vconn collect bundle errors into a list instead of calling a callback. This makes bundle error management simpler. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* vconn: Update length of bundled messages.Jarno Rajahalme2016-07-291-1/+2
| | | | | | | | | | | | | Variable length messages need their length updated before they can be added to the bundle. Message length updating after encoding is sometimes done by the encoding function, but always latest when the message is sent out. As an OpenFlow message is added to a bundle add message, it will not be sent by itself, and we need to update the length explicitly instead. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofp-print.h to include/openvswitch directoryBen Warren2016-04-141-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofp-msgs.h to include/openvswitch directoryBen Warren2016-04-141-6/+6
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofp-util.h to include/openvswitch directoryBen Warren2016-04-141-1/+1
| | | | | | | | This commit also adds several #include directives in source files in order to make the 'ofp-util.h' move possible Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofpbuf.h to include/openvswitch directoryBen Warren2016-03-301-1/+1
| | | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofp-errors.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Add bundle support and unit testing.Jarno Rajahalme2015-06-101-22/+219
| | | | | | | | | | | | | | | | | | | | | | | All existing ovs-ofctl flow mod commands now take an optional '--bundle' argument, which executes the flow mods as a single transaction. OpenFlow 1.4+ is implicitly assumed when '--bundle' is specified. ovs-ofctl 'add-flow' and 'add-flows' commands now accept flow specifications that start with an optional 'add', 'modify', 'delete', 'modify_strict', or 'delete_strict' keyword, so that arbitrary flow table modifications may be specified. For backwards compatibility, a missing keyword is treated as an 'add'. With the new '--bundle' option all the modifications are executed as a single transaction using an OpenFlow 1.4 bundle. OpenFlow 1.4 requires bundles to support at least flow and port mods. This implementation does not yet support port mods in bundles. Another restriction is that the atomic transactions are not yet supported. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib/list: Add LIST_FOR_EACH_POP.Jarno Rajahalme2015-04-061-4/+2
| | | | | | | | Makes popping each member of the list a bit easier. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Russell Bryant <rbryant@redhat.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Use the IANA-assigned ports for OpenFlow and OVSDB.Justin Pettit2015-03-121-4/+4
| | | | | | | | We've been warning about the change since 2.1, which was released a year ago. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofpbuf: Simplify ofpbuf API.Pravin B Shelar2015-03-031-14/+14
| | | | | | | | | | | | ofpbuf was complicated due to its wide usage across all layers of OVS, Now we have introduced independent dp_packet which can be used for datapath packet, we can simplify ofpbuf. Following patch removes DPDK mbuf and access API of ofpbuf members. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* vconn: Avoid using C++ keyword 'class' as variable name in headersAmit Bose2015-01-131-17/+17
| | | | | Signed-off-by: Amit Bose <bose@noironetworks.com> Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* list: Rename struct list to struct ovs_listThomas Graf2014-12-151-1/+1
| | | | | | | struct list is a common name and can't be used in public headers. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofpbuf: Introduce access api for base, data and size.Pravin Shelar2014-03-301-14/+14
| | | | | | | These functions will be used by later patches. Following patch does not change functionality. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* vconn: Fix vconn_get_status() return value when connection in progress.Ben Pfaff2014-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | When a connection takes a few rounds of the state machine to complete, 'error' gets filled with EAGAIN until that completes. This didn't match the vconn_get_status() documentation, which says that it only returns a positive errno value if there was an error. One could fix the problem by updating the documentation (and the callers) or by updating the implementation. I decided that the latter was the way to go because the distinction between the TCP connection being in progress or complete isn't visible to the client; what is visible to the client is the OpenFlow negotiation being complete. This problem is difficult to find in the unit tests because TCP connections to localhost complete immediately. Bug introduced by commit accaecc419cc57d (rconn: Discover errors in rconn_run() even if rconn_recv() is never called.) Reported-by: Anuprem Chalvadi <achalvadi@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* rconn: Discover errors in rconn_run() even if rconn_recv() is never called.Ben Pfaff2014-02-271-1/+10
| | | | | | | | | | | | | | | | rconn_recv() calls vconn_recv(), which will report a connection error and cause rconn_recv() to disconnect the rconn. Most rconn users regularly call rconn_recv(), so that disconnection happens promptly. However, the lswitch code only calls rconn_recv() after the connection negotiates an OpenFlow version, so a connection that failed before negotiation would never be detected as failed. This commit fixes the problem by making rconn_run() also detect and handle connection errors. The lswitch code is only used by the test-controller program, so this is not an important bug fix. Reported-by: Vasu Dasari <vdasari@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Remove stream, vconn, and rconn functions to get local/remote IPs/ports.Ben Pfaff2013-12-171-57/+0
| | | | | | | | These functions don't have any ultimate users. The in-band control code used to use them, but not anymore, so we might as well delete them all. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* Rename NOT_REACHED to OVS_NOT_REACHEDHarold Lim2013-12-171-1/+1
| | | | | | | | This allows other libraries to use util.h that has already defined NOT_REACHED. Signed-off-by: Harold Lim <haroldl@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* vconn: Reply with OFPBRC_BAD_VERSION for bad version.Ben Pfaff2013-12-131-1/+15
| | | | | | | Testers keep wanting to know why this doesn't work. I think it's a silly test, but it's easy enough to make them happy. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto: Define official OpenFlow port number.Justin Pettit2013-10-011-4/+4
| | | | | Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Don't differentiate between TCP and SSL ports for OpenFlow and OVSDB.Justin Pettit2013-10-011-2/+2
| | | | | | | | | | | | The OVS code has always made a distinction between the unencrypted (TCP) and SSL port numbers for the OpenFlow and OVSDB protocols. The default port numbers for both protocols has changed, and there continues to be no distinction between the unencrypted and SSL versions. This commit removes the distinction in port numbers. A future patch will recognize the change in default port number. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* vconn: Fix formatting of user message.Ben Pfaff2013-06-281-1/+1
| | | | | | This corrects "version 0x03and earlier" to "version 0x03 and earlier". Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace all uses of strerror() by ovs_strerror(), for thread safety.Ben Pfaff2013-06-281-1/+1
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* Fix misspellings in comments and docs.Andy Hill2013-06-041-1/+1
| | | | | | | | Flagged with: https://github.com/lyda/misspell-check Run with: git ls-files | misspellings -f - Signed-off-by: Andy Hill <hillad@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* vconn: Mark class structures as const.Ben Pfaff2013-05-031-15/+15
| | | | | | | These data structures are never modified so it seems logical for them to be const. Signed-off-by: Ben Pfaff <blp@nicira.com>
* vconn: Initialize 'recv_any_version' member of struct vconn in vconn_init().Ben Pfaff2013-01-251-5/+1
| | | | | | | | | | | This uninitialized data caused failures in the test "ofproto - eviction upon table overflow (OpenFlow 1.2)" for some developers and in some circumstances. Found by valgrind. Reported-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* rconn: Fix null pointer dereference in rconn_add_monitor().Ben Pfaff2013-01-241-1/+22
| | | | | | | | | | | | | | | | | | | | | | rconn_add_monitor() tries to check the version of the controller connection being monitored, so that it can decide what OpenFlow version to tell the monitor connection to negotiate. But at any given time an rconn may not have a controller connection (e.g. during backoff), so rc->vconn may be null and thus vconn_get_version(rc->vconn) dereferences a null pointer. Fixing the problem in a local way would require the rconn to remember the previous version negotiated, and that fails if the rconn hasn't yet connected or if the next connection negotiates a new version. This commit instead adds the ability to a vconn to accept any OpenFlow message version and modifies "ovs-ofctl snoop" to use that feature, thus removing the need to negotiate the "correct" version on snoops. Bug #14265. Reported-by: Pratap Reddy <preddy@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-20/+19
| | | | | | | | This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* vconn: Fix parameters for vconn_open(), vconn_open_block(), pvconn_open().Ben Pfaff2013-01-041-7/+7
| | | | | | | | | | | The customary parameter order in Open vSwitch is to put input parameters before output parameters, but vconn_open() and pvconn_open() had the 'dscp' input parameter at the end, which bugged me a bit. Also, vconn_open_block() didn't take a 'dscp' parameter at all even though it's otherwise a wrapper around vconn_open(). This commit fixes all that up. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* vonn: Allow snoops to use the OpenFlow version of the controller connectionSimon Horman2012-11-121-0/+8
| | | | | | | | | | | | | | | Override the allowed versions of the snoop vconn so that only the version of the controller connection is allowed. This is because the snoop will see the same messages as the controller. Without this change the snoop will try to negotiate a connection using the default allowed versions, or in other words only allow OpenFlow 1.0. This breaks snoops for controller connections using other OpenFlow versions, that is OpenFlow 1.2. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-util: Add version bitmap support to hello messages.Simon Horman2012-11-041-5/+4
| | | | | | | | | Allow encoding and decoding of version bitmap in hello messages as specified in Open Flow 1.3.1. Signed-off-by: Simon Horman <horms@verge.net.au> [blp@nicira.com simplified and generalized decode/encode functions] Signed-off-by: Ben Pfaff <blp@nicira.com>
* vconn: Replace minimum version with bitmap of allowed versions.Simon Horman2012-11-041-32/+91
| | | | | | | | | | | | | | This is in preparation for allowing the range of allowed OpenFlow versions to be configured. As part of this change pvconn_open() is now paramatised over the allowed versions. this is to avoid avoids needing to provide version information as a parameter to pvconn_accept(). This will in turn avoid the need to pass version information to connmgr_run(). Signed-off-by: Simon Horman <horms@verge.net.au> [blp@nicira.com simplified slightly and generalize log messages] Signed-off-by: Ben Pfaff <blp@nicira.com>
* vconn: Properly line up description for "tcp:" and "ssl:" usage.Justin Pettit2012-08-071-2/+2
| | | | Signed-off-by: Justin Pettit <jpettit@nicira.com>
* vconn: Fix vconn_get_version().Ben Pfaff2012-08-071-2/+2
| | | | | | | It's documented to return -1 if the version isn't yet known, but in fact it returned 0. Signed-off-by: Ben Pfaff <blp@nicira.com>
* vconn: Ensure that vconn_run() is enough to complete a connection.Ben Pfaff2012-08-071-0/+12
| | | | | | | | | | | | | | | | | | Until now, it seems that all vconn users have immediately started reading messages from the connection. Today, however, I added a new user that only wants to read packets after the OpenFlow version is negotiated, so it never called vconn_recv() before that happened. It turns out that if you do this, the version never gets negotiated at all. This commit fixes the problem by ensuring that vconn_run() will continue version negotiation if it isn't done yet. This changes the error return that I get for Unix sockets in the test-vconn "accept-then-close" test from EPIPE to ECONNRESET, so this commit also adjusts that test to accept either error code; both of them seem reasonable enough to me. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-util: Make ofperr_encode_msg__() use correct Open Flow versionSimon Horman2012-08-061-3/+2
| | | | | | | | Make ofperr_encode_msg__() use correct Open Flow version in the header of messages. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-util: Allow encoding of Open Flow 1.1 & 1.2 Barrier Request MessagesSimon Horman2012-08-061-1/+1
| | | | | Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* test-vconn: Block in three cases where a race is visible on FreeBSD.Ben Pfaff2012-07-311-7/+19
| | | | | | | | On FreeBSD, sometimes plain vconn_connect() or vconn_recv() reports EAGAIN in these cases. Reported-by: Ed Maste <emaste@freebsd.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
* openflow: Add enum ofp_versionSimon Horman2012-07-301-2/+3
| | | | | | | | | Use an enum for ofp_version in ofp-util and ofp-msg. This in conjunction with the use of switch() statements allows the compiler to warn when a new ofp_version isn't handled. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-msgs: New approach to encoding and decoding OpenFlow headers.Ben Pfaff2012-07-301-34/+34
| | | | | | | | | | | | | | | | OpenFlow headers are not as uniform as they could be, with size, alignment, and numbering changes from one version to another and across varieties (e.g. ordinary messages vs. "stats" messages). Until now the Open vSwitch internal APIs haven't done a good job of abstracting those differences in header formats. This commit changes that; from this commit forward very little code actually needs to understand the header format or numbering. Instead, it can just encode or decode, or pull or put, the header using a more abstract API using the ofpraw_, ofptype_, and other APIs in the new ofp-msgs module. Signed-off-by: Ben Pfaff <blp@nicira.com> Tested-by: Simon Horman <horms@verge.net.au> Reviewed-by: Simon Horman <horms@verge.net.au>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Allow configuring DSCP on controller and manager connections.Mehak Mahajan2012-03-231-5/+7
| | | | | | | | | | | The changes allow the user to specify a separate dscp value for the controller connection and the manager connection. The value will take effect on resetting the connections. If no value is specified a default value of 192 is chosen for each of the connections. Feature #10074 Requested-by: Rajiv Ramanathan <rramanathan@nicira.com> Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
* Begin breaking openflow-1.0.h into common and version-specific definitions.Ben Pfaff2012-03-071-6/+6
| | | | | | | | | | | | | | | | | | | | | | The intention is that, as each OpenFlow 1.1 and 1.2 feature is added to Open vSwitch, the corresponding protocol definitions will be broken up this way: - Definitions that are the same in OF1.0 and OF1.1 will retain the "OFP" or "ofp" prefix and move to openflow-common.h. - Definitions that are specific to OF1.0 will be renamed with an "OFP10" or "ofp10" prefix and stay in openflow-1.0.h. - Definitions that are specific to OF1.1 or to OF1.1 and OF1.2 will be renamed with an "OFP11" or "ofp11" prefix and move to openflow-1.1.h. - Definitions that are specific to OF1.2 will be renamed with an "OFP12" or "ofp12" prefix and move to openflow-1.2.h. This commit starts this process with some basic OpenFlow definitions. Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Introduce ofputil_protocol, to abstract the protocol in use on a connection.Ben Pfaff2012-03-071-5/+16
| | | | | | | | | | | | | | | | | | | | | | Open vSwitch already handles a few different protocol variations, but it does so in a nonuniform manner: - OpenFlow 1.0 and NXM flow formats are distinguished using the NXFF_* constant values from nicira-ext.h. - The "flow_mod_table_id" feature setting is maintained in ofproto as part of an OpenFlow connection's (ofconn's) state. There's no way to easily communicate this state among components. It's not much of a problem yet, but as more protocol support is added it seems better to have an abstract, uniform way to represent protocol versions and variants. This commit implements that by introducing a new type "enum ofputil_protocol". Each ofputil_protocol value represents a variant of a protocol version. Each value is a separate bit, so a single enum can also represent a set of protocols, which is often useful as well. Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>