Michal Weglicki [Tue, 9 Jan 2018 07:55:37 +0000 (07:55 +0000)]
netdev: Custom statistics.
- New get_custom_stats interface function is added to netdev. It
allows particular netdev implementation to expose custom
counters in dictionary format (counter name/counter value).
- New statistics are retrieved using experimenter code and
are printed as a result to ofctl dump-ports.
- New counters are available for OpenFlow 1.4+.
- New statistics are printed to output via ofctl only if those
are present in reply message.
- New statistics definition is added to include/openflow/intel-ext.h.
- Custom statistics are implemented only for dpdk-physical
port type.
- DPDK-physical implementation uses xstats to collect statistics.
Only dropped and error counters are exposed.
Co-authored-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Michal Weglicki <michalx.weglicki@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Michal Weglicki [Wed, 10 Jan 2018 13:06:03 +0000 (13:06 +0000)]
ofproto-dpif-ipfix: add interface Information Elements to flow key
Extend flow key part of data record to include following Information Elements:
- ingressInterface
- ingressInterfaceType
- egressInterface
- egressInterfaceType
- interfaceName
- interfaceDescription
In case of input sampling we don't have information about egress port.
Define templates depending not only on protocol types, but also on flow
direction. Only egress flow will include egress information elements.
With this change, dpif_ipfix_exporter stores every port in hmap rather
than only tunnel ports. It allows to easily retrieve required
information about interfaces during sampling upcalls.
Co-authored-by: Michal Weglicki <michalx.weglicki@intel.com> Signed-off-by: Michal Weglicki <michalx.weglicki@intel.com> Signed-off-by: Przemyslaw Szczerbik <przemyslawx.szczerbik@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Wed, 10 Jan 2018 16:35:04 +0000 (08:35 -0800)]
ofproto-dpif: Issue clear error messages for unsupported CT features.
I spent way too much time this last week tracking down errors due to a
VM with an antique kernel module that didn't support connection tracking.
This commit adds clear error messages that would have made the problem
obvious.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Darrell Ball <dlu998@gmail.com>
William Tu [Wed, 10 Jan 2018 21:13:11 +0000 (13:13 -0800)]
tunnel: fix tunnel flags set/clear.
Existing code only set these tunnel flags (df, csum, and key) when the
flag is set in the output tunnel port, but did not clear when the flag
is unset. The patch fixes it by setting and clearing it accordingly.
Two existing testcases need to fix:
'tunnel - Geneve option present' has no key set up, so we should match
'flags(df)' instead of 'flags(df|key)'. The second case
'tunnel - concomitant IPv6 and IPv4 tunnels' follows the same pattern.
One additional test case 'tunnel - Mix Geneve/GRE options' is added.
Signed-off-by: William Tu <u9012063@gmail.com>
VMWare-BZ: #2019012 Signed-off-by: Ben Pfaff <blp@ovn.org>
Ashish Varma [Fri, 15 Dec 2017 15:09:50 +0000 (07:09 -0800)]
tests: add-del-add sequence for interface
Added a unit test case for testing the condition when a veth interface
is added to br0 and then the veth interface is deleted from the
system and added back with the same name.
Darrell Ball [Tue, 9 Jan 2018 23:44:57 +0000 (15:44 -0800)]
conntrack: Reorder sanity checks in extract_l3_ipvx().
The functions extract_l3_ipv4 and extract_l3_ipv6 check for
unsupported ip fragments and return early. The checks were after
an assignment that would not be needed when early return happens.
This is slightly inefficient, but mostly reads poorly.
Hence, reorder the ip fragment checks before the assignments.
Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Darrell Ball [Tue, 9 Jan 2018 23:44:56 +0000 (15:44 -0800)]
conntrack: Some style improvements.
Fix up some instances where variable declarations were not close
enough to their use, as these were missed before. This is the
preferred art in OVS code and flagged heavily in code reviews.
This is highly desirable due to code clarity reasons.
There are also some cases where newlines were not needed by prior art
and some cases where they were needed but missed.
There was one case where there was a missing space after "}".
There were a few cases where for loop index declarations could be
folded into the loop.
One function was missing some const qualifiers.
There were a few instances where a local variable for conn_key_hash
could be eliminated.
Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Darrell Ball [Tue, 9 Jan 2018 23:44:55 +0000 (15:44 -0800)]
conntrack: Add additional alg support.
In order to support more algs with different requirements,
expectation handling is allowed to handle more cases, such as
a wildcard source ip as in the case of SIP. NAT can also be
skipped in some alg cases.
Expectation_create() was otherwise simplified in the process.
Some renaming was done to support the above changes.
Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Darrell Ball [Tue, 9 Jan 2018 23:44:54 +0000 (15:44 -0800)]
conntrack: Fix alg expectation cleanup.
Presently, alg expectations are removed by being time expired.
This was intended to happen before the control connections and
was intended to minimize the extra work involved for tracking and
removing the expectations. This is not the best option since it
should be possible to remove expectations when a control connection
is removed and a new api is in the works to do this. Also, conceptually
an expectation should not exist without a control connection context
and it can be argued that this should be a strict requirement.
The approach is changed to remove the expectations when the control
connections are removed. The previous code to expire the expectations
is removed at the same time.
Fixes: bd5e81a0e ("Userspace Datapath: Add ALG infra and FTP.")
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-December/341683.html Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
ofproto-dpif-xlate: Incorrect handling of errors in group action processing
As per OpenFlow v1.3 specification, when an action list contains a group
action a copy of the packet is passed to the group for processing by the
group. This means that if there is an error encountered during group
processing, only the copy of packet should be dropped, but subsequent
actions in the action list should be executed on the original packet.
Additionally, if the group type is "ALL", each action bucket of the group
should process a copy of the packet. If there is an error while processing
one bucket other buckets should still be processed.
Example 1:
table=0,in_port=tap0 actions=output:tap1,group:10,output:tap2
Even if any error is encountered while processing the group action, the
packet should still be forwarded to ports tap1 and tap2.
Example 2:
group_id=1,type=all,bucket=actions=output:tap1,bucket=actions=encap(eth)
Even if processing the action in the second bucket fails because the
packet already has an Ethernet header, the other copy of the packet should
still be processed by the first bucket and output to port tap1.
Currently the error handling in OVS does not comply with those rules. When
any group bucket execution fails the error is recorded in the so-called
"translation context" which is global for the processing of the original
packet. Once an error is recorded, OVS skips processing subsequent buckets
and installs a drop action in the datapath even if parts of the action list
were previously processed successfully.
This patch clears the error flag after any bucket of a group is executed.
This way the error encountered in processing any bucket of the group will
not impact other actions of action-list or other buckets of the group.
Errors which are system limits to protect translation from taking too long
time or too much space are not cleared. Instead drop action is installed
for them.
Signed-off-by: Vishal Deep Ajmera <vishal.deep.ajmera@ericsson.com> Signed-off-by: Keshav Gupta <keshav.gupta@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
ovs-bugtool: Extend bugtool with query repeat feature.
Devs can configure bugtool plugin queries to be repeated using
repeat counters. The value of a repeat counter is an integer
greater than 1. The outputs of a repeated query are saved in the
same output file with date headers. Queries without repeat counter
will run only once. Users can set the delay between repeated
queries with the delay option. Default value for delay is 10
seconds.
Setting repeat counter value to "2" for traffic related queries.
Signed-off-by: David Patrik Pinter <david.patrik.pinter@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
ovs-bugtool: Refactorize bugtool plugin xml files.
Introducing new query calling practice:
- single line query called directly from plugin xml
- multiple line query saved as script and the script is called
from plugin xml
Signed-off-by: David Patrik Pinter <david.patrik.pinter@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Introducing 'ovs-bugtool-ovs-ofctl-loop-over-bridges' bash script.
It calls ovs-ofctl commands given as first parameter for each
bridge with the corresponding open flow protocol option.
Usage:
ovs-bugtool-ovs-ofctl-loop-over-bridges "param1" "param2"
- param1: ovs-ofctl command to call (show, dump-flows, etc...)
- param2: optional, add further parts for the shell command
(like "| grep something")
Calling ovs-ofctl commands 'show' and 'dump-flows' with the
'ovs-bugtool-ovs-ofctl-loop-over-bridges' bash script.
Signed-off-by: David Patrik Pinter <david.patrik.pinter@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Numan Siddique [Mon, 8 Jan 2018 07:35:56 +0000 (13:05 +0530)]
OVN pacemaker: Fix issues when started as pacemaker container bundles
When OVN dbs are created as a pacemaker container bundle resource with
meta attribute "container-attribute-target=host" defined, the OVN OCF script
is not working properly. It should use the function provided by the OCF lib
'ocf_attribute_target' [1] to get the physical hostname and use that to set the
master/slave scores. This patch makes use of this function when setting the
scores. Also fixes other issues seen and deletes the local unused function
'ovsdb_server_find_active_peers'.
[1] - Please see this commit in ResourceAgents for more information on
'ocf_attribute_target'
https://github.com/ClusterLabs/resource-agents/commit/9bd94137d77f770967d35db5de716590cfaf0435
Signed-off-by: Numan Siddique <nusiddiq@redhat.com> CC: Russell Bryant <russell@ovn.org> Signed-off-by: Russell Bryant <russell@ovn.org>
Markos Chandras [Wed, 27 Dec 2017 18:27:12 +0000 (18:27 +0000)]
ovsdb: ovsdb-dot.in: Change exception semantics for Python3
PEP-3110 changes the semantics for capturing exceptions in Python3
from 'except E,N' to 'except E as N'. This fixes the following problem
when building with python3
Markos Chandras [Wed, 27 Dec 2017 18:27:11 +0000 (18:27 +0000)]
ovsdb: ovsdb-dot.in: Use print function for Python3
The python2 print statement no longer works in python3 since the
latter uses a print function. As such, replace all instances of
'print' with 'print()'. This fixes the following build problem with
python3
Markos Chandras [Wed, 27 Dec 2017 18:27:10 +0000 (18:27 +0000)]
ovsdb: Use items() instead of iteritems() for Python3
Python3 removed the iteritems() iterator and replaced it with items()
which should also work in Python2. This fixes the following build
problem on Python3:
Traceback (most recent call last):
File "./ovsdb/ovsdb-idlc.in", line 1436, in <module>
func(*args[1:])
File "./ovsdb/ovsdb-idlc.in", line 314, in printCIDLHeader
for columnName, column in sorted(table.columns.iteritems()):
AttributeError: 'dict' object has no attribute 'iteritems'
Signed-off-by: Markos Chandras <mchandras@suse.de> Signed-off-by: Ben Pfaff <blp@ovn.org>
Daniel Alvarez [Tue, 9 Jan 2018 13:54:36 +0000 (14:54 +0100)]
ovn-controller: Change duplicate flows trace from INFO to DBG
When ovn-controller detects that a flow is duplicated, it will print an
INFO trace. Even though it's rate limited, this patch is changing the
trace level back to DEBUG to reduce noise.
Background: in our effort to ensure consistency across objects in
Neutron and OVN databases we find some special cases like security group
rules which match OVN ACLs but not in 1:1 relationship. Until now, two
identical security group rules beloning each to a different security
group would generate a single ACL in NB database. With this behavior,
there's no way to map the ACL in OVN to the corresponding Neutron
object.
By implementing [0] we're trying to ensure this mapping so we make use
of the external_ids column of every table for this purpose. It may
happen that we'll have two identical ACLs but each referencing a
different Neutron object in their external_ids field. However, this will
make ovn-controller to drop those duplicated flows and log a (rate
controlled) INFO trace. In order to reduce this noise, this patch
changes it to DBG.
Commit e995e3df57 ("Allow OVS_USERSPACE_ATTR_USERDATA to be variable
length.") changed userspace action userdata from eight bytes to variable
length. OVS only supports Linux kernels greater than or equal to 3.10,
which include support for variable length userdata. Other datapaths are
more modern and should have support, so it's no longer necessary to
probe.
Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Tue, 9 Jan 2018 18:38:31 +0000 (10:38 -0800)]
ofp-errors: Send as much of a message as possible in an error reply.
When an OpenFlow switch sends an error message in reply to a request
from a controller, it includes an excerpt from the original request. The
OpenFlow specification only requires the switch to send at least the first
64 bytes of the request. Until now, Open vSwitch has only sent that much.
This commit changes Open vSwitch to instead send the entire message, only
trimming it if necessary to keep the error message within the 64 kB limit
for an OpenFlow message. This should simplify debugging for controller
authors.
Yi Yang [Sat, 6 Jan 2018 05:47:51 +0000 (13:47 +0800)]
nsh: rework NSH netlink keys and actions
This patch changes OVS_KEY_ATTR_NSH
to nested attribute and adds three new NSH sub attribute keys:
OVS_NSH_KEY_ATTR_BASE: for length-fixed NSH base header
OVS_NSH_KEY_ATTR_MD1: for length-fixed MD type 1 context
OVS_NSH_KEY_ATTR_MD2: for length-variable MD type 2 metadata
Its intention is to align to NSH kernel implementation.
NSH match fields, set and PUSH_NSH action all use the below
nested attribute format:
OVS_KEY_ATTR_NSH begin
OVS_NSH_KEY_ATTR_BASE
OVS_NSH_KEY_ATTR_MD1
OVS_KEY_ATTR_NSH end
or
OVS_KEY_ATTR_NSH begin
OVS_NSH_KEY_ATTR_BASE
OVS_NSH_KEY_ATTR_MD2
OVS_KEY_ATTR_NSH end
In addition, NSH encap and decap actions are renamed as push_nsh
and pop_nsh to meet action naming convention.
Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Mon, 8 Jan 2018 21:13:34 +0000 (13:13 -0800)]
ofproto: Delete all groups and meters when (un)configuring a controller.
Open vSwitch has always deleted all flows from the flow table whenever a
controller is configured or whenever all the controllers are unconfigured.
After this commit, OVS additionally deletes all OpenFlow groups and meters.
Suggested-by: Periyasamy Palanisamy <periyasamy.palanisamy@ericsson.com> Suggested-by: Jan Scheurich <jan.scheurich@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jan Scheurich <jan.scheurich@ericsson.com> Tested-by: Jan Scheurich <jan.scheurich@ericsson.com> Reviewed-by: Greg Rose <gvrose8192@gmail.com> Tested-by: Greg Rose <gvrose8192@gmail.com>
Timothy Redaelli [Fri, 22 Dec 2017 15:00:53 +0000 (16:00 +0100)]
rhel: add "force-reload-kmod" support in "ovs-systemd-reload"
Since you can't use "ovs-ctl force-reload-kmod" on Fedora/RHEL, due to
systemd dependencies, this commit adds the "force-reload-kmod" feature on
ovs-systemd-reload.
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Greg Rose <gvrose8192@gmail.com> Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Ben Pfaff [Fri, 5 Jan 2018 06:40:01 +0000 (22:40 -0800)]
ofp-print: Include full hex dump of messages that fail decode.
In debugging issues with a controller that appears to send invalid
OpenFlow messages, it can be difficult to actually see the important
details of those messages, because OpenFlow message logging (in the vconn
log module) will generally just print a generic decode error that doesn't
allow a developer to see what failed to decode. This commit enhances the
ofp-print code so that, if a message fails to decode, the full hex dump of
the message is included in the output.
Reported-by: Su Wang <suwang@vmware.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Gurucharan Shetty <guru@ovn.org>
Mark Michelson [Wed, 29 Nov 2017 21:59:48 +0000 (15:59 -0600)]
OVN: Add support for periodic router advertisements.
This change adds three new options to the Northbound
Logical_Router_Port's ipv6_ra_configs option:
* send_periodic: If set to "true", then OVN will send periodic router
advertisements out of this router port.
* max_interval: The maximum amount of time to wait between sending
periodic router advertisements.
* min_interval: The minimum amount of time to wait between sending
periodic router advertisements.
When send_periodic is true, then IPv6 RA configs, as well as some layer
2 and layer 3 information about the router port, are copied to the
southbound database. From there, ovn-controller can use this information
to know when to send periodic RAs and what to send in them.
Because periodic RAs originate from each ovn-controller, the new
keep-local flag is set on the packet so that ports don't receive an
overabundance of RAs.
Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Mark Michelson [Wed, 29 Nov 2017 21:59:47 +0000 (15:59 -0600)]
OVN: Add multicast local-only flag.
When this flag is set, then a multicast packet that would normally be
delivered to ports on multiple hypervisors is only delivered to ports
on the local hypervisor.
The primary known use case for this is when multicast packets originate
from ovn-controller. Multiple ovn-controllers will be attempting to send
out those multicast packets, and so each should only be responsible for
delivering those packets to their local ports.
Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Thu, 28 Dec 2017 20:34:50 +0000 (12:34 -0800)]
tunnel: Add ofproto/list-tunnels command for troubleshooting.
I've recently had to debug some issues related to tunnel implementation.
This command would make it easier to have some confidence in how tunnels
are actually set up inside OVS.
Ben Pfaff [Thu, 28 Dec 2017 20:34:49 +0000 (12:34 -0800)]
tunnel: Log sanely in tnl_port_receive().
When this function was introduced in 2012, it modified its 'flow' argument
and logged the changes (at debug level). However, since 2013 it has no
longer modified its 'flow' argument, but the logging was still oriented
around the idea that it did. This commit fixes up the logging to make
sense again.
This doesn't fix an actual bug that causes problems, but it does fix a
conceptual error.
Fixes: 2301f7ebc15e ("tunnel: Make tnl_port_receive() parameter 'const'.") Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Jakub Sitnicki [Fri, 22 Dec 2017 15:12:52 +0000 (16:12 +0100)]
tests: Kill the daemons at cleanup only if pidfile exists.
Remembering the PIDs of started daemon processes and killing them during
cleanup can interfere with other tests.
When the tests are running in parallel (i.e., -jX was passed in
TESTSUITEFLAGS), PIDs of daemons that have terminated before the cleanup
are subject to reuse by processes, or threads, spawned in another test.
This means that, while executing its 'cleanup' script, one test can
accidentally send a SIGTERM to a process running as a part of another
test and influence its outcome.
Retrieve the PID of the process we intend to kill at the last possible
moment to narrow down the window of opportunity for interfering.
This approach has a downside that if the daemon's pidfile has
disappeared but the process has not terminated, we will not clean it up
at the end of the test.
Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Fri, 6 Oct 2017 22:15:31 +0000 (15:15 -0700)]
log: Use absolute name of log file.
In ovsdb-server, the OVSDB log code is used to open the databases specified
on the command line before ovsdb-server daemonizes itself. Afterward, it
is occasionally necessary for ovsdb-server to reference those files by name
again. When that happens, if daemonization changed the current directory
to the root, any relative names are no longer valid and those references
will fail. Until now, this was handled at a higher level in ovsdb-server,
but in the future it will be convenient to handle it in the log code
itself. This commit prepares for that by making the log code take the
absolute name of log files itself.
Ben Pfaff [Mon, 25 Dec 2017 01:52:34 +0000 (17:52 -0800)]
log: Replace ovsdb_log_get_offset() by a more abstract mechanism.
Upcoming support for clustered databases will need to provide a more
abstract way to determine when a given file should be compacted, so this
changes the standalone database support to use this mechanism in advance.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Mon, 25 Dec 2017 00:19:24 +0000 (16:19 -0800)]
log: Support multiple magic.
Some OVSDB tools will want to open files that might be standalone or
clustered databases, and so it's better if ovsdb_log_open() can accept more
than one valid "magic". This commit makes that possible.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Fri, 6 Oct 2017 18:40:00 +0000 (11:40 -0700)]
log: Support using /dev/stdin for opening logs read-only.
On Unix-like systems, usually /dev/stdin opens a duplicate of fd 0, and
this will be convenient in a few places later on. This commit makes this
support universal.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Thu, 7 Dec 2017 22:33:28 +0000 (14:33 -0800)]
log: New functions for replacing a log's contents.
These functions will acquire users in future commits.
This new functionality made the internal state machine of the log hard
enough to understand that I thought that it was best to make it explicit
with a 'state' variable, so this commit introduces one.
This commit duplicates code and logic from ovsdb_rename() and
ovsdb_compact() in ovsdb/file.c. A future commit removes this duplication.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Wed, 6 Dec 2017 20:36:44 +0000 (12:36 -0800)]
log: Make reading in writing mode less of an error.
Clients are intended to use the OVSDB log code by reading zero or more
records and then writing zero or more records, but not reading after any
write has occurred. Until now, ovsdb_log_read() has signaled the latter
behavior as an error. Upcoming changes to OVSDB are going to make it an
expected behavior in some cases, so this commit changes it so that it
just becomes an empty read.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Wed, 6 Dec 2017 18:33:21 +0000 (10:33 -0800)]
log: Require log entries to be JSON objects.
The current and upcoming users of the OVSDB logging module only use
JSON objects as records. This commit simplifies the users slightly
by allowing them to always assume that the records are JSON objects.
Unfortunately this resulted in a large number of updates to tests,
which didn't always use JSON objects.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Sun, 24 Dec 2017 19:43:59 +0000 (11:43 -0800)]
log: Allow client to specify magic.
Until now, the logging code in ovsdb has only supported a single file
format, for OVSDB standalone database files. Upcoming commits will add
support for another, incompatible format, which uses a different magic
string for identification. This commit allows the logging code to
support both formats.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Mon, 6 Nov 2017 22:42:32 +0000 (14:42 -0800)]
sparse: Add guards to prevent FreeBSD-incompatible #include order.
FreeBSD insists that <sys/types.h> be included before <netinet/in.h> and
that <netinet/in.h> be included before <arpa/inet.h>. This adds guards to
the "sparse" headers to yield a warning if this order is violated. This
commit also adjusts the order of many #includes to suit this requirement.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Fri, 8 Dec 2017 20:36:57 +0000 (12:36 -0800)]
ovsdb-client: Show even constraint-breaking data in "dump" output.
The ovsdb-client "dump" command is a fairly low-level tool that can be
used, among other purposes, to debug the OVSDB protocol. It's better if
it just prints what the server sends without being too judgmental about it.
Thus, we might as well ignore constraints for the purpose of dumping
tables.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Ben Pfaff [Mon, 4 Dec 2017 19:51:43 +0000 (11:51 -0800)]
odp-util: Use flexible sized buffer to hold Geneve options.
The 'mask' buffer in parse_odp_action() is supposed to always be big
enough:
/* 'mask' is big enough to hold any key. */
Geneve options can be really big and the comment was wrong. In addition,
the user might supply more options than can really fit in any case, so
we might as well just use a stub.
Found by libfuzzer.
Reported-by: Bhargava Shastry <bshastry@sec.t-labs.tu-berlin.de> Signed-off-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Mon, 27 Nov 2017 21:53:28 +0000 (13:53 -0800)]
netdev-tc-offloads: Use customary types for buffer.
This function uses local array set_buff[] to store Netlink attributes.
It declares set_buff as an array of character pointers, which is a strange
type for a buffer of non-character-pointer objects. In OVS it is
customary to use an ofpbuf with a stub of uint64_t objecs (to ensure
proper alignment, otherwise uint8_t would be more usual). This commit
changes to that more usual form.
Ben Pfaff [Mon, 23 Oct 2017 21:01:50 +0000 (14:01 -0700)]
ovs-vswitchd: Allow more convenient 0x short form for specifying DPIDs.
Until now, ovs-vswitchd has insisted that other-config:datapath-id be
exactly 16 hex digits. This commit allows shorter forms prefixed by 0x.
This was prompted by Faucet controller examples such as this one:
https://github.com/faucetsdn/faucet/blob/master/docs/README_config.rst
which tend to suggest datapath IDs like 0x1.
CC: Josh Bailey <joshb@google.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff [Mon, 27 Nov 2017 17:20:57 +0000 (09:20 -0800)]
odp-util: Avoid reading wrong table in generate_all_wildcard_mask().
These lines of code are intended to copy the 'next' and 'next_max' members
of tbl[type] into local variables 'tbl' and 'max':
tbl = tbl[type].next;
max = tbl[type].next_max;
They didn't do it properly because the first line changes 'tbl', so that
the first and seconds lines' references to tbl[type] refer to different
objects.
Ilya Maximets [Thu, 14 Dec 2017 11:59:24 +0000 (14:59 +0300)]
dpif-netdev: Output packet batching.
While processing incoming batch of packets they are scattered
across many per-flow batches and sent separately.
This becomes an issue while using more than a few flows.
For example if we have balanced-tcp OvS bonding with 2 ports
there will be 256 datapath internal flows for each dp_hash
pattern. This will lead to scattering of a single recieved
batch across all of that 256 per-flow batches and invoking
send for each packet separately. This behaviour greatly degrades
overall performance of netdev_send because of inability to use
advantages of vectorized transmit functions.
But the half (if 2 ports in bonding) of datapath flows will
have the same output actions. This means that we can collect
them in a single place back and send at once using single call
to netdev_send. This patch introduces per-port packet batch
for output packets for that purpose.
'output_pkts' batch is thread local and located in send port cache.
Ilya Maximets [Thu, 14 Dec 2017 11:59:23 +0000 (14:59 +0300)]
dpif-netdev: Keep latest measured time for PMD thread.
In current implementation 'now' variable updated once on each
receive cycle and passed through the whole datapath via function
arguments. It'll be better to keep this variable inside PMD
thread structure to be able to get it at any time. Such solution
will save the stack memory and simplify possible modifications
in current logic.
This patch introduces new structure 'dp_netdev_pmd_thread_ctx'
contained by 'struct dp_netdev_pmd_thread' to store any processing
context of this PMD thread. For now, only time and cycles moved to
that structure. Can be extended in the future.
Ilya Maximets [Mon, 11 Dec 2017 13:18:43 +0000 (16:18 +0300)]
netdev-dpdk: Add debug appctl to get mempool information.
New appctl 'netdev-dpdk/get-mempool-info' implemented to get result
of 'rte_mempool_list_dump()' function if no arguments passed and
'rte_mempool_dump()' if DPDK netdev passed as argument.
Could be used for debugging mbuf leaks and other mempool related
issues. Most useful in pair with `grep -v "cache_count.*=0"`.
Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com> Tested-by: Mark Kavanagh <mark.b.kavanagh@intel.com> Acked-by: Antonio Fischetti <antonio.fischetti@intel.com> Acked-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Yifeng Sun [Mon, 11 Dec 2017 13:44:07 +0000 (05:44 -0800)]
bond: Fix bug that writes to freed memory
pr_op->pr_rule is pointing to memory in bond->hash. It shouldn't be written
if bond->hash is already freed.
This bug is reported by running kernel path testsuite under valgrind:
Invalid write of size 8
at 0x413D16: update_recirc_rules__ (bond.c:392)
by 0x414CA0: bond_unref (bond.c:290)
by 0x427E3C: bundle_destroy (ofproto-dpif.c:3002)
by 0x429EF4: bundle_set (ofproto-dpif.c:3023)
by 0x40858B: port_destroy (bridge.c:4087)
by 0x40BD04: bridge_destroy (bridge.c:3266)
by 0x410528: bridge_exit (bridge.c:506)
by 0x4072EE: main (ovs-vswitchd.c:135)
Address 0xb5a85f0 is 5,360 bytes inside a block of size 12,288 free'd
at 0x4C2EDEB: free (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x414C8D: bond_unref (bond.c:288)
by 0x427E3C: bundle_destroy (ofproto-dpif.c:3002)
by 0x429EF4: bundle_set (ofproto-dpif.c:3023)
by 0x40858B: port_destroy (bridge.c:4087)
by 0x40BD04: bridge_destroy (bridge.c:3266)
by 0x410528: bridge_exit (bridge.c:506)
by 0x4072EE: main (ovs-vswitchd.c:135)
Block was alloc'd at
at 0x4C2DB8F: malloc (/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x516C04: xmalloc (util.c:120)
by 0x414FD1: bond_entry_reset (bond.c:1651)
by 0x414FD1: bond_reconfigure (bond.c:470)
by 0x41507D: bond_create (bond.c:245)
by 0x429D5D: bundle_set (ofproto-dpif.c:3194)
by 0x408AC8: port_configure (bridge.c:1052)
by 0x40CD87: bridge_reconfigure (bridge.c:682)
by 0x410775: bridge_run (bridge.c:2998)
by 0x407244: main (ovs-vswitchd.c:119)
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Greg Rose <gvrose8192@gmail.com> Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Yifeng Sun [Mon, 11 Dec 2017 13:44:06 +0000 (05:44 -0800)]
valgrind: Add support to run kernel datapath testsuite under valgrind
With this patch, kernel datapath testsuite can be run under valgrind by using
the "check-kernel-valgrind" target and the results can be found under directory
"tests/system-kmod-testsuite.dir/".
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Greg Rose <gvrose8192@gmail.com Reviewed-by: Greg Rose <gvrose8192@gmail.com>