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

19894 Commits

Author SHA1 Message Date
Ben Pfaff
092bebdc04 vswitchd: Make "fdb/show" output more meaningful port numbers.
The "fdb/show" unixctl command was showing vswitch-internal port indexes,
which cannot be meaningfully interpreted by software outside vswitchd.
Also, they potentially change every time the vswitchd configuration file
changes.  This commit changes it to use a datapath port index instead,
which are both more meaningful and more stable.
2009-07-16 15:15:02 -07:00
Ben Pfaff
867fb42cba cfg: New function cfg_get_matches(). 2009-07-16 15:07:05 -07:00
Ben Pfaff
3b01baa397 Merge citrix branch into master. 2009-07-16 11:54:37 -07:00
Ben Pfaff
3c303e5fe1 Implement "brctl showmacs" support in brcompat and ovs-brcompatd.
This is needed by the Citrix test infrastructure.
2009-07-16 09:18:23 -07:00
Ben Pfaff
e5307f55aa brcompat: Refactor infrastructure for communication with ovs-brcompatd.
In an upcoming change, brcompat will need to receive bulk data from
ovs-brcompatd.  The existing brcompat infrastructure for receiving data
only supports returning an error code, so this commit adds the ability to
receive an arbitrary sk_buff and updates the existing users to handle it.
2009-07-16 09:18:23 -07:00
Ben Pfaff
14551ceac6 brcompatd: Factor code out of prune_ports().
An upcoming commit will also need to gather all of the interfaces on a
specified bridge, so break this code into a helper function.
2009-07-16 09:18:21 -07:00
Ben Pfaff
b5dae6846a process: New function process_run_capture().
In an upcoming commit, ovs-brcompatd will need to create a subprocess and
capture both its stdout and stderr separately, which one cannot do with
simple interfaces such as popen().  This function provides that ability.
2009-07-16 09:17:06 -07:00
Ben Pfaff
1fa39e1d50 process: Factor code out of process_start() into helper functions.
An upcoming commit will add a new function that can also use these helper
functions.
2009-07-16 09:17:06 -07:00
Ben Pfaff
52dc2ef41b process: Fix races on fatal signal handling in process_start().
To prevent fatal signals in a child process from causing the parent
process's pidfile, etc. to be deleted, we need to block fatal signals
around fork and call fatal_signal_fork() in the child process.

This problem was noticed through code inspection; it has not been observed
in practice.
2009-07-16 09:17:06 -07:00
Ben Pfaff
8c4c1387fd vswitchd: New unixctl command "fdb/show" to print the MAC learing table.
To implement "brctl showmacs" for bridge compatibility, brcompatd needs to
be able to extract the MAC learning table from ovs-vswitchd.  This provides
a way, and it may be directly useful to switch administrators also.
2009-07-16 09:17:06 -07:00
Ben Pfaff
321943f790 mac-learning: New function mac_entry_age().
This function will be used as part of printing the MAC learning table at
user request.
2009-07-16 09:17:06 -07:00
Ben Pfaff
eaa7133434 Add macros for parsing MAC addresses from strings. 2009-07-16 09:17:06 -07:00
Ben Pfaff
4871855420 New function ds_steal_cstr(). 2009-07-16 09:17:06 -07:00
Ben Pfaff
a8b5f8b423 Add function get_null_fd(), to reduce code redundancy. 2009-07-16 09:17:03 -07:00
Ben Pfaff
080ec396fd ovs-ofctl: Use 65535 instead of 0 for OFPP_CONTROLLER max_len.
OpenFlow 0.9 will change the interpretation of a max_len of 0 in an
OFPP_CONTROLLER output action from "send entire packet" to "send 0 bytes
of packet", but ovs-ofctl documents that specifying no argument or "ALL"
as the argument to a CONTROLLER output action sends the whole packet, so
we need to make that happen.
2009-07-15 13:25:11 -07:00
Ben Pfaff
aec7d2fba6 brcompat: Improve comments in header file. 2009-07-15 12:45:35 -07:00
Ben Pfaff
25ce84b23b vswitchd: Skip updelay on slave when only a single bond slave is up.
If a network device takes a few seconds to detect carrier, as some do, then
when bringing up a network device and then immediately adding that device
to a bridge, the bond code would start out with that slave considered down
and apply the full updelay to it before bringing it up.  With the 31-second
updelay set by XenServer, this is excessive: we end up having no
connectivity at all for 31 seconds even though there is no reason for it.

This commit makes the bond code disregard the updelay when an interface
comes up on a bond that has no enabled interfaces, and updates the
documentation to match.

Part of bug #1566.
2009-07-14 17:04:40 -07:00
Ben Pfaff
17ea75b2a2 vswitchd: Fix log messages when bond slaves are enabled or disabled.
We were printg "enabled" when a slave was disabled and vice versa.

Part of bug #1566.
2009-07-14 17:04:40 -07:00
Justin Pettit
e775da1437 Fix unitialized variable in coverage_log()
When providing the ability to force coverage printouts to occur, some
code was moved around that allowed the "hash" variable to be used
unitialized.  This fixes that.

Thanks to Ben for pointing out the problem.

Bug #1577
2009-07-14 00:25:44 -07:00
Ben Pfaff
923229363a datapath: Don't orphan packets in dp_dev transmit path.
Before commit 72ca14c1 "datapath: Fix race against workqueue in dp_dev and
simplify code," the dp_dev network device had a device queue, and we would
orphan packets before sticking them on the queue.  This screwed up socket
accounting a bit, but the effect was limited to the device queue length.

Now, after that commit, the dp_dev device has no device queue, but it still
orphans packets.  This screws up socket accounting a *lot*, because the
effect is now unlimited, since there is no queue to limit it.

The solution is to not orphan packets at all.  There is little need for it
now since packet transmission now happens immediately, not in a workqueue
whose execution may be delayed.

This should fix bug #1519, which tests "netperf -t UDP_STREAM" performance,
finding that an unrealistically high number of UDP packets could be sent
but that none at all were received.  The send rate is due to the orphaning,
the receive rate presumably because at least one out of approx. 65535/1500
= 44 fragments per full packet were dropped in each case.
2009-07-13 15:50:32 -07:00
Ben Pfaff
d7cca86710 vconn: Fix detection of vconn local IP address, to fix in-band control.
The in-band control code needs to know the IP and port of both ends of the
control connection.  However, the vconn code was only reporting the local
address after the connection had already succeeded, which created a
chicken-and-egg problem.  In practice we would fail to connect until the
switch went into fail-open, at which point the connection would go through.

Fortunately, we can get the local IP address right after we try to connect,
not just after the connection completes, so this commit changes the code
to do that.

This commit also breaks setting the remote IP and port into functions
separate from vconn_init(), which makes the code more readable.
2009-07-13 15:06:59 -07:00
Ben Pfaff
00c030a597 Revert "datapath: Don't orphan packets in dp_dev transmit path."
This reverts commit 0858ad2b9d2f594f99bb11fc9b331ce8b1de953d.
Although that commit partially fixed a performance regression
relative to the Linux bridge, it introduced other problems that
were not apparent in the performance testing (e.g.
WARN_ON_ONCE(skb->destructor) now triggers in dp_process_received_packet()).
The fix is not completely obvious, so reverting now to ensure stability
while investigating the problem.
2009-07-13 11:56:26 -07:00
Ben Pfaff
0858ad2b9d datapath: Don't orphan packets in dp_dev transmit path.
Before commit 72ca14c1 "datapath: Fix race against workqueue in dp_dev and
simplify code," the dp_dev network device had a device queue, and we would
orphan packets before sticking them on the queue.  This screwed up socket
accounting a bit, but the effect was limited to the device queue length.

Now, after that commit, the dp_dev device has no device queue, but it still
orphans packets.  This screws up socket accounting a *lot*, because the
effect is now unlimited, since there is no queue to limit it.

The solution is to not orphan packets at all.  There is little need for it
now since packet transmission now happens immediately, not in a workqueue
whose execution may be delayed.

This should fix bug #1519, which tests "netperf -t UDP_STREAM" performance,
finding that an unrealistically high number of UDP packets could be sent
but that none at all were received.  The send rate is due to the orphaning,
the receive rate presumably because at least one out of approx. 65535/1500
= 44 fragments per full packet were dropped in each case.
2009-07-13 11:21:50 -07:00
Justin Pettit
67ca9e6d90 Remove "coverage/clear" command due its limited use
The poll loop calls coverage_clear on every pass anyway, so provide a
function to call it separately is of limited value.
2009-07-10 17:36:09 -07:00
Justin Pettit
cae40bbd0c Fix small typo in ovs-ofctl man page. 2009-07-10 17:33:41 -07:00
Justin Pettit
f5c6854a73 Provide ability to retrieve coverage information
Previously, there was no way to induce coverage information to be
displayed; it would only print when the system noticed unusual delays
between polling intervals.  Now, production of coverage logs can be
forced with "coverage/log" command in ovs-appctl.  Coverage counters may
be reset with "coverage/clear".
2009-07-10 15:09:41 -07:00
Ben Pfaff
55fa0147b1 Document how to submit patches for Open vSwitch. 2009-07-10 13:38:58 -07:00
Ben Pfaff
77671a6ad3 Document how to report bugs in Open vSwitch. 2009-07-10 11:04:05 -07:00
Ben Pfaff
7ad5233116 INSTALL.bridge: Add detail suggested by Pete. 2009-07-10 11:03:00 -07:00
Ben Pfaff
5fca1acd93 Document how to use Open vSwitch as a replacement for the Linux bridge. 2009-07-10 10:35:36 -07:00
Ben Pfaff
10bf9f637b datapath: Fix races in updating dp_dev port statistics. 2009-07-08 14:13:15 -07:00
Ben Pfaff
828bc1f072 datapath: Fix race in datapath creation.
Before we create the local port, we should allocate and assign the table.
Otherwise packets sent on the local port before we do so will cause an
OOPS.

This is a theoretical race that has not been observed in practice.
2009-07-08 14:13:15 -07:00
Ben Pfaff
72ca14c154 datapath: Fix race against workqueue in dp_dev and simplify code.
The dp_dev_destroy() function failed to cancel the xmit_queue work, which
allowed it to run after the device had been destroyed, accessing freed
memory.  However, simply canceling the work with cancel_work_sync() would
be insufficient, since other packets could get queued while the work
function was running.  Stopping the queue with netif_tx_disable() doesn't
help, because the final action in dp_dev_do_xmit() is to re-enable the TX
queue.

This issue led me to re-examine why the dp_dev needs to use a work_struct
at all.  This was implemented in commit 71f13ed0b "Send of0 packets from
workqueue, to avoid recursive locking of ofN device" due to a complaint
from lockdep about recursive locking.

However, there's no actual reason that we need any locking around
dp_dev_xmit().  Until now, it has accepted the standard locking provided
by the network stack.  But looking at the other software devices (veth,
loopback), those use NETIF_F_LLTX, which disables this locking, and
presumably do so for this very reason.  In fact, the lwn article at
http://lwn.net/Articles/121566/ hints that NETIF_F_LLTX, which is otherwise
discouraged in the kernel, is acceptable for "certain types of software
device."

So this commit switches to using NETIF_F_LLTX for dp_dev and gets rid
of the work_struct.

In the process, I noticed that veth and loopback also take advantage of
a network device destruction "hook" using the net_device "destructor"
member.  Using this we can automatically get called on network device
destruction at the point where rtnl_unlock() is called.  This allows us
to stop stringing the dp_devs that are being destroyed onto a list so
that we can free them, and thus simplifies the code along all the paths
that call dp_dev_destroy().

This commit gets rid of a call to synchronize_rcu() (disguised as a call
to synchronize_net(), which is a macro that expands to synchronize_rcu()),
so it probably speeds up deleting ports, too.
2009-07-08 14:13:15 -07:00
Ben Pfaff
6d867ef335 datapath: Remove declarations of functions that are never defined or used. 2009-07-08 14:13:15 -07:00
Ben Pfaff
6fba0d0b82 datapath: Fix use-after-free error in datapath destruction.
When we create a datapath we do this:

	1. Create local port.
	2. Call add_dp hook.
	3. Allow userspace to add more ports.

When we deleted a datapath we were doing this:

	1. Call del_dp hook
	2. Delete all the ports.

Unfortunately step 1 destroys dp->ifobj, then dp_del_port on any port other
than the local port in step 2 tries to reference dp->ifobj through a call
to sysfs_remove_link().

This commit fixes the problem by changing datapath deletion to mirror
creation:

	1. Delete all the ports but the local port.
	2. Call dp_del hook.
	3. Delete local port.

Commit 010082639 "datapath: Add sysfs support for all (otherwise supported)
Linux versions" makes this problem obvious on a 2.6.25+ kernel configured
with slab debugging, because on such kernels the ifobj is a pointer to a
slab object that is freed by the del_dp hook function (when brcompat_mod
is loaded).  This bug may be just as present on older kernels, but there
the ifobj is part of struct datapath, not a pointer, and thus it is much
harder to trigger.

Bug #1465.
2009-07-08 14:13:15 -07:00
Ben Pfaff
334b374988 datapath: Remove redundant synchronize_rcu() call.
There is no benefit to synchronizing twice, and it might cost us a lot of
time.
2009-07-08 14:13:15 -07:00
Justin Pettit
26d9fe3b2d secchan: Various fixes to run in-band on non-"local" port
The in-band control code assumed that we would connect to the controller
over the datapath's "local" port.  If the switch had multiple datapaths,
and the controller was only available through one of them, the other
datapaths would fail to connect.  This is addressed by the following
changes:

    - The controller's MAC address is looked up through the connection's
      interface instead of the datapath's local one.

    - We allow ARP traffic to be sent by the connection's interface.

    - We allow ARP traffic to be sent to the controller's MAC address.
      This is necessary if the controller is running locally (e.g. in a VM).

Bug #1466
2009-07-08 11:19:52 -07:00
Justin Pettit
79c720a830 Provide method to locate device by IP and add more nodev functions to netdev
In some cases we need to be able to locate a device by its IPv4 address.
There doesn't seem to be an easy way to do this on Linux, so we iterate
through all devices until it's found.  The caller can provide a hint as
to the device, so subsequent checks can be quicker.

This checkin also adds nodev versions of functions to lookup ARP entries
and the IPv4 address of a device.
2009-07-08 11:19:52 -07:00
Justin Pettit
ae8871ec5b Show more information about connection when querying status.
It is often useful in debugging to know the ports and IP addresses being
used in an OpenFlow connection.  This commit adds the remote and local
IP addresses and ports used for a connection to the "status" information
returned by ovs-ofctl.

Feature #1484.
2009-07-08 11:19:52 -07:00
Justin Pettit
193456d581 Have rconn and vconn export information about IPs and ports
Previously, rconn and vconn only allowed users to find out about the
remote IP address.  This set of changes allows users to retrieve the
remote port, local IP, and local port used for the connection.
2009-07-08 11:19:51 -07:00
Justin Pettit
ab9c78ff50 Include "inttypes.h" to pickup definition of PRIu8. 2009-07-08 11:19:51 -07:00
Ben Pfaff
8cd4882fd5 Rename "secchan" to "ofproto" (library) and "ovs-openflowd" (program).
These names are more meaningful, so we prefer them.
2009-07-08 10:30:42 -07:00
Justin Pettit
3b250e2911 secchan: Display mgmt and datapath id in status messages
Since it's not always easy to determine the management id, this adds the
ability to see it (and the datapath id) with the "ovs-ofctl status"
command.

Feature #1533
2009-07-07 09:34:37 -07:00
Justin Pettit
fef94d151c vswitchd: Add missing argument to check for update-resolv.conf config 2009-07-06 22:12:53 -07:00
Ben Pfaff
de2047c512 vswitch: Don't pass null pointer to stat().
If no CA certificate is defined then cacert_file is null.  The kernel
kindly tolerates this but we should not do it anyhow.

Found with valgrind.
2009-07-06 16:35:04 -07:00
Ben Pfaff
d3d22744a7 vswitch: Avoid knowledge of details specific to Linux datapaths.
At startup, the vswitch needs to delete datapaths that are not configured
by the administrator.  Until now this was done by knowing the possible
names of Linux datapaths.  This commit cleans up by allowing each
datapath class to enumerate its existing datapaths and their names.
2009-07-06 11:06:36 -07:00
Ben Pfaff
a165b67e53 dpif-linux: Don't allow arbitrary internal ports to identify a datapath.
The userspace tools were allowing the name of any internal port to be used
to identify a datapath.  This, however, makes it hard to enumerate all the
names by which a datapath can be known, and it was never documented or
intentional behavior, so this commit disables it.
2009-07-06 11:02:57 -07:00
Ben Pfaff
632d136c7b vswitch: Remove restriction on datapath names.
Commit f4b96c92c "vswitch: Disallow bridges named "dpN" or "nl:N"" disabled
naming bridges "dpN" because the vswitchd code made the bad assumption that
the bridge's local port has the same name as the bridge, which was not
true (at the time) for bridges named dpN.  Now that assumption has been
eliminated, so this commit eliminates the restriction too.

This change is also a cleanup in that it eliminates one form of the
vswitch's dependence on specifics of the dpif implementation.
2009-07-06 10:17:54 -07:00
Ben Pfaff
72865317a4 New implementation of userspace datapath, based on the netdev library. 2009-07-06 09:55:06 -07:00
Ben Pfaff
e9e28be359 Introduce general-purpose ways to wait for dpif and netdev changes.
The dpif and netdev code has had various ways to check for changes to
dpifs and netdevs over the course of Open vSwitch development.  All of
these have been thus far fairly specific to the Linux implementation.  This
commit is the start of a more general API for watching for such changes.
The dpif-related parts seem fairly mature and so they are documented,
the netdev parts will probably need to change somewhat and so they are
not documented yet.
2009-07-06 09:07:24 -07:00