summaryrefslogtreecommitdiff
path: root/utilities/ovs-ofctl.c
Commit message (Collapse)AuthorAgeFilesLines
* ofp-util: Implement OFPMP_TABLE_FEATURES decoding and printing.Alexander Wu2014-03-231-0/+17
| | | | | | Signed-off-by: Alexander Wu <alexander.wu@huawei.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto: Allow the use of the OpenFlow 1.4 protocolAlexandru Copot2014-03-231-0/+1
| | | | | | | | | | This defines the version number for OpenFlow 1.4 so that the switch can actually use it. The ovsdb schema is also modified. Signed-off-by: Alexandru Copot <alex.mihai.c@gmail.com> Cc: Daniel Baluta <dbaluta@ixiacom.com> [blp@nicira.com adjusted code in cases where 1.3 and 1.4 are the same] Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: Use fcntl instead of sys/fcntl.Gurucharan Shetty2014-03-171-1/+1
| | | | | | | Windows does not have a sys/fcntl.h Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: simplify flow_extract() APIAndy Zhou2014-02-281-2/+4
| | | | | | | | | | Change the flow_extract() API to accept struct pkt_metadata, instead of individual metadata fields. It will make the API more logical and easier to maintain when we need to expand metadata down the road. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>¬
* fatal-signal: SIGPIPE for Windows.Gurucharan Shetty2014-02-261-1/+2
| | | | | | | | | Windows does not have a SIGPIPE. We ignore SIGPIPE for Linux. To compile on Windows, carve out a new function to ignore SIGPIPE on Linux. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib/pcap-file: add 'ovs_' prefix to pcap functionsLuigi Rizzo2014-01-231-4/+4
| | | | | | | | | This is done to avoid collisions and confusions with libpcap symbols, like pcap_read() Signed-off-by: Luigi Rizzo <rizzo@iet.unipi.it> Signed-off-by: Daniele Di Proietto <daniele.di.proietto@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* classifier: Use fat_rwlock instead of ovs_rwlock.Ben Pfaff2014-01-141-8/+8
| | | | | | | | | | Jarno Rajahalme reported up to 40% performance gain on netperf TCP_CRR with an earlier version of this patch in combination with a kernel NUMA patch, together with a reduction in variance: http://openvswitch.org/pipermail/dev/2014-January/035867.html Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ovs-ofctl: New command "ofp-parse-pcap" to dump OpenFlow from PCAP files.Ben Pfaff2013-12-231-2/+91
| | | | | | | Based on the number of people who ask about Wireshark support for OpenFlow, this is likely to be widely useful. Signed-off-by: Ben Pfaff <blp@nicira.com>
* pcap-file: Add timestamp support for reading and writing pcap files.Ben Pfaff2013-12-231-1/+1
| | | | | | | Only the write support is initially useful, but an upcoming commit will add a user for the read support. Signed-off-by: Ben Pfaff <blp@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>
* ovs-ofctl: Replace TODO with XXX.Ethan Jackson2013-12-131-1/+1
| | | | | | | In accordance with the style guidelines. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Avoid printf type modifiers not supported by MSVC C runtime library.Alin Serdean2013-11-251-10/+10
| | | | | | | | | | | | | The MSVC C library printf() implementation does not support the 'z', 't', 'j', or 'hh' format specifiers. This commit changes the Open vSwitch code to avoid those format specifiers, switching to standard macros from <inttypes.h> where available and inventing new macros resembling them where necessary. It also updates CodingStyle to specify the macros' use and adds a Makefile rule to report violations. Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-actions: Make ofpacts_check() report consistency for all protocols.Ben Pfaff2013-11-201-19/+11
| | | | | | | | | | | | Until now ofpacts_check() has been told either to enforce consistency or not, but that means that the caller has to know exactly what protocol is going to be in use (because some protocols require consistency to be enforced and others don't). This commit changes ofpacts_check() to just rule out protocols that require enforcement when it detects inconsistencies. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* Classifier: Staged subtable matching.Jarno Rajahalme2013-11-191-2/+2
| | | | | | | | | | | Subtable lookup is performed in ranges defined for struct flow, starting from metadata (registers, in_port, etc.), then L2 header, L3, and finally L4 ports. Whenever it is found that there are no matches in the current subtable, the rest of the subtable can be skipped. The rationale of this logic is that as many fields as possible can remain wildcarded. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofproto: Centralize action checking, doing it at decode time.Ben Pfaff2013-11-011-2/+3
| | | | | | | | | | Jarno pointed out that modify_flows__() didn't really need to check every instance of the flow separately. After some further investigation I decided that this was even more of an improvement. CC: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofp-actions: Simplify interface and internal structure.Jarno Rajahalme2013-11-011-9/+12
| | | | | | | This makes later changes simpler. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Implement OFPT_QUEUE_GET_CONFIG_REQUEST and OFPT_QUEUE_GET_CONFIG_REPLY.Venkitachalam Gopalakrishnan2013-10-291-0/+22
| | | | | | | | | | | Open vSwitch has never implemented this request and reply, even though they have been in OpenFlow since version 1.0. This commit adds an implementation. Signed-off: Venkitachalam Gopalakrishnan <gops@vmware.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Joe Stringer <joestringer@nicira.com>
* lib/ofp-actions: Enforce action consistency.Jarno Rajahalme2013-10-231-9/+18
| | | | | | | | | OpenFlow 1.1+ specs encourage switches to verify action consistency at flow setup time. Implement this for OpenFlow 1.1+ only to not break any current OF 1.0 based use. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-actions: Distinguish OF1.1/1.2 push_mpls from OF1.3+.Joe Stringer2013-10-211-4/+4
| | | | | | | | | | | | | | In OpenFlow 1.1 and 1.2, the push_mpls action pushes the MPLS label after any existing VLAN tag. In OpenFlow 1.3, it pushes the label before any existing VLAN tag. Until now, the action parser didn't distinguish these cases. This commit adds support. Nothing yet actually changes the behavior of push_mpls. enum ofpact_mpls_position contributed by Ben Pfaff. Signed-off-by: Joe Stringer <joe@wand.net.nz> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-actions: Make ofpacts_format() caller add "actions=" if it wants it.Ben Pfaff2013-10-141-1/+4
| | | | | | An upcoming caller doesn't want it. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: Add undocumented "parse-pcap" command, for testing.Ben Pfaff2013-10-091-0/+32
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: Add meter support.Jarno Rajahalme2013-09-161-2/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | Adds commands add-meter, mod-meter, del-meter, del-meters, dump-meter, dump-meters, meter-stats, and meter-features. Syntax is as follows: add-meter <br> meter=<n> (kbps|pktps) [burst] [stats] bands= type=(drop|dscp_remark) rate=<n> [burst_size=<n>] [prec_level=<n>] <more bands> mod-meter <br> meter=<n> (kbps|pktps) [burst] [stats] bands= type=(drop|dscp_remark) rate=<n> [burst_size=<n>] [prec_level=<n>] <more bands> del-meter <br> meter=(<n>|all) del-meters <br> dump-meter <br> meter=(<n>|all) dump-meters <br> meter-stats <br> [meter=(<n>|all)] meter-features <br> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* vlog: Report timestamps in millisecond resolution in log messages.Paul Ingram2013-09-131-1/+2
| | | | | | | To make debugging easier. Signed-off-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Paul Ingram <pingram@nicira.com>
* openflow-1.1+: OFPT_TABLE_MOD (part 1)Andy Zhou2013-09-071-0/+38
| | | | | | | | | | | | | Added infrastructure to support Openflow OFPT_TABLE_MOD message. This patch does not include the flexible table miss handling code that is necessary to support the semantics specified in OFPT_TABLE_MOD messages. Current flow miss behavior continues to conform to Openflow 1.0. Future commits to add more flexible table miss support are needed to fully support OPFT_TABLE_MOD for Openflow-1.1+. Signed-off-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Implement OpenFlow 1.1+ "groups" protocol.Neil Zhu2013-09-021-0/+162
| | | | | | | | | | | | | This doesn't include a dpif implementation of groups functionality. In its current form, it is untested. Signed-off-by: Neil Zhu <zhuj@centecnetworks.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Co-authored-by: Simon Horman <horms@verge.net.au> Signed-off-by: Simon Horman <horms@verge.net.au> Co-authored-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
* lib: Keep track of usable protocols while parsing.Jarno Rajahalme2013-08-271-28/+35
| | | | | | | | | | Keep track of usable protocols while parsing actions and matches, rather than checking for them afterwards. This fixes silently discarded meter and goto table instructions when not explicitly specifying the protocol to use. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-util: Abstract flow_mod OFPFF_* flags.Ben Pfaff2013-08-271-1/+2
| | | | | | | | | | | | | | | | | | The OFPFF_* flags used in flow_mods are just confusing enough that it seems worthwhile to try to abstract them out. In particular: * OFPFF_EMERG was introduced in OF1.0, deleted in OF1.1, and then its bit was reused for a different purpose in OF1.2. * OFPFF_RESET_COUNTS was introduced in OF1.2 but the semantics that it specifies are implied by "add" commands in earlier versions, so proper translation requires the OpenFlow version number and flow_mod command. This commit does the abstraction. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* classifier: Make use of the classifier thread safe.Ethan Jackson2013-08-091-0/+8
| | | | | Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: Add "ofp-parse" command for printing OpenFlow from a file.Ben Pfaff2013-08-061-1/+54
| | | | | | Test provided by Alex Wang <alexw@nicira.com>. Signed-off-by: Ben Pfaff <blp@nicira.com>
* clang: Fix the alignment warning.Alex Wang2013-07-231-2/+2
| | | | | | | | This commit fixes the warning issued by 'clang' when pointer is casted to one with greater alignment. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Avoid designated initializers and static decls of arrays of unknown size.Linda Sun2013-07-191-2/+7
| | | | | | | MSVC can't handle either one. Signed-off-by: Linda Sun <lsun@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-util: Add 'modify_cookie' to struct ofputil_flow_mod, to support OF1.1.Ben Pfaff2013-07-081-0/+1
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-parse: Do not exit() upon a parse error.Ben Pfaff2013-07-081-15/+56
| | | | | | | | | Until now, failure to parse a flow in the ofp-parse module has caused the program to abort immediately with a fatal error. This makes it hard to use these functions from any long-lived program. This commit fixes the problem. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace all uses of strerror() by ovs_strerror(), for thread safety.Ben Pfaff2013-06-281-5/+5
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* Fix table checking for goto table instruction.Jarno Rajahalme2013-06-281-3/+9
| | | | | | | | | | | | | | | | Usually the table id in flow mods is 255, which means that goto table instruction cannot be checked before the table is picked (for flow add), or the rules to be modified are found (flow mod). Move goto table checking from decode (ofp-util) to actions checking (ofp-actions), and postpone the action checking until the table in which the actions are added is known. This fixes OFPBRC_BAD_TABLE_ID errors for flow adds that specify the table id as 255, and have a goto table instruction. Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-errors: Implement OpenFlow 1.2+ experimenter error codes.Ben Pfaff2013-06-251-6/+9
| | | | | | | | | | OpenFlow 1.2 standardized experimenter error codes in a way different from the Nicira extension. This commit implements the OpenFlow 1.2+ version. This commit also makes it easy to add error codes for new experimenter IDs by adding new *_VENDOR_ID definitions to openflow-common.h. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Create specific types for ofp and odp portAlex Wang2013-06-201-11/+21
| | | | | | | | | | | | Until now, datapath ports and openflow ports were both represented by unsigned integers of various sizes. With implicit conversions, etc., it is easy to mix them up and use one where the other is expected. This commit creates two typedefs, ofp_port_t and odp_port_t. Both of these two types are marked by "__attribute__((bitwise))" so that sparse can be used to detect any misuse. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofp-actions: enforce valid range for table_id in goto_table instructionJing Ai2013-06-051-3/+14
| | | | | | | | | | Found a bug that OVS allows goto_table_id to be smaller than (or equal to) the current table id where the flow resides. It potentially creates an infinite loop when composing actions for a packet. To fix it, we just let OVS returns an error message to prevent such flow to be programmed. Signed-off-by: Jing Ai <jinga@google.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Always check return value of strftime().Ben Pfaff2013-05-081-6/+2
| | | | | | | | | | | | strftime() returns 0 and leaves the contents of the output buffer unspecified if the output buffer is not big enough. Thus, one should check strftime()'s return value. Until now, OVS has had a few invocations of strftime() that did not check the return value. This commit fixes those. I believe that the buffers were always large enough in each case, but it's better to be safe. Reported-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: Fix bad info in comment on transact_multiple_noreply().Ben Pfaff2013-05-071-3/+3
| | | | | | Cut-and-paste error I guess. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: Make "ovs-ofctl monitor" respond to echo requests.Ben Pfaff2013-05-031-7/+27
| | | | | | | | | Otherwise the command will time out after a while when there's no traffic, which probably isn't what we want. Reported-by: Henry Mai <hmai@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* Make most "struct option" instances "const".Ben Pfaff2013-05-031-1/+1
| | | | | | | | Reducing non-const static data makes code more obviously thread-safe. Although option parsing does not normally need to be thread-safe, I don't know of a drawback to making its data const. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Use gmtime_r() and localtime_r() instead of non-thread-safe versions.Ben Pfaff2013-05-021-1/+3
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* Use is_pow2() function, where possible, instead of IS_POW2 macro.Ben Pfaff2013-02-011-1/+1
| | | | | | | | The IS_POW2 macro is meant for use in contexts where a function call is not allowed. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* rconn: Fix null pointer dereference in rconn_add_monitor().Ben Pfaff2013-01-241-6/+12
| | | | | | | | | | | | | | | | | | | | | | 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>
* ovs-ofctl: Use vconn_open() instead of vconn_open_block() in open_vconn__().Ben Pfaff2013-01-241-2/+1
| | | | | | | | | | | | All of the paths in open_vconn__(), except the one path that calls vconn_open() directly, just start the connection and do not block until it completes. This changes the remaining path to work the same way. This will be important in an upcoming commit when in some cases we need to take an action between opening and connecting. 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-1/+1
| | | | | | | | 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-4/+5
| | | | | | | | | | | 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>
* ofp-errors: Correctly encode errors as extensions or not depending on domain.Ben Pfaff2012-12-041-0/+35
| | | | | | | | | | | | | When ofp-errors was introduced, each OFPERR_* was either an extension or not. However, since then, some Nicira extension error code have been given official error codes in later OpenFlow versions, so now whether an OFPERR_* is an extension depends on the OpenFlow versions. This means that certain errors were encoded incorrectly as extensions in later OpenFlow versions. This commit fixes the problem. This commit also adds a test that should prevent a regression. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-ofctl: By default, do not set flow format for OpenFlow 1.1+Simon Horman2012-11-291-13/+26
| | | | | | | | | Only set the default format for ovs-ofctl monitor if OpenFlow 1.0 is the prevailing version. IMHO that is the only case where it makes sense. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>