2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 13:58:14 +00:00
Commit Graph

17132 Commits

Author SHA1 Message Date
Ben Pfaff
0d7e8aac8d xenserver: Bring up physical devices before configuring local port.
If DHCP is in use, then the physical devices have to be up before we
configure the local port, otherwise the DHCP request will never hit the
wire and we have no hope of getting an IP address.

This problem has been here for a long time, but it was masked until
commit c170afc1 "xenserver: Really take devices down in
interface-reconfigure." actually caused devices to go down and stay down.

Fixes bug #1809 "vswitch upgrade broke the xenserver".
2009-08-07 17:02:34 -07:00
Ben Pfaff
c170afc1db brcompat: Remove no-longer-needed #includes. 2009-08-07 15:11:42 -07:00
Ben Pfaff
6dac2b9ed9 brcompat: Remove requirement that that no datapaths exist at load time.
We previously required that brcompat_mod be loaded before any datapaths
were created, because creation and destruction of datapaths and ports
differed when brcompat_mod was loaded, but the latter is no longer the
case so there is no reason for the former anymore.
2009-08-07 15:11:42 -07:00
Ben Pfaff
35c979bff4 vswitchd: Support creating fake bond device interfaces.
Citrix QA scripts expect that "brctl show" shows a bond interface for each
bond that is added to a bridge.  The only way to do that without modifying
brctl itself is to create an actual network device by that name, so this
commit adds a new bonding configuration key that causes an internal
device by the name of the bond to be created.

This feature is also necessary, but not sufficient, to allow XenCenter to
accurately show the link status and statistics of bridges (bug #1363).

This new configuration key is intentionally undocumented, because I don't
want anyone to use it.

Bug NIC-19.
2009-08-07 15:11:42 -07:00
Ben Pfaff
db322751d8 brcompat: Move BRCTL_GET_BRIDGES, BRCTL_GET_PORT_LIST into userspace.
The Citrix QA scripts assume that "brctl show" will show a topology as if
the Linux bridge were still in use; that is, as if there were one bridge
per VLAN and as if bonds were network devices of their own instead of
separate devices.  However, we were showing the datapath topology, i.e.
all VLANs and bond devices lumped together into a single datapath.  This
commit fixes the VLAN end of the problem, by moving the implementation of
the ioctls that brctl uses into userspace in ovs-brcompatd and putting the
necessary translation logic into ovs-brcompatd.

By itself, this commit does not fix the problem for bonds: the port name
for a bond does not (normally) under Open vSwitch exist as an actual
Linux network device, and thus it has no ifindex, and so ovs-brcompatd
can't pass it back to the kernel to report to brctl.  This fix will have
to wait for another commit.

Bug NIC-19.
2009-08-07 15:11:40 -07:00
Ben Pfaff
ae1281cfa0 brcompatd: Factor code out of handle_fdb_query_cmd().
An upcoming commit wants to do the same thing in another place, so break
the logic into a function.
2009-08-07 15:05:47 -07:00
Ben Pfaff
621fd03a07 brcompatd: Fix handle_fdb_query_cmd() return value on error.
handle_fdb_query_cmd() should return an error when an error occurs, but
in this case it was always returning 0, because error is known to have
value 0 at this point.

Nothing really uses the return value here, and so eventually it would make
sense to just change the return type here and in the rest of the
handle_*() functions to void.
2009-08-07 15:05:47 -07:00
Ben Pfaff
41e754bcb4 brcompatd: Break send_reply() up into more functions for flexibility.
Upcoming commits will require sending Netlink messages to the kernel that
have additional attributes.  Instead of adding more arguments to
send_reply() to handle these, it's cleaner to break up send_reply() into
two functions and let the caller add those attributes itself.
2009-08-07 15:05:47 -07:00
Ben Pfaff
7f42c1d707 brcompatd: Make parse_command() parse commands without dp arguments.
The BRCTL_GET_BRIDGES ioctl is going to move to userspace, but that ioctl
doesn't provide a bridge name as argument, so we need to support that.
2009-08-07 15:05:47 -07:00
Ben Pfaff
c338e47fbe svec: New convenience macro SVEC_FOR_EACH. 2009-08-07 15:05:47 -07:00
Ben Pfaff
f86e18b739 datapath: Unexport functions only used in openvswitch_mod. 2009-08-07 15:05:47 -07:00
Ben Pfaff
0ceda58c06 xenserver: Fix infinite recursion in get_netdev_by_mac.
Oops.
2009-08-07 14:47:06 -07:00
Justin Pettit
d2a345699f dpif: Only clear 'all_dps' argument in dp_enumerate().
Originally, the function dp_enumerate() initialized the 'all_dps'
argument.  This is inconsistent with most other functions that take an
svec argument, which would only clear the contents.  Further, if someone
were not careful when reusing the svec, it could lead to memory leaks.
With this change, the caller is expected to first call svec_init() on
the argument.
2009-08-07 11:16:06 -07:00
Justin Pettit
16cd277e74 XenServer: Add knowledge of vswitch to xen-bugtool
The xen-bugtool tool gathers information that may be useful in debugging
problems.  This commit modifies that script to add support for vswitch.
Currently, the information we collect is:

    - /etc/ovs-vswitchd.conf
    - ovs-dpctl show
    - Cores in /var/xen/vswitch
    - ovs-ofctl show <bridges>
    - ovs-ofctl status <bridges>
    - ovs-ofctl dump-flows <bridges>
    - ovs-dpctl dump-flows <bridges>

This commit also modifies the way cores are handled.  They are now
enabled by default and placed in "/var/xen/vswitch".

Feature #1570
2009-08-06 18:04:37 -07:00
Justin Pettit
e7bd7d78b1 daemon: Remove short options from daemon library
The daemon library provides a few short options, but these then take
away their availability from programs that wish to use the library.
Since the daemon options are generally going to be called from a script
(which doesn't care how much typing is involved), we'll only provide
long options.
2009-08-06 18:04:36 -07:00
Justin Pettit
8093d640ac secchan: Remove mention of "-f" flag as being equivalent "--fail"
In an error message, it mentions a required argument to "-f or --fail",
but "-f" is not a short form of "--fail".
2009-08-06 18:04:36 -07:00
Justin Pettit
91a1e24d09 daemon: Provide option to not chdir to root
By default, Open vSwitch daemons change their working directories to the
root directory.  This commit provides a --no-chdir option to prevent this
behavior.
2009-08-06 18:04:36 -07:00
Justin Pettit
c4fca56af2 ovs-dpctl: Remove UNUSED attributed in do_show
The do_show() function declared the argc argument as UNUSED, but it
always is.
2009-08-06 18:04:36 -07:00
Justin Pettit
b566902b59 ovs-dpctl: Add dump-dps command
The "dump-dps" command prints the name of each datapath on a separate
line.
2009-08-06 18:04:36 -07:00
Ian Campbell
c239b2d4f3 xenserver: Cope gracefully with non-integer MTU in interface-reconfigure.
CP-1148.
2009-08-06 17:07:18 -07:00
Ian Campbell
9dc898c09d xenserver: Log attempts to enable promiscuous mode for bridge ports on vif plug.
This functionality is replaced by vSwitch support for SPAN/RSPAN.

CP-1148.
2009-08-06 17:07:18 -07:00
Ian Campbell
42ab020339 xenserver: Update copyright on interface-configure and vif hotplug script.
CP-1148.
2009-08-06 17:07:18 -07:00
Ben Pfaff
2bb451b698 xenserver: Rename network devices to match MAC addresses of physical PIFs.
XenServer does not rely on Linux to keep the naming of network devices
stable from one boot to the next.  Instead, it requires
interface-reconfigure to ensure that network devices are named such that
they have the MAC address specified for the corresponding physical PIF
in the xapi database.

At one point, we fulfilled this requirement by calling out to the Centos
ifup/ifdown scripts, which rename netdevs as necessary to match the
"HWADDR=" lines in /etc/sysconfig/network-scripts/ifcfg-<devname>.  When
we rewrote interface-reconfigure not to use those scripts, however, we
accidentally dropped that support.  This commit adds back in that renaming.

Bug NIC-20.
2009-08-06 17:01:53 -07:00
Ben Pfaff
449776d81d xenserver: Add new helper function to interface-reconfigure.
This will be useful in the followin commit.
2009-08-06 16:57:06 -07:00
Ben Pfaff
ba09980aaf vswitchd: Fix use of uninitialized variable in bridge_pick_local_hw_addr().
When a port's MAC is explicitly specified in the config file, we did not
initialize 'iface' and therefore later we could dereference a wild pointer.
This commit fixes the problem.
2009-08-06 16:57:06 -07:00
Ben Pfaff
c874dc6d6b secchan: Fix behavior when a network device is renamed.
update_port() deals with the case where we have been notified that a
network device with a given name, that is part of the datapath, has changed
in some way.  In particular it breaks the problem space up into ports that
have been added, deleted, or modified.

But the code here deals badly with the case where the only change is that
the network device associated with a port has been renamed (which is
reported to it with 'devname' as the network device's new named): it
looks up devname in the ofproto's index by name and doesn't find it, then
it looks up the port number assigned to the netdev in the ofproto's index
by datapath index and sees that there already is one.  This makes it
think that it's a new port, but with a port number that conflicts with an
existing port (under the old name for the port), which makes it discard
the notification and keep the old netdev name, and so afterward nothing
on the netdev will work since it still has the old netdev name.

This rewrite fixes the problem and simplifies the code.
2009-08-06 16:57:06 -07:00
Ben Pfaff
0515ceb3e8 datapath: Update sysfs links when network devices are renamed.
We create symlinks from /sys/class/net/<bridgename>/brif/<devname> to
/sys/class/net/<devname>/brport, but until now we have never updated the
links when network devices are renamed.  This commit fixes this problem.

(Only the <devname> in /sys/class/net/<bridgename>/brif/<devname> needs to
be updated.  Symlinks within sysfs have stable targets; that is, no matter
how the object that a sysfs symlink points to moves around, the link is
still maintained correctly.)
2009-08-06 16:57:06 -07:00
Ben Pfaff
58c342f617 datapath: Fix OOPS when dp_sysfs_add_if() fails.
Until now, when dp_sysfs_add_if() failed, the caller ignored the failure.
This is a minor problem, because everything else should continue working,
without sysfs entries for the interface, in theory anyhow.  In actual
practice, the error exit path of dp_sysfs_add_if() does a kobject_put(),
and that kobject_put() calls release_nbp(), so that the new port gets
freed.  The next reference to the new port (usually in an ovs-vswitchd call
to the ODP_PORT_LIST ioctl) will then use the freed data and probably OOPS.

The fix is to make the datapath code, as opposed to the sysfs code,
responsible for creating and destroying the net_bridge_port kobject.  The
dp_sysfs_{add,del}_if() functions then just attach and detach the kobject
to sysfs and their cleanup routines no longer need to destroy the kobject
and indeed we don't care whether dp_sysfs_add_if() really succeeds.

This commit also makes the same transformation to the datapath's ifobj,
for consistency.

It is easy to trigger the OOPS fixed by this commit by adding a network
device A to a datapath, then renaming network device A to B, then renaming
network device C to A, then adding A to the datapath.  The last attempt to
add A will fail because a file named /sys/class/net/<datapath>/brif/A
already exists from the time that C was added to the datapath under the
name A.

This commit also adds some compatibility infrastructure, because it moves
code out of #ifdef SUPPORT_SYSFS and it otherwise wouldn't build.
2009-08-06 16:57:06 -07:00
Ben Pfaff
3de35df914 datapath: Prepare to extend lifetime of kobjects.
The following commit will move the initialization of the datapath and
net_bridge_port kobjects earlier and the destruction later, without
changing when those kobjects are attached to sysfs.  To do so, the
initialization of kobjects and attaching to sysfs has to be done as
separate steps.  That's already the case for net_bridge_port kobjects, and
this commit makes it so for datapath kobjects too.

This commit also simplifies some code, since the split API exists both
before and after 2.6.25, but the combined functions changed names.

Also, in dp_sysfs_add_if() call kobject_init() after initializing the
kset member, since kobject_init() expects that.  This makes no actual
difference in this case since the kobj is obtained from kzalloc(), but
it still seems better.
2009-08-06 16:57:06 -07:00
Ben Pfaff
2ba9026e2f datapath: Rename brc_sysfs_* to dp_sysfs_*.
These files and names are now part of the datapath, not brcompat, so name
them appropriately so as not to confuse anyone.
2009-08-06 16:57:06 -07:00
Ben Pfaff
2e7dd8eca8 datapath: Move sysfs support from brcompat_mod into openvswitch_mod.
In the past problems have arisen due to the different ways that datapaths
are created and destroyed in the three different cases:

	1. sysfs supported, brcompat_mod loaded.
	2. sysfs supported, brcompat_mod not loaded.
	3. sysfs not supported.

The brcompat_mod loaded versus not loaded distinction is the stickiest
because we have to do all the calls into brcompat_mod through hook
functions, which in turn causes pressure to keep the number of hook
functions small and well-defined, which makes it really difficult to put
the hook call points at exactly the right place.  Witness, for example,
this piece of code in datapath.c:

        int dp_del_port(struct net_bridge_port *p)
        {
                ASSERT_RTNL();

        #ifdef SUPPORT_SYSFS
                if (p->port_no != ODPP_LOCAL && dp_del_if_hook)
                        sysfs_remove_link(&p->dp->ifobj, p->dev->name);
        #endif

The code inside the #ifdef is logically part of the brcompat_mod sysfs
support, but the author of this code (quite reasonably) didn't want to
add a hook function call there.  After all, what would you call the
hook function?  There's no obvious name from the dp_del_port() caller's
perspective.

All this argues that sysfs support should be in openvswitch_mod itself,
since it has to be tightly integrated, not bolted on.  So this commit
moves it there.

Now, this is not to say that openvswitch_mod should actually be
implementing bridge-compatible sysfs.  In the future, it probably should
not be; rather, it should implement something appropriate for Open vSwitch
datapaths instead.  But right now we have bridge-compatible sysfs, and so
that's what this commit moves.
2009-08-06 16:57:06 -07:00
Ben Pfaff
3cc42ebbc1 xenserver: Really take devices down in interface-reconfigure.
When down_netdev was called with deconfigure=True (which is the default),
it would invoke, e.g. "/sbin/ifconfig eth0 down 0.0.0.0", with the
intention of taking the interface down and removing any IP address from it
at the same time.

In fact, this removed any IP address from it and brought the device *up*,
because ifconfig executes its commands in the order that they are
specified, and setting or unsetting an IP address brings a device up.

We could specify the commands in the opposite order ("0.0.0.0 down") but
it seems to me more obviously correct to just run ifconfig twice, so that
is what this commit does.

This commit could break things, because it could be that there is a bug
elsewhere that depends on down_netdev not actually bringing a device down,
but it is needed for the upcoming device renaming commit (to fix bug
NIC-20), because a network device has to be down to be renamed.
2009-08-06 16:57:06 -07:00
Ben Pfaff
5e93df1c46 brcompat: Add comments to sysfs code.
I got tired of figuring out over and over what these function calls do.
2009-08-06 16:57:06 -07:00
Ben Pfaff
8cc013b20f vswitchd: Fix logged warnings for new internal ports.
Justin reported that adding an internal port to a bridge caused
ovs-vswitchd to log a pair of warnings.  This commit suppresses those
warnings, which were harmless.
2009-08-06 10:33:26 -07:00
Justin Pettit
1dcf111b1c datapath: Support jumbo frames in the datapath device
The datapath has no problems switching jumbo frames (frames with a payload
greater than 1500 bytes), but it has not supported sending and receiving
them to the device itself.  With this commit, the MTU can be set as large
as the minimum MTU size of the devices that are directly attached, or 1500
bytes if there are none.  This mimics the behavior of the Linux bridge.

Feature #1736
2009-08-03 13:29:22 -07:00
Justin Pettit
110d69af04 vswitchd: Initialize cfg properly and check return values
A previous checkin added the cfg_init() function, so we now call it.  We
also check the return value of the initial call to cfg_read(), since if
it fails, there's not much point in continuing.
2009-08-03 11:24:23 -07:00
Justin Pettit
590ab3cc64 cfg: Terminate cfg to prevent crashes
If cfg_* accessor calls were made before cfg_read() was called (or it
returned error), they could cause segfault.  This checkin terminates the
cfg structure in such a way that will prevent these run-time problems.

Bug #1693
2009-08-01 00:58:31 -07:00
Ben Pfaff
5146acb140 Fix broken build by making "make dist" include lib/netdev-provider.h. 2009-07-30 17:10:13 -07:00
Ben Pfaff
559843ed53 rtnetlink: Move into separate source and header file.
Now that rtnetlink isn't named similarly to netdev_linux, it might as well
have its own source and header files to avoid confusing everyone.
2009-07-30 16:07:15 -07:00
Ben Pfaff
d81c0ac56d rtnetlink: Document. 2009-07-30 16:07:14 -07:00
Ben Pfaff
46097491e4 netdev-linux: Rename "linux_netdev_*" to "rtnetlink_*".
It was getting to be too confusing to have both netdev_linux_* functions
and linux_netdev_* functions.  Rename the latter to make the distinction
more obvious.  "rtnetlink" seems to be a fairly good name because that's
what the kernel calls it, so the name will be familiar at least to people
who know about rtnetlink.
2009-07-30 16:07:14 -07:00
Ben Pfaff
8b61709d5e netdev: Implement an abstract interface to network devices.
This new abstraction layer allows multiple implementations of network
devices in a single running process.  This will be useful, for example, to
support network devices that are simulated entirely in the running process
or that communicate with other processes over Unix domain sockets, etc.

The reimplemented tap device support in this commit has not been tested.
2009-07-30 16:07:14 -07:00
Ben Pfaff
b1bf7d43b3 netdev: Remove netdev_nodev_*() functions.
These functions are now unused, so they may be deleted.
2009-07-30 16:07:14 -07:00
Ben Pfaff
b2f17b151d netdev: Make netdev_get_vlan_vid() take a netdev instead of a name.
For consistency, it's best if every netdev function takes a netdev instead
of a device name.  The netdev_nodev_*() functions have always been a bit
ugly.
2009-07-30 16:07:14 -07:00
Ben Pfaff
07c318f404 vswitchd: Avoid netdev_nodev_*() functions.
The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.  This commit converts all of the users of these functions to use
the corresponding functions that take a "struct netdev *" instead.
2009-07-30 16:07:14 -07:00
Ben Pfaff
795fe1fba0 vswitchd: Avoid netdev_nodev_set_policing().
The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.
2009-07-30 16:07:14 -07:00
Ben Pfaff
c752217a1e netdev: Make netdev_find_dev_by_in4() use netdevs, not device names.
The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

Also updates the only user of netdev_find_dev_by_in4().
2009-07-30 16:07:14 -07:00
Ben Pfaff
96b9b7a9ef vswitchd: Don't keep track of mac in struct iface.
It's easy to get the Ethernet address of the interface from the netdev
code, and so we don't have to keep track of it in the bridge too.
2009-07-30 16:07:14 -07:00
Ben Pfaff
0c6aea3f9b vswitchd: Keep a netdev open for each interface.
This will allow the vswitch to use the netdev functions that take a
netdev parameter instead of the ones that take a device name.
2009-07-30 16:07:14 -07:00
Ben Pfaff
6ae39834ad vswitchd: Factor out iteration over interfaces with deletion.
Two different pieces of code in vswitchd were both iterating over all
the interfaces in a bridge and deleting some of them, then deleting any
ports that ended up with no interfaces because of this.  This commit
factors this operation out into a helper function.
2009-07-30 16:07:14 -07:00