sliver-openvswitch.git
12 years agoxenserver: Update README to be current.
Justin Pettit [Thu, 29 Sep 2011 01:37:18 +0000 (18:37 -0700)]
xenserver: Update README to be current.

12 years agoxenserver: Correct location of xen-bugtool plugins.
Justin Pettit [Thu, 29 Sep 2011 01:03:06 +0000 (18:03 -0700)]
xenserver: Correct location of xen-bugtool plugins.

xen-bugtool plugins were stored in "/etc/xensource/bugtool/bugtool-plugins/*",
but xen-bugtool will not traverse deeper than "/etc/xensource/bugtool/*".
This commit corrects the location and makes our plugins run.

signed-off-by: Justin Pettit <jpettit@nicira.com>
acked-by: Ben Pfaff <blp@nicira.com>

12 years agobugtool: Collect "lacp/show" and "cfm/show" information.
Justin Pettit [Mon, 26 Sep 2011 23:49:32 +0000 (16:49 -0700)]
bugtool: Collect "lacp/show" and "cfm/show" information.

Feature #7496

12 years agoovs-vswitchd: Document "coverage/log" in man page.
Justin Pettit [Mon, 26 Sep 2011 22:56:20 +0000 (15:56 -0700)]
ovs-vswitchd: Document "coverage/log" in man page.

12 years agolacp: Make argument to ovs-appctl "lacp/show" command optional.
Justin Pettit [Mon, 26 Sep 2011 22:44:46 +0000 (15:44 -0700)]
lacp: Make argument to ovs-appctl "lacp/show" command optional.

If an argument isn't passed to "lacp/show", it will print information
about all interfaces with LACP enabled.

12 years agocfm: Make argument to ovs-appctl "cfm/show" command optional.
Justin Pettit [Mon, 26 Sep 2011 22:40:53 +0000 (15:40 -0700)]
cfm: Make argument to ovs-appctl "cfm/show" command optional.

If an argument isn't passed to "cfm/show", it will print information
about all interfaces with CFM enabled.

12 years agoovs-appctl: Print command arguments for "help".
Justin Pettit [Mon, 26 Sep 2011 21:59:35 +0000 (14:59 -0700)]
ovs-appctl: Print command arguments for "help".

12 years agodatapath: Avoid skb-clone in upcall
Pravin Shelar [Thu, 29 Sep 2011 23:33:06 +0000 (16:33 -0700)]
datapath: Avoid skb-clone in upcall

There is not need to clone skb while sending packet to user-space.
Since data is only read from packet skb.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
12 years agoin-band: Classifier rules should use OpenFlow ports.
Jesse Gross [Thu, 29 Sep 2011 21:02:42 +0000 (14:02 -0700)]
in-band: Classifier rules should use OpenFlow ports.

The in-band rules want to allow traffic to and from the local port
but the rule to be inserted in the classifier table for DHCP traffic
used the datapath constant for local traffic instead of the OpenFlow
one.

12 years agoofp-util: make_packet_out() shouldn't receive OVSP_NONE.
Jesse Gross [Thu, 29 Sep 2011 20:30:07 +0000 (13:30 -0700)]
ofp-util: make_packet_out() shouldn't receive OVSP_NONE.

make_packet_out() operates solely at the OpenFlow layer, so it
should never receive OVSP_LOCAL as an in_port.  This function is
used only by the learning switch, which will never generate
a packet with OVSP_LOCAL so this fixes not a bug but a violation
of semantics.

12 years agoflow: Drop datapath-protocol.h from flow.c.
Jesse Gross [Thu, 29 Sep 2011 20:22:46 +0000 (13:22 -0700)]
flow: Drop datapath-protocol.h from flow.c.

datapath-protocol.h is increasingly a Linux-specific header so its
usage should be restricted from generic code.  Nothing in flow.c
uses it, so drop it to avoid layer violations.

12 years agovlog: Accept any case for ANY and PATTERN when setting levels.
Ben Pfaff [Tue, 27 Sep 2011 19:22:57 +0000 (12:22 -0700)]
vlog: Accept any case for ANY and PATTERN when setting levels.

12 years agodatapath: Avoid use-after-free error in dp_device_event().
Ben Pfaff [Thu, 29 Sep 2011 16:49:37 +0000 (09:49 -0700)]
datapath: Avoid use-after-free error in dp_device_event().

Commit f14d80834 "datapath: genl_notify() on port disappearances" frees the
vport before passing it to ovs_vport_cmd_build_info(), which reads the
freed data.

Without this commit, the following commands consistently trigger a kernel
BUG report on my test VM (which has slab debugging enabled) on 3 attempts:

    tunctl
    ovs-vsctl add-port br0 tap0
    tunctl -d tap0

With this commit, I consistently don't see the BUG, on a few hundred tries
in a tight loop.

The interesting log information is:

    device tap0 entered promiscuous mode
    device tap0 left promiscuous mode
    BUG: unable to handle kernel paging request at 6b6b6ba7
    IP: [<c88269ed>] get_vport_protected+0x8/0x52 [openvswitch_mod]
    *pde = 00000000
    Oops: 0000 [#1] SMP
    last sysfs file: /sys/devices/pci0000:00/0000:00:04.0/net/eth1/carrier
    Modules linked in: brcompat_mod openvswitch_mod

    Pid: 653, comm: tunctl Not tainted 2.6.37+ #25 /Bochs
    EIP: 0060:[<c88269ed>] EFLAGS: 00010246 CPU: 0
    EIP is at get_vport_protected+0x8/0x52 [openvswitch_mod]
    EAX: 6b6b6ba7 EBX: 00000000 ECX: 00000000 EDX: 00000000
    ESI: c6d98400 EDI: c5c32074 EBP: c6ff1de8 ESP: c6ff1de4
     DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
    Process tunctl (pid: 653, ti=c6ff0000 task=c5c3a820 task.ti=c6ff0000)
    Stack:
     00000000 c6ff1df8 c8826b1d 6b6b6b6b c6d77ab0 c6ff1e14 c8826dc6 c7489160
     00000f40 c6d98400 c6d77ab0 00000000 c6ff1e3c c88286fa 00000000 00000000
     00000002 02ff1e34 00000000 c6d77ab0 c6df98a0 00000006 c6ff1e54 c8828aa2
    Call Trace:
     [<c8826b1d>] ? get_dpifindex+0x1b/0x31 [openvswitch_mod]
     [<c8826dc6>] ? ovs_vport_cmd_fill_info+0x40/0x183 [openvswitch_mod]
     [<c88286fa>] ? ovs_vport_cmd_build_info+0x3f/0x62 [openvswitch_mod]
     [<c8828aa2>] ? dp_device_event+0x56/0xb0 [openvswitch_mod]
     [<c1046c0d>] ? notifier_call_chain+0x6d/0x96
     [<c1046c52>] ? raw_notifier_call_chain+0xc/0xe
     [<c1254c10>] ? call_netdevice_notifiers+0x3c/0x43
     [<c1255029>] ? rollback_registered_many+0xd4/0x18b
     [<c1255146>] ? rollback_registered+0x23/0x28
     [<c1255199>] ? unregister_netdevice_queue+0x4e/0x6b
     [<c1227d2e>] ? tun_chr_close+0x3f/0x76

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
12 years agobridge: Clear out all Interface fields when an interface cannot be created.
Ben Pfaff [Wed, 28 Sep 2011 16:36:13 +0000 (09:36 -0700)]
bridge: Clear out all Interface fields when an interface cannot be created.

When an Interface record is invalid (for example, when the interface that
it specifies does not exist and cannot be created), ovs-vswitchd would
leave any pre-existing data in its columns, except that it would set the
ofport column to -1 to indicate the error.  This was sometimes confusing
because, for example, the lacp_current field could still be set to "true"
if LACP has previously been active and up-to-date.

This commit changes ovs-vswitchd to reset all such data to its default
values when an interface is invalid.

Bug #7450.
Reported-by: Duffie Cooley <dcooley@nicira.com>
Bug #7491.
Reported-by: Ethan Jackson <ethan@nicira.com>
Release Notes #7500.
Reported-by: Keith Amidon <keith@nicira.com>
12 years agoxenserver: Fix typo in comment in XAPI plugin.
Ben Pfaff [Wed, 28 Sep 2011 20:27:59 +0000 (13:27 -0700)]
xenserver: Fix typo in comment in XAPI plugin.

Signed-off-by: Ben Pfaff <blp@nicira.com>
12 years agoovs.daemon: Fix bug introduced by "pychecker" warning fixes.
Ben Pfaff [Thu, 29 Sep 2011 06:09:33 +0000 (23:09 -0700)]
ovs.daemon: Fix bug introduced by "pychecker" warning fixes.

Commit 591c20651f1 "daemon.py: Don't shadow built-in 'file' variable"
changed most instances of "file" to "file_handle" but missed this one.

I'm not certain that this solves a real problem, but it still seems wrong.

Bug #7533.

12 years agoovs.daemon: Fix semantics of --pidfile option.
Ben Pfaff [Thu, 29 Sep 2011 06:07:11 +0000 (23:07 -0700)]
ovs.daemon: Fix semantics of --pidfile option.

The --pidfile option is supposed to work like this:

   * Without --pidfile, you don't get a pidfile.
   * With --pidfile, you get the default pidfile.
   * With --pidfile=FILE, you get FILE as your pidfile.

However, it actually worked like this:

   * Without --pidfile, you got the default pidfile.
   * With --pidfile, you got no pidfile at all.
   * With --pidfile=FILE, you got FILE as your pidfile.

This is because of the semantics of "default" in argparse.  It is
documented as:

    The default keyword argument of add_argument(), whose value defaults to
    None, specifies what value should be used if the command-line argument
    is not present.  For optional arguments, the default value is used when
    the option string was not present at the command line.

We actually want "const", which is documented under the description of
nargs="?" as:

    If no command-line argument is present, the value from default will be
    produced.  Note that for optional arguments, there is an additional
    case - the option string is present but not followed by a command-line
    argument.  In this case the value from const will be produced.

Bug #7533.

12 years agoovs-xapi-sync: Crashes if root-prefix is unspecified.
Ethan Jackson [Wed, 28 Sep 2011 19:12:56 +0000 (12:12 -0700)]
ovs-xapi-sync: Crashes if root-prefix is unspecified.

12 years agoroute-table: Clear route_notifier after free.
Jesse Gross [Wed, 28 Sep 2011 16:52:07 +0000 (09:52 -0700)]
route-table: Clear route_notifier after free.

If the routing table is destroyed and re-created then it will
trigger another assertion because route_notifier is not NULL,
even though it has already been freed.

12 years agosFlow: Genericize/simplify kernel sFlow implementation
Pravin Shelar [Wed, 28 Sep 2011 17:43:07 +0000 (10:43 -0700)]
sFlow: Genericize/simplify kernel sFlow implementation

Following patch adds sampling action which takes probability and set
of actions as arguments. When probability is hit, actions are executed for
given packet.
USERSPACE action's userdata (u64) is used to store struct
user_action_cookie as cookie. CONTROLLER action is fixed accordingly.

Now we can remove sFlow code from kernel and implement sFlow generically
as SAMPLE action. sFlow is defined as SAMPLE Action with probability (sFlow
sampling rate) and USERSPACE action as argument. USERSPACE action's data
is used as cookie. sFlow uses this cookie to store output-port, number of
output ports and vlan-id. sample-pool is calculated by using vport
stats.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agoxenserver: Don't specify python code by hand.
Ethan Jackson [Tue, 27 Sep 2011 23:56:23 +0000 (16:56 -0700)]
xenserver: Don't specify python code by hand.

Before this patch, a list of each python file in the xenserver rpm
was listed by hand.  This was error prone so now the spec file uses
a glob.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
12 years agoxenserver: Add vlog.py to spec file.
Ethan Jackson [Tue, 27 Sep 2011 23:49:17 +0000 (16:49 -0700)]
xenserver: Add vlog.py to spec file.

12 years agoroute-table: Close netlink notifier before closing nln.
Jesse Gross [Tue, 27 Sep 2011 22:27:43 +0000 (15:27 -0700)]
route-table: Close netlink notifier before closing nln.

Commit 2ee6545f2bff7eb27e8c84965e3ff38dfa909bf6 "notifiers: Create
and destroy nln_notifiers." requires callers to explicitly create
and destroy netlink notifiers but route-table only did the creation
part.  This causes an assertion failure any time the netdev for a
vport is destroyed (for example ovs-dpctl show when there is a
tunnel port).

Bug #7464

12 years agotests: Use compat argparse when required.
Ethan Jackson [Tue, 27 Sep 2011 22:31:18 +0000 (15:31 -0700)]
tests: Use compat argparse when required.

Some build environments don't have argparse installed.  In these
cases the test framework will use the compat version.

12 years agoovs-xapi-sync: Convert to vlog.
Ethan Jackson [Sun, 25 Sep 2011 22:40:10 +0000 (15:40 -0700)]
ovs-xapi-sync: Convert to vlog.

12 years agoovs-monitor-ipsec: Convert to vlog.
Ethan Jackson [Sun, 25 Sep 2011 22:18:44 +0000 (15:18 -0700)]
ovs-monitor-ipsec: Convert to vlog.

12 years agopython: Upgrade to vlog.
Ethan Jackson [Sun, 25 Sep 2011 00:53:30 +0000 (17:53 -0700)]
python: Upgrade to vlog.

This patch upgrades the library code in the python/ovs directory to
the new vlog module.

12 years agopython: Upgrade daemon module to argparse.
Ethan Jackson [Mon, 26 Sep 2011 23:02:26 +0000 (16:02 -0700)]
python: Upgrade daemon module to argparse.

This patch also updates it's callers.

12 years agostream.py: Make usage() function return a string.
Ethan Jackson [Mon, 26 Sep 2011 23:02:14 +0000 (16:02 -0700)]
stream.py: Make usage() function return a string.

This will marginally simplify a future patch.

12 years agopython: Create new vlog module.
Ethan Jackson [Wed, 21 Sep 2011 22:43:27 +0000 (15:43 -0700)]
python: Create new vlog module.

Currently, each python daemon has to come up with it's own logging
solution.  These logging strategies are not consistent across the
python code or with the C vlog module.  This patch adds a new
logging module which hopes to solve the problem.  This new module
generates log messages in a manner consistent with the C code.
Furthermore, it can easily be extended to support things like rate
limiters in the future.

This patch does not update any python code to use the new module.

12 years agopython: Backport argparse to older platforms.
Ethan Jackson [Thu, 22 Sep 2011 19:05:18 +0000 (12:05 -0700)]
python: Backport argparse to older platforms.

Argparse has some convenient advantages over optparse including the
ability to handle optional arguments to flags.  It also supports
parsing arguments as well as options.

This patch copies argparse.py from Python 2.7 into a newly created
compat directory.  It made some very minor syntactic updates in the
process.  Platforms which have a Python version too old to include
argparse by default will have this compat version installed as a
workaround.

12 years agotest-jsonrpc: Help option doesn't work.
Ethan Jackson [Mon, 26 Sep 2011 23:12:33 +0000 (16:12 -0700)]
test-jsonrpc: Help option doesn't work.

The test-jsonrpc.py script didn't understand the "-h" option and
threw an exception when "--help" was supplied.

12 years agoImplement "native VLAN" feature.
Ben Pfaff [Sat, 24 Sep 2011 00:03:03 +0000 (17:03 -0700)]
Implement "native VLAN" feature.

Significant updates by Ben Pfaff, including:

* Comment, coding style, indentation updates.
* Documentation improved.
* Added tests.
* Dropped PORT_VLAN_EMPTY.

12 years agobitmap: New function to allocate a bitmap initialized to all-1-bits.
Ben Pfaff [Fri, 26 Aug 2011 19:58:36 +0000 (12:58 -0700)]
bitmap: New function to allocate a bitmap initialized to all-1-bits.

12 years agoofproto-dpif: Add tests for VLAN handling.
Ben Pfaff [Fri, 26 Aug 2011 00:00:45 +0000 (17:00 -0700)]
ofproto-dpif: Add tests for VLAN handling.

These tests would have caught the bug fixed in the previous commit
"ofproto-dpif: Fix behavior when a subset of VLANs is trunked."

12 years agoofproto-dpif: Get rid of OFP_VLAN_NONE pollution.
Ben Pfaff [Mon, 26 Sep 2011 20:15:54 +0000 (13:15 -0700)]
ofproto-dpif: Get rid of OFP_VLAN_NONE pollution.

OFP_VLAN_NONE used to be convenient as a value for struct dst's 'vlan'
member, because it ended up being used in actions anyway, but now it's
much better to just use 0.

12 years agoofproto-dpif: Fix VLAN and other field handling in OFPP_NORMAL.
Ben Pfaff [Sat, 24 Sep 2011 00:11:49 +0000 (17:11 -0700)]
ofproto-dpif: Fix VLAN and other field handling in OFPP_NORMAL.

compose_actions(), which is part of the OFPP_NORMAL implementation, had
multiple flaws that this commit corrects.

First, it did not commit changes made to the flow by actions preceding
the output to OFPP_NORMAL.  This means that, for example, if an OpenFlow
action to modify an L2 or L3 header preceded the output to OFPP_NORMAL,
then OFPP_NORMAL would output its packets without those changes.

Second, it did not update the action_xlate_ctx's notion of the VLAN that
was currently set, in the cases where it modified the current VLAN.  This
means that actions following the output to OFPP_NORMAL could output to
unexpected VLANs.

Third, when it switched to VLAN 0, it unconditionally also stripped the
whole 802.1Q header, so that if the packet originally was priority tagged,
the output packet was not priority tagged.  This is reasonable behavior,
but it is a change in behavior from what previous releases of OVS did, so
this commit reverts it.

Based on a patch from and a conversation with Pravin Shelar
<pshelar@nicira.com>.

12 years agoovs-xapi-sync: Add unit test.
Ben Pfaff [Mon, 26 Sep 2011 20:07:29 +0000 (13:07 -0700)]
ovs-xapi-sync: Add unit test.

12 years agoovs-monitor-ipsec: Add unit test.
Ben Pfaff [Fri, 23 Sep 2011 21:21:19 +0000 (14:21 -0700)]
ovs-monitor-ipsec: Add unit test.

12 years agodatapath: Fix OVS build failure on older kernel
Pravin Shelar [Mon, 26 Sep 2011 19:30:50 +0000 (12:30 -0700)]
datapath: Fix OVS build failure on older kernel

   genlmsg_unicast() API changed for network namespace in 2.6.32.
Following patch handles compatibility for same.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
12 years agojson.py: Typo in parsing code.
Ben Pfaff [Mon, 26 Sep 2011 18:43:25 +0000 (11:43 -0700)]
json.py: Typo in parsing code.

12 years agopython: Style cleanup.
Ethan Jackson [Sat, 24 Sep 2011 06:43:12 +0000 (23:43 -0700)]
python: Style cleanup.

This patch does minor style cleanups to the code in the python and
tests directory.  There's other code floating around that could use
similar treatment, but updating it is not convenient at the moment.

12 years agotest-reconnect: Fix use of undefined symbol.
Ethan Jackson [Sat, 24 Sep 2011 23:19:27 +0000 (16:19 -0700)]
test-reconnect: Fix use of undefined symbol.

12 years agotest-ovsdb.py: Remove unused import.
Ethan Jackson [Sat, 24 Sep 2011 23:04:19 +0000 (16:04 -0700)]
test-ovsdb.py: Remove unused import.

12 years agoovsuuid.py: Fix use of undefined symbol.
Ethan Jackson [Sat, 24 Sep 2011 07:09:48 +0000 (00:09 -0700)]
ovsuuid.py: Fix use of undefined symbol.

Found by pychecker.

12 years agoovs-xapi-sync: Style cleanup.
Ethan Jackson [Sat, 24 Sep 2011 00:18:08 +0000 (17:18 -0700)]
ovs-xapi-sync:  Style cleanup.

Pleases pep8.

12 years agoovs-xapi-sync: Remove dead code.
Ethan Jackson [Sat, 24 Sep 2011 00:18:53 +0000 (17:18 -0700)]
ovs-xapi-sync: Remove dead code.

Found by pychecker.

12 years agobond: Remove spurious blank line.
Ben Pfaff [Fri, 23 Sep 2011 22:49:26 +0000 (15:49 -0700)]
bond: Remove spurious blank line.

12 years agoovs-monitor-ipsec: Style cleanup.
Ethan Jackson [Fri, 23 Sep 2011 22:35:04 +0000 (15:35 -0700)]
ovs-monitor-ipsec: Style cleanup.

Pleases pep8.

12 years agoovs-monitor-ipsec: Remove unused root-prefix option.
Ethan Jackson [Fri, 23 Sep 2011 22:36:59 +0000 (15:36 -0700)]
ovs-monitor-ipsec: Remove unused root-prefix option.

12 years agoovs-bugtool: Use RUNDIR macro for ovs-appctl target.
Justin Pettit [Fri, 23 Sep 2011 22:30:55 +0000 (15:30 -0700)]
ovs-bugtool: Use RUNDIR macro for ovs-appctl target.

Correct the target path used by ovs-appctl.  The previous value was
hard-coded to "/var/run", but the common path is actually
"/var/run/openvswitch".  However, it's better to use RUNDIR, since the
default location is build-time configurable.

12 years agodpif-linux: Prevent a single port from monopolizing upcalls.
Jesse Gross [Fri, 16 Sep 2011 22:23:37 +0000 (15:23 -0700)]
dpif-linux: Prevent a single port from monopolizing upcalls.

Currently it is possible for a client on a single port to generate
a huge number of packets that miss in the kernel flow table and
monopolize the userspace/kernel communication path.  This
effectively DoS's the machine because no new flow setups can take
place.  This adds some additional fairness by separating each upcall
type for each object in the datapath onto a separate socket, each
with its own queue.  Userspace then reads round-robin from each
socket so other flow setups can still succeed.

Since the number of objects can potentially be large, we don't always
have a unique socket for each.  Instead, we create 16 sockets and
spread the load around them in a round robin fashion.  It's theoretically
possible to do better than this with some kind of active load balancing
scheme but this seems like a good place to start.

Feature #6485

12 years agonetlink: Expose version of nl_attr_find for key and len.
Jesse Gross [Fri, 23 Sep 2011 18:53:12 +0000 (11:53 -0700)]
netlink: Expose version of nl_attr_find for key and len.

Many of our functions pass around a pointer to Netlink attributes
and a length.  This exposes the version of nl_attr_find that takes
that format so it can be used by callers outside the Netlink library.

12 years agopoll-loop: Enable checking whether a FD caused a wakeup.
Jesse Gross [Sun, 31 Jul 2011 21:47:32 +0000 (14:47 -0700)]
poll-loop: Enable checking whether a FD caused a wakeup.

Each time we run through the poll loop, we check all file descriptors
that we were waiting on to see if there is data available.  However,
this requires a system call and poll already provides information on
which FDs caused the wakeup so it is inefficient as the number of
active FDs grows.  This provides a way to check whether a given FD
has data.

12 years agoofproto-dpif: Flush flows before dpif_recv_set_mask().
Jesse Gross [Fri, 16 Sep 2011 16:50:35 +0000 (09:50 -0700)]
ofproto-dpif: Flush flows before dpif_recv_set_mask().

Now that upcalls from the kernel use unicast sockets, we need to
tell the kernel where to send them explicitly.  This means that
when the switch is restarted it's necessary to take control of any
existing objects, which is done when the dpif listen mask becomes
non-zero.  Since we're going to blow away the flows anyways, we
might as well do it before going through the trouble of updating
all of them.

12 years agodatapath: Use unicast Netlink sockets for upcalls.
Jesse Gross [Wed, 14 Sep 2011 20:05:09 +0000 (13:05 -0700)]
datapath: Use unicast Netlink sockets for upcalls.

Currently we publish several multicast groups for upcalls and let
userspace sockets subscribe to them.  The benefit of this is mostly
that userspace is the one doing the subscription - the actual
multicast capability is not currently used and probably wouldn't be
even if we moved to a multiprocess model.  Despite the convenience,
multicast sockets have a number of disadvantages, primarily that
we only have a limited number of them so there could be collisions.
In addition, unicast sockets give additional flexibility to userspace
by allowing every object to potentially have a different socket
chosen by userspace for upcalls.  Finally, any future optimizations
for upcalls to reduce copying will likely not be compatible with
multicast anyways so disallowing it potentially simplifies things.

We also never unregistered the multicast groups registered for upcalls
and leaked them on module unload.  As a side effect, this solves that
problem.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agonetlink: Expose method to get Netlink pid of a socket.
Jesse Gross [Fri, 16 Sep 2011 16:37:16 +0000 (09:37 -0700)]
netlink: Expose method to get Netlink pid of a socket.

In the future, the kernel will use unicast messages instead of
multicast to send upcalls.  As a result, we need to be able to
tell it where to direct the traffic.  This adds a function to expose
the Netlink pid of a socket so it can be included in messages to the
kernel.

12 years agotests: test-jsonrpc.py whitespace cleanup.
Ethan Jackson [Fri, 23 Sep 2011 22:24:10 +0000 (15:24 -0700)]
tests: test-jsonrpc.py whitespace cleanup.

Pleases pep8.

12 years agotests: test-jsonrpc references nonexistent variable.
Ethan Jackson [Sat, 17 Sep 2011 05:37:26 +0000 (22:37 -0700)]
tests: test-jsonrpc references nonexistent variable.

12 years agotag: Fix typo in comment.
Ben Pfaff [Wed, 21 Sep 2011 17:09:00 +0000 (10:09 -0700)]
tag: Fix typo in comment.

12 years agopython: Implement write support in Python IDL for OVSDB.
Ben Pfaff [Wed, 21 Sep 2011 17:43:03 +0000 (10:43 -0700)]
python: Implement write support in Python IDL for OVSDB.

Until now, the Python bindings for OVSDB have not supported writing to the
database.  Instead, writes had to be done with "ovs-vsctl" subprocesses.
This commit adds write support and brings the Python bindings in line with
the C bindings.

This commit deletes the Python-specific IDL tests in favor of using the
same tests as the C version of the IDL, which now pass with both
implementations.

This commit updates the two users of the Python IDL to use the new write
support.  I tested this updates only by writing unit tests for them,
which appear in upcoming commits.

12 years agoovs.db.types: Add table reference to ovs.db.types.BaseType.
Ben Pfaff [Tue, 20 Sep 2011 18:24:44 +0000 (11:24 -0700)]
ovs.db.types: Add table reference to ovs.db.types.BaseType.

Until now ovs.db.types.BaseType has kept track of the name of the
referenced table but not a reference to it.  This commit renames the
ref_table attribute to ref_table_name and adds a new ref_table attribute
whose value is a reference to the named table.

This will be useful in an upcoming commit where table references are
actually followed.

12 years agopython: Accept multiple forms of strings and lists when parsing JSON.
Ben Pfaff [Fri, 16 Sep 2011 00:17:36 +0000 (17:17 -0700)]
python: Accept multiple forms of strings and lists when parsing JSON.

The JSON parser in OVS always yields unicode strings and lists, never
non-unicode strings or tuples, but it's easy to create them when building
JSON elsewhere, so accept both forms.

12 years agopython: Change 'clone' function names to 'copy'.
Ben Pfaff [Thu, 15 Sep 2011 22:31:12 +0000 (15:31 -0700)]
python: Change 'clone' function names to 'copy'.

It seems that 'copy' is the proper name for this kind of function in
Python, based on the existence of dict.copy().

12 years agoovs.ovsuuid: Get rid of ovs.ovsuuid.UUID class.
Ben Pfaff [Wed, 21 Sep 2011 17:59:36 +0000 (10:59 -0700)]
ovs.ovsuuid: Get rid of ovs.ovsuuid.UUID class.

This class only caused unnecessary confusion.  This commit changes all of
its methods into top-level functions.

12 years agotests: Fix typos in C versions of test-ovsdb error messages.
Ben Pfaff [Thu, 15 Sep 2011 20:02:29 +0000 (13:02 -0700)]
tests: Fix typos in C versions of test-ovsdb error messages.

12 years agoovs.jsonrpc: Include result in Message.__str__() output.
Ben Pfaff [Thu, 15 Sep 2011 20:01:39 +0000 (13:01 -0700)]
ovs.jsonrpc: Include result in Message.__str__() output.

This was overlooked in the initial implementation.  Including the result
member makes logging output more useful.

12 years agoovs.db.data: Make Datum.check_constraints() work.
Ben Pfaff [Thu, 15 Sep 2011 19:59:31 +0000 (12:59 -0700)]
ovs.db.data: Make Datum.check_constraints() work.

This code never got tested and so didn't work.

This does not fix an actual bug because Datum.check_constraints() does not
have any existing users.

12 years agoovs.db.data: Fix Atom.new()'s handling of Boolean values.
Ben Pfaff [Thu, 15 Sep 2011 19:57:48 +0000 (12:57 -0700)]
ovs.db.data: Fix Atom.new()'s handling of Boolean values.

Boolean values have Boolean type, not real type.

This does not fix an actual bug because Atom.new() does not have existing
users.

12 years agoovsdb-idl: Code style improvements.
Ben Pfaff [Thu, 15 Sep 2011 19:53:12 +0000 (12:53 -0700)]
ovsdb-idl: Code style improvements.

I noticed these opportunities for improvement while working on the Python
IDL.

12 years agotests: Actually run all the Python IDL tests under Python.
Ben Pfaff [Thu, 15 Sep 2011 20:09:25 +0000 (13:09 -0700)]
tests: Actually run all the Python IDL tests under Python.

The lack of _PY in the macro invocations caused these tests to actually
test the C IDL.

Fortunately they would have passed anyway, modulo some minor differences
in output formatting that this commit fixes up.

12 years agoovs.json: Remove commented-out debug code.
Ben Pfaff [Tue, 13 Sep 2011 21:27:23 +0000 (14:27 -0700)]
ovs.json: Remove commented-out debug code.

This must have slipped into an old commit by accident.

12 years agoovs.json: Actually implement the "pretty" option for serialization.
Ben Pfaff [Tue, 20 Sep 2011 18:07:46 +0000 (11:07 -0700)]
ovs.json: Actually implement the "pretty" option for serialization.

12 years agopython: Avoid shadowing standard or global names.
Ben Pfaff [Thu, 25 Aug 2011 00:12:53 +0000 (17:12 -0700)]
python: Avoid shadowing standard or global names.

Found by pychecker.

12 years agopython: Avoid "unused parameter" warnings from pychecker.
Ben Pfaff [Tue, 20 Sep 2011 18:05:13 +0000 (11:05 -0700)]
python: Avoid "unused parameter" warnings from pychecker.

pychecker ignores parameters named "_" or prefixed with "unused_".

12 years agoovs.db.types: Always initialize ref_type attribute.
Ben Pfaff [Thu, 25 Aug 2011 00:10:45 +0000 (17:10 -0700)]
ovs.db.types: Always initialize ref_type attribute.

The ref_type attribute was initialized on some paths but not others.

Found by pychecker.

12 years agoovs-monitor-ipsec: Fix typo in comment.
Ben Pfaff [Thu, 22 Sep 2011 23:08:46 +0000 (16:08 -0700)]
ovs-monitor-ipsec: Fix typo in comment.

12 years agoInclude sys/socket.h for SOCK_STREAM
Simon Horman [Fri, 23 Sep 2011 11:11:20 +0000 (20:11 +0900)]
Include sys/socket.h for SOCK_STREAM

This appears to be required when building using the Android NDK r6b
(Android API level 13).

12 years agoInclude sys/wait.h for WIFEXITED
Simon Horman [Fri, 23 Sep 2011 11:11:19 +0000 (20:11 +0900)]
Include sys/wait.h for WIFEXITED

This appears to be required when building using the Android NDK r6b
(Android API level 13).

12 years agoovsdb-tool: Correct markup for 'db' argument in show-log description.
Justin Pettit [Fri, 23 Sep 2011 01:14:02 +0000 (18:14 -0700)]
ovsdb-tool: Correct markup for 'db' argument in show-log description.

12 years agoofp-print: Avoid double space before "actions" for catch-all flows.
Ben Pfaff [Thu, 22 Sep 2011 21:35:05 +0000 (14:35 -0700)]
ofp-print: Avoid double space before "actions" for catch-all flows.

Bug #7434.
Reported-by: Michael Mao <mmao@nicira.com>
12 years agonetdev-linux: Fix broken build on RHEL 6.
Ben Pfaff [Thu, 22 Sep 2011 18:54:22 +0000 (11:54 -0700)]
netdev-linux: Fix broken build on RHEL 6.

Commit 00fa9d37c2b "Do not include net/ethernet.h and linux/if_tunnel.h"
introduced a compile error on RHEL 6:

lib/netdev-linux.c: In function 'netdev_linux_listen':
lib/netdev-linux.c:734: error: 'ETH_P_ALL' undeclared (first use in this
function)

This fixes the problem.

I verified that the Android NDK r6b mentioned in the previous commit
contains a file named android-ndk-r6b/platforms/android-3/arch-x86/use/
linux/if_ether.h that defines ETH_P_ALL.  I didn't try building on that
platform.

12 years agonetlink-socket: Async notifications are incompatible with other operations.
Ben Pfaff [Thu, 22 Sep 2011 18:36:39 +0000 (11:36 -0700)]
netlink-socket: Async notifications are incompatible with other operations.

A Netlink socket that receives asynchronous notifications (e.g. from a
multicast group) cannot be used for transactions or dumps, because those
operations would discard asynchronous messages that arrive while waiting
for replies.

This commit documents this issue in a comment on nl_sock_join_mcgroup().
It also removes an internal attempt to avoid mixing multicast reception
with other operations.  The attempt was incomplete, because it only
handled dumps even though ordinary transactions are also problematic.  It
seems better to remove it than to fix it because, first, all of the
existing users in OVS already separate multicast reception from other
operations and, second, an upcoming commit will start using unicast
Netlink for asynchronous notifications, which has the same issues but
doesn't use nl_sock_join_mcgroup().

12 years agoovs-xapi-sync: Make pychecker-able.
Ben Pfaff [Wed, 21 Sep 2011 21:56:55 +0000 (14:56 -0700)]
ovs-xapi-sync: Make pychecker-able.

pychecker imports the code that it checks, which means that code at top
level runs, so "ovs-xapi-sync" failed to import unless the user had write
access to /var/log/openvswitch.

12 years agoovs-bugtool: Fix --unlimited option.
Daniel Roman [Wed, 21 Sep 2011 21:44:15 +0000 (14:44 -0700)]
ovs-bugtool: Fix --unlimited option.

Bug #5443.

12 years agoRemove netdev_find_dev_by_in4
Simon Horman [Thu, 22 Sep 2011 12:24:14 +0000 (21:24 +0900)]
Remove netdev_find_dev_by_in4

netdev_find_dev_by_in4() appears to no longer be used and thus
can be removed. This also allows netdev_enumerate(), the
enumerate member of struct netdev_class and netdev_linux_enumerate()
to be removed.

I noticed this as netdev_linux_enumerate() makes use of if_nameindex()
and if_freenameindex() which are not available when compiling using
the Android NDK r6b (Android API level 13).

12 years agoDo not include net/ethernet.h and linux/if_tunnel.h
Simon Horman [Thu, 22 Sep 2011 12:24:13 +0000 (21:24 +0900)]
Do not include net/ethernet.h and linux/if_tunnel.h

net/ethernet.h and linux/if_tunnel.h do not appear to be needed
on lib/netdev-linux.c.

I noticed this while trying to build on the Android NDK r6b (Android API
level 13) as these headers are not present there.

12 years agoAdd fallback definition of SIG_ATOMIC_MAX
Simon Horman [Thu, 22 Sep 2011 12:24:12 +0000 (21:24 +0900)]
Add fallback definition of SIG_ATOMIC_MAX

Android appears to lack SIG_ATOMIC_MAX which is only
used in fatal-signal.c.

Observed when compiling using the Android NDK r6b (Android API level 13).

Patch based on a suggestion by Ben Pfaff

12 years agoInclude <sys/time.h> in socket-util.h
Simon Horman [Thu, 22 Sep 2011 12:24:11 +0000 (21:24 +0900)]
Include <sys/time.h> in socket-util.h

sys/time.h appears to be required for a definition of timespec on Android.

Observed when compiling using the Android NDK r6b (Android API level 13).

12 years agoInclude <sys/socket.h> in socket-util.h
Simon Horman [Thu, 22 Sep 2011 12:24:10 +0000 (21:24 +0900)]
Include <sys/socket.h> in socket-util.h

This appears to be necessary to get a definition of socket_t
when compiling using the Android NDK r6b (Android API level 13).

12 years agonetlink-socket: Fix typo in comment.
Ben Pfaff [Thu, 22 Sep 2011 03:49:32 +0000 (20:49 -0700)]
netlink-socket: Fix typo in comment.

12 years agodatapath: IFF_BRIDGE_PORT is backported by Centos 5.6.
Jesse Gross [Wed, 21 Sep 2011 19:41:52 +0000 (12:41 -0700)]
datapath: IFF_BRIDGE_PORT is backported by Centos 5.6.

Some versions of Centos 5.6 backport the flag IFF_BRIDGE_PORT
without the associated rx_handler changes, so this changes to
use a version check since we really don't care about the actual
symbol.

Reported-by: Srinivasan Ramasubramanian <vrsrini@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
12 years agodatapath: Cleanup actions.c:do_output().
Jesse Gross [Tue, 20 Sep 2011 23:44:46 +0000 (16:44 -0700)]
datapath: Cleanup actions.c:do_output().

The code for outputting a packet can be simplified a little and
also modernized.  There is no functional change.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agodatapath: Send to userspace errors shouldn't halt processing.
Jesse Gross [Tue, 20 Sep 2011 23:29:38 +0000 (16:29 -0700)]
datapath: Send to userspace errors shouldn't halt processing.

If we encounter an error when sending a packet to userspace due to
an explicit action we stop processing further actions.  This makes
sense for things like push vlan, where to continue means outputting
an incorrect packet.  However, sending to userspace is more akin
to outputting to a port, which does not halt further processing.
For consistency, ignore errors in this case as well.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agodatapath: Correctly validate vport attributes on old kernels.
Jesse Gross [Tue, 20 Sep 2011 17:31:29 +0000 (10:31 -0700)]
datapath: Correctly validate vport attributes on old kernels.

The vport policy for OVS_VPORT_ATTR_PORT_NO and OVS_VPORT_ATTR_TYPE
are present only in the section for newer kernels.  This means that
on older kernels the length of these attributes are never checked
anywhere but we go ahead and read from them anyways.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agodatapath: Remove check for shared skbs.
Jesse Gross [Tue, 20 Sep 2011 21:08:57 +0000 (14:08 -0700)]
datapath: Remove check for shared skbs.

We never allow shared skbs to be present inside of the OVS datapath
but the presence of a check in the core makes this less clear.  Since
the check is very old and no longer relevant, drop it.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agoovs-vsctl: Fix typo in documentation.
Ben Pfaff [Mon, 19 Sep 2011 20:29:05 +0000 (13:29 -0700)]
ovs-vsctl: Fix typo in documentation.

I don't know what was really supposed to go here.

Documentation #7371.
Reported-by: Reid Price <reid@nicira.com>
12 years agodebian: Correct path to ovs-controller in init script.
Ben Pfaff [Tue, 20 Sep 2011 16:38:33 +0000 (09:38 -0700)]
debian: Correct path to ovs-controller in init script.

Reported-by: George Shuklin <amarao@desunote.ru>
Bug-report: http://bugs.debian.org/642206

12 years agodatapath: Fully initialize datapath before local port.
Jesse Gross [Thu, 15 Sep 2011 23:41:36 +0000 (16:41 -0700)]
datapath: Fully initialize datapath before local port.

It's possible to start receiving packets on a datapath as soon as
the internal device is created.  It's therefore important that the
datapath be fully initialized before this, which it currently isn't.
In particular, the fact that dp->stats_percpu is not yet set is
potentially fatal.  In addition, if allocation of the Netlink response
failed it would leak the percpu memory.  This fixes both problems.

Found by code inspection, in practice the datapath is probably always
done initializing before someone can send a packet on it.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 years agodatapath: Correctly set error code in queue_userspace_packets().
Jesse Gross [Mon, 19 Sep 2011 23:23:25 +0000 (16:23 -0700)]
datapath: Correctly set error code in queue_userspace_packets().

In a few places in queue_userspace_packets() when we encounter an
error, we don't actually set the 'err' variable.  Although we
free the packets we don't correctly account for these packets as
being lost.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>