openvswitch
15 years agoAdd missing switch case.
Ben Pfaff [Thu, 8 Jan 2009 23:20:32 +0000 (15:20 -0800)]
Add missing switch case.

Found with -Wswitch-enum.

15 years agoAdd missing trailing initializers.
Ben Pfaff [Thu, 8 Jan 2009 23:19:50 +0000 (15:19 -0800)]
Add missing trailing initializers.

Found with -Wmissing-field-initializers.

15 years agoMark out_of_memory() as never returning.
Ben Pfaff [Thu, 8 Jan 2009 23:18:38 +0000 (15:18 -0800)]
Mark out_of_memory() as never returning.

Found with -Wmissing-noreturn.

15 years agoAdd missing header file to brcompat.h.
Ben Pfaff [Thu, 8 Jan 2009 23:18:00 +0000 (15:18 -0800)]
Add missing header file to brcompat.h.

Found with -Wmissing-prototypes.

15 years agovlog: Fix initializer in VLOG_RATE_LIMIT macro.
Ben Pfaff [Thu, 8 Jan 2009 23:27:52 +0000 (15:27 -0800)]
vlog: Fix initializer in VLOG_RATE_LIMIT macro.

Found by -Wmissing-field-initializers.

15 years agovlog: Mark format_log_message() as taking a printf format string.
Ben Pfaff [Thu, 8 Jan 2009 23:27:35 +0000 (15:27 -0800)]
vlog: Mark format_log_message() as taking a printf format string.

Found by -Wmissing-format-attribute.

15 years agoFix bug that could have caused infinite loop in ofp_print_actions().
Ben Pfaff [Thu, 8 Jan 2009 23:27:23 +0000 (15:27 -0800)]
Fix bug that could have caused infinite loop in ofp_print_actions().

Found by -Wextra noticing that len < 0 is always false.

15 years agoRemove unused functions.
Ben Pfaff [Thu, 8 Jan 2009 23:27:03 +0000 (15:27 -0800)]
Remove unused functions.

Found by -Wmissing-prototypes.

15 years agoAdd missing function prototypes to header files.
Ben Pfaff [Thu, 8 Jan 2009 23:12:29 +0000 (15:12 -0800)]
Add missing function prototypes to header files.

Found with -Wmissing-prototypes.

15 years agoRemove comparison of unsigned value < 0.
Ben Pfaff [Thu, 8 Jan 2009 23:25:24 +0000 (15:25 -0800)]
Remove comparison of unsigned value < 0.

Found by -Wextra.

15 years agoMark unused callback function parameters as UNUSED.
Ben Pfaff [Thu, 8 Jan 2009 23:25:15 +0000 (15:25 -0800)]
Mark unused callback function parameters as UNUSED.

Found by -Wunused-parameters.

15 years agoChange external functions to static functions, where possible.
Ben Pfaff [Thu, 8 Jan 2009 23:25:05 +0000 (15:25 -0800)]
Change external functions to static functions, where possible.

Found by -Wmissing-prototypes.

15 years agoMake function declarations into prototypes.
Ben Pfaff [Thu, 8 Jan 2009 23:24:48 +0000 (15:24 -0800)]
Make function declarations into prototypes.

Found by -Wmissing-prototypes.

15 years agoRemove unused function parameter from stp_start().
Ben Pfaff [Thu, 8 Jan 2009 23:23:50 +0000 (15:23 -0800)]
Remove unused function parameter from stp_start().

Found by -Wunused-parameter.

15 years agoRemove unused function parameter from stp_received_tcn_bpdu().
Ben Pfaff [Thu, 8 Jan 2009 23:23:29 +0000 (15:23 -0800)]
Remove unused function parameter from stp_received_tcn_bpdu().

Found with -Wunused-parameter.

15 years agonetdev: Remove unused 'fd' parameter from set_flags().
Ben Pfaff [Thu, 8 Jan 2009 23:00:13 +0000 (15:00 -0800)]
netdev: Remove unused 'fd' parameter from set_flags().

Found by -Wunused-parameter.

15 years agonetdev: Remove unused 'netdev' parameter from dpif_add_router().
Ben Pfaff [Thu, 8 Jan 2009 22:59:42 +0000 (14:59 -0800)]
netdev: Remove unused 'netdev' parameter from dpif_add_router().

Found by -Wunused-parameter.

15 years agoRemove 'wait' parameter from dpif_send_openflow().
Ben Pfaff [Thu, 8 Jan 2009 22:58:35 +0000 (14:58 -0800)]
Remove 'wait' parameter from dpif_send_openflow().

The 'wait' parameter had no effect (it was not implemented) and it was
only ever set to false.  It's easier to simply remove it than to
implement an unneeded feature.

Found by -Wunused-parameter.

15 years agovswitchd: Fix port mirroring example.
Ben Pfaff [Thu, 8 Jan 2009 21:54:41 +0000 (13:54 -0800)]
vswitchd: Fix port mirroring example.

Thanks to Keith for pointing this out.

15 years agovswitchd: Fix inaccurate comment.
Ben Pfaff [Thu, 8 Jan 2009 21:39:56 +0000 (13:39 -0800)]
vswitchd: Fix inaccurate comment.

Thanks to Pete for pointing this out.

15 years agovswitchd: Make secchan subprocesses listen for management connections.
Ben Pfaff [Thu, 8 Jan 2009 21:38:10 +0000 (13:38 -0800)]
vswitchd: Make secchan subprocesses listen for management connections.

15 years agosecchan: Fix inverted logic (down vs. up).
Ben Pfaff [Thu, 8 Jan 2009 21:37:44 +0000 (13:37 -0800)]
secchan: Fix inverted logic (down vs. up).

15 years agodatapath: Fix deadlock in switch port removal.
Ben Pfaff [Thu, 8 Jan 2009 20:25:18 +0000 (12:25 -0800)]
datapath: Fix deadlock in switch port removal.

dp_del_switch_port() cancels the port_task and waits for
it to finish, but the port_task requires the RTNL lock
to complete, which dp_del_switch_port() holds, thus a
deadlock.

This commit fixes the problem, by deleting the port_task
entirely and moving its work into secchan.

15 years agodatapath: Avoid deadlock on dp_mutex versus kthread_stop().
Ben Pfaff [Thu, 8 Jan 2009 00:57:05 +0000 (16:57 -0800)]
datapath: Avoid deadlock on dp_mutex versus kthread_stop().

When a datapath is deleted, del_dp() acquires dp_mutex and uses
kthread_stop() to wait for the dp_task to die.  Meanwhile, dp_task may
be waiting to acquire dp_mutex and won't die until it does so.

This commit fixes the problem by sending SIGKILL to dp_task before
call kthread_stop() and making dp_task give up if it receives a signal.

15 years agodatapath: Fix deadlock in network device notifier.
Ben Pfaff [Wed, 7 Jan 2009 23:19:09 +0000 (15:19 -0800)]
datapath: Fix deadlock in network device notifier.

When a network device that is part of a datapath is destroyed, the
notifier handler in dp_device_event() calls dp_del_switch_port() to
delete the switch port.  dp_del_switch_port() then calls rtnl_lock()
to drop the device's promiscuous count.  But the RTNL lock has already
been taken at this point, so taking it recursively deadlocks.

The obvious fix is for dp_del_switch_port()'s caller to take the RTNL
lock for it, if it is not already taken.  This, however, causes a
different deadlock, as dp_del_switch_port() needs dp_mutex and that
means that we are nesting dp_mutex and the RTNL both ways.

The fix used here is to always nest dp_mutex inside the RTNL lock and
never vice versa.

    =============================================
    [ INFO: possible recursive locking detected ]
    ---------------------------------------------
    tunctl/2934 is trying to acquire lock:
     (rtnl_mutex){--..}, at: [<c029667d>] mutex_lock+0x1c/0x1f

    but task is already holding lock:
     (rtnl_mutex){--..}, at: [<c029667d>] mutex_lock+0x1c/0x1f

    other info that might help us debug this:
    1 lock held by tunctl/2934:
     #0:  (rtnl_mutex){--..}, at: [<c029667d>] mutex_lock+0x1c/0x1f

    stack backtrace:
     [<c01040cf>] show_trace+0xd/0x10
     [<c0104655>] dump_stack+0x19/0x1b
     [<c012f897>] __lock_acquire+0x747/0x9a6
     [<c0130058>] lock_acquire+0x4b/0x6b
     [<c029651b>] __mutex_lock_slowpath+0xb0/0x1f6
     [<c029667d>] mutex_lock+0x1c/0x1f
     [<c023f045>] rtnl_lock+0xd/0xf
     [<c89703eb>] dp_del_switch_port+0x2d/0xb9 [openflow_mod]
     [<c8972554>] dp_device_event+0x84/0xb0 [openflow_mod]
     [<c0125033>] notifier_call_chain+0x20/0x31
     [<c012506d>] raw_notifier_call_chain+0x8/0xa
     [<c0237e75>] unregister_netdevice+0x129/0x1ce
     [<c020ed97>] tun_chr_close+0x5e/0x69
     [<c01573a5>] __fput+0xb3/0x15e
     [<c0157467>] fput+0x17/0x19
     [<c0154de1>] filp_close+0x51/0x5b
     [<c011aeca>] put_files_struct+0x6d/0xa9
     [<c011becf>] do_exit+0x206/0x790
     [<c011c4d2>] sys_exit_group+0x0/0x11
     [<c011c4e1>] sys_exit_group+0xf/0x11
     [<c0102ab7>] syscall_call+0x7/0xb

Problem identified with this script (in conjunction with the brcompat
module):

    #! /bin/sh
    brctl delbr a
    brctl delbr b
    brctl delbr c
    set -x
    stress () {
        bridge=$1
        shift
        while true; do
            brctl addbr $bridge; brctl show
            for iface
            do
                case $iface in
                    tap*) tunctl -t $iface ;;
                esac
                brctl addif $bridge $iface
            done
            for iface
            do
                brctl delif $bridge $iface
                case $iface in
                    tap*) tunctl -d $iface ;;
                esac
            done
            brctl delbr $bridge; brctl show
        done
    }
    stress a tap0 tap1 tap2 &
    stress b tap3 tap4 tap5 &
    trap 'killall stress-brctl' 0 SIGINT
    wait

15 years agoStyle fixes.
Ben Pfaff [Wed, 7 Jan 2009 01:26:36 +0000 (17:26 -0800)]
Style fixes.

15 years agoInclude "util.h" in hmap.h, to get CONTAINER_OF.
Ben Pfaff [Tue, 6 Jan 2009 20:57:12 +0000 (12:57 -0800)]
Include "util.h" in hmap.h, to get CONTAINER_OF.

15 years agoConvert GFP_ATOMIC to GFP_KERNEL where possible.
Ben Pfaff [Tue, 6 Jan 2009 22:44:49 +0000 (14:44 -0800)]
Convert GFP_ATOMIC to GFP_KERNEL where possible.

GFP_KERNEL is preferable, because it is more likely to succeed.  This code
is allowed to sleep, so GFP_ATOMIC is not necessary.

15 years agoExpose NetFlow to vswitchd configuration.
Justin Pettit [Tue, 6 Jan 2009 17:49:25 +0000 (09:49 -0800)]
Expose NetFlow to vswitchd configuration.

15 years agoFix the previous fix.
Ben Pfaff [Tue, 6 Jan 2009 01:00:42 +0000 (17:00 -0800)]
Fix the previous fix.

*sigh*

15 years agoFix datapath build by distributing all the necessary compatibility headers.
Ben Pfaff [Tue, 6 Jan 2009 00:58:29 +0000 (16:58 -0800)]
Fix datapath build by distributing all the necessary compatibility headers.

15 years agoFix "make dist" by adding forgotten files to sources lists.
Ben Pfaff [Tue, 6 Jan 2009 00:36:42 +0000 (16:36 -0800)]
Fix "make dist" by adding forgotten files to sources lists.

15 years agovswitchd: Implement spanning tree protocol.
Ben Pfaff [Tue, 6 Jan 2009 00:23:32 +0000 (16:23 -0800)]
vswitchd: Implement spanning tree protocol.

15 years agoImprove STP library.
Ben Pfaff [Tue, 6 Jan 2009 00:04:05 +0000 (16:04 -0800)]
Improve STP library.

- Don't expose the funny STP time units; instead, convert to and from
  milliseconds at the module boundary.

- Allow the client to configure the max age, hello time, and forward delay
  parameters.

- Do more of the construction of BPDUs internally, instead of making the
  client do it.

15 years agovswitchd: New function cfg_is_valid().
Ben Pfaff [Tue, 6 Jan 2009 00:01:32 +0000 (16:01 -0800)]
vswitchd: New function cfg_is_valid().

15 years agoDo not forward multicast addresses that must not be, in learning-switch.
Ben Pfaff [Tue, 6 Jan 2009 00:00:19 +0000 (16:00 -0800)]
Do not forward multicast addresses that must not be, in learning-switch.

15 years agoNew function to test for multicast addresses that must not be forwarded.
Ben Pfaff [Mon, 5 Jan 2009 23:59:40 +0000 (15:59 -0800)]
New function to test for multicast addresses that must not be forwarded.

15 years agoAdd support for time_after64/time_before64 macros in older kernels.
Justin Pettit [Mon, 5 Jan 2009 07:47:13 +0000 (23:47 -0800)]
Add support for time_after64/time_before64 macros in older kernels.

15 years agovswitchd: Improve log options passed down to secchan.
Ben Pfaff [Sat, 3 Jan 2009 01:26:26 +0000 (17:26 -0800)]
vswitchd: Improve log options passed down to secchan.

Previously, secchan as started by vswitchd would always log to the console.
Now, it logs to the console only if any logging to the console is enabled
for vswitchd.

Previously, secchan as started by vswitchd would never log to a file.  Now,
it logs to a file if vswitchd is configured to do so.

Also, use the bridge name in the vlog log pattern, instead of the datapath
number, so that users can more easily relate log messages to bridges.

Requested by Keith.

15 years agovswitchd: Don't make and pass socketpair to secchan if we won't use it.
Ben Pfaff [Sat, 3 Jan 2009 00:39:59 +0000 (16:39 -0800)]
vswitchd: Don't make and pass socketpair to secchan if we won't use it.

If there's a remote controller then secchan will talk to it, not to
vswitchd, so there's no need to make a socketpair for communication in
that case.

15 years agoImprove compatibility fallbacks for allocating multicast groups.
Ben Pfaff [Sat, 3 Jan 2009 00:10:19 +0000 (16:10 -0800)]
Improve compatibility fallbacks for allocating multicast groups.

The linux-2.6 compatibility code for allocating multicast groups only
allocated a single multicast group per Generic Netlink family.  However,
OpenFlow performance is going to be better if we allocate one per OpenFlow
datapath (which are all in the same Generic Netlink family).  This commit
implements that.

Thanks to Justin for pointing out the issue.

15 years agoUse separate Netlink multicast groups for different datapaths.
Ben Pfaff [Sat, 3 Jan 2009 00:13:07 +0000 (16:13 -0800)]
Use separate Netlink multicast groups for different datapaths.

Otherwise every socket that listens for OpenFlow multicast messages will
get them for every single datapath.  Not only is that a waste of memory
and time, it also allows one congested bridge to effectively DoS other
bridges that have little traffic.

15 years agoMerge master branch into vswitchd.
Ben Pfaff [Sat, 3 Jan 2009 00:24:35 +0000 (16:24 -0800)]
Merge master branch into vswitchd.

15 years agoMake the openflow and brcompt modules use different netlink mc groups.
Justin Pettit [Fri, 2 Jan 2009 23:40:54 +0000 (15:40 -0800)]
Make the openflow and brcompt modules use different netlink mc groups.

15 years agoDiscard OpenFlow messages not for us in dpif_recv_openflow().
Ben Pfaff [Fri, 2 Jan 2009 21:58:08 +0000 (13:58 -0800)]
Discard OpenFlow messages not for us in dpif_recv_openflow().

Currently there is only a single Netlink multicast group that is shared
by all OpenFlow datapaths.  This is undesirable and should be fixed, but
a solution in every case is impossible due to Linux kernel limitations.
This commit works around the problem by dropping OpenFlow messages that
are related to a datapath that we are not interested in.

This should fix vswitchd behavior when more than one bridge is configured.

Thanks to Keith and Justin for diagnosing the problem.

15 years agoCorrect VERIFY_NUL_STRING back-port that required a "0" instead of a null.
Justin Pettit [Fri, 2 Jan 2009 19:04:21 +0000 (11:04 -0800)]
Correct VERIFY_NUL_STRING back-port that required a "0" instead of a null.

The VERIFY_NUL_STRING back-port to older kernels was looking for an ASCII
zero instead of the null-string terminator.

15 years agovswitchd: Add support for untagged VLAN ports in VLAN 0.
Ben Pfaff [Thu, 1 Jan 2009 22:42:10 +0000 (14:42 -0800)]
vswitchd: Add support for untagged VLAN ports in VLAN 0.

15 years agovswitchd: Change port mirroring to match semantics expected by users.
Ben Pfaff [Thu, 1 Jan 2009 22:33:32 +0000 (14:33 -0800)]
vswitchd: Change port mirroring to match semantics expected by users.

15 years agovswitchd: Support limiting the number of VLANs carried by a trunk port.
Ben Pfaff [Thu, 1 Jan 2009 01:23:21 +0000 (17:23 -0800)]
vswitchd: Support limiting the number of VLANs carried by a trunk port.

15 years agovswitchd: Minor code simplification.
Ben Pfaff [Thu, 1 Jan 2009 00:43:28 +0000 (16:43 -0800)]
vswitchd: Minor code simplification.

The 'vlan' argument is exactly what we want here.

15 years agobrcompat: Remove unneeded RCU locking.
Ben Pfaff [Thu, 1 Jan 2009 18:09:32 +0000 (10:09 -0800)]
brcompat: Remove unneeded RCU locking.

The only memory accessed here is in 'dev', which can't
disappear because we maintain a reference count on it.
net_devices aren't RCU-locked anyway.

15 years agobrcompat: Use ENOMEM to indicate out-of-memory (not EINVAL).
Ben Pfaff [Thu, 1 Jan 2009 18:08:28 +0000 (10:08 -0800)]
brcompat: Use ENOMEM to indicate out-of-memory (not EINVAL).

15 years agobrcompat: Mark variables "static".
Ben Pfaff [Thu, 1 Jan 2009 18:08:09 +0000 (10:08 -0800)]
brcompat: Mark variables "static".

15 years agoMinor style fixes.
Ben Pfaff [Thu, 1 Jan 2009 03:52:01 +0000 (19:52 -0800)]
Minor style fixes.

Thanks to Reid for pointing these out.

15 years agovswitchd: Prevent a single interface from being added to two different ports.
Ben Pfaff [Thu, 1 Jan 2009 00:13:33 +0000 (16:13 -0800)]
vswitchd: Prevent a single interface from being added to two different ports.

15 years agosecchan: Fix cut-and-paste errors in port speed determination.
Ben Pfaff [Wed, 31 Dec 2008 23:59:39 +0000 (15:59 -0800)]
secchan: Fix cut-and-paste errors in port speed determination.

15 years agovswitchd: Drop debug output that was accidentally included.
Ben Pfaff [Wed, 31 Dec 2008 23:38:56 +0000 (15:38 -0800)]
vswitchd: Drop debug output that was accidentally included.

15 years agovswitchd: Implement port mirroring.
Ben Pfaff [Wed, 31 Dec 2008 22:38:43 +0000 (14:38 -0800)]
vswitchd: Implement port mirroring.

15 years agoNew functions for parsing integers.
Ben Pfaff [Wed, 31 Dec 2008 22:34:13 +0000 (14:34 -0800)]
New functions for parsing integers.

15 years agoNew function svec_equal().
Ben Pfaff [Wed, 31 Dec 2008 22:33:47 +0000 (14:33 -0800)]
New function svec_equal().

15 years agoReturn meaningful errors for brctl modification commands.
Justin Pettit [Wed, 31 Dec 2008 18:55:13 +0000 (10:55 -0800)]
Return meaningful errors for brctl modification commands.

When datapaths and interfaces are modified, we now do more thorough
checks to see whether they will succeed or not.  When datapaths are
added, we now block until they are created, so that follow-on ioctl
calls to attach interfaces will immediately work.

15 years agoMake the datapath tolerate kernels that lack NLA_NUL_STRING.
Ben Pfaff [Wed, 31 Dec 2008 18:35:42 +0000 (10:35 -0800)]
Make the datapath tolerate kernels that lack NLA_NUL_STRING.

NLA_NUL_STRING was introduced in 2.6.19.

15 years agovswitchd: Be careful to sort all the svecs that are passed to svec_contains().
Ben Pfaff [Wed, 31 Dec 2008 17:56:20 +0000 (09:56 -0800)]
vswitchd: Be careful to sort all the svecs that are passed to svec_contains().

15 years agoAdd support for "brctl show".
Justin Pettit [Wed, 31 Dec 2008 06:31:38 +0000 (22:31 -0800)]
Add support for "brctl show".

This makes datapaths and their interfaces show up as you'd expect when
"brctl show" is run.  To get this functionality, you must insmod the
brcompat kernel module.

15 years agovswitchd: Fix fd leaks by closing files that we read in read_file().
Ben Pfaff [Wed, 31 Dec 2008 00:06:06 +0000 (16:06 -0800)]
vswitchd: Fix fd leaks by closing files that we read in read_file().

Fixes bug #697.

Thanks to Martin for reporting this bug.

15 years agovswitchd: Add support for remote controller.
Ben Pfaff [Wed, 31 Dec 2008 00:02:17 +0000 (16:02 -0800)]
vswitchd: Add support for remote controller.

15 years agoFix bug in make_add_simple_flow() that busts secchan's in-band control.
Ben Pfaff [Tue, 30 Dec 2008 23:26:33 +0000 (15:26 -0800)]
Fix bug in make_add_simple_flow() that busts secchan's in-band control.

15 years agovswitchd: Don't try to delete local port from datapath.
Ben Pfaff [Tue, 30 Dec 2008 21:53:18 +0000 (13:53 -0800)]
vswitchd: Don't try to delete local port from datapath.

The local port (OFFP_LOCAL) is fixed in place and can't be deleted, so
don't try.

15 years agobrcompat: Remove line-length limitations from brc_modify_config().
Ben Pfaff [Tue, 30 Dec 2008 21:40:10 +0000 (13:40 -0800)]
brcompat: Remove line-length limitations from brc_modify_config().

15 years agobrcompat: Write temporary file to same directory as config file.
Ben Pfaff [Tue, 30 Dec 2008 21:25:35 +0000 (13:25 -0800)]
brcompat: Write temporary file to same directory as config file.

Otherwise, we will write it in the current working directory, which will
be / if we're running as a daemon (see daemonize()).  We shouldn't assume
that we can write to that directory, and it might not be in the same
file system as the output file anyhow.

15 years agoNew function nl_sock_wait(), to improve netlink socket abstraction.
Ben Pfaff [Tue, 30 Dec 2008 21:12:48 +0000 (13:12 -0800)]
New function nl_sock_wait(), to improve netlink socket abstraction.

15 years agoProperly lock dp_mutex around changes to the datapath.
Ben Pfaff [Tue, 30 Dec 2008 21:03:48 +0000 (13:03 -0800)]
Properly lock dp_mutex around changes to the datapath.

We weren't locking dp_mutex() here but it really is necessary.  See the
comment on dp_mutex itself for details.

This actually restores some of the locking removed by commit 47b8652d
"Simplify use of dp_mutex."  That commit is correct that we can take
dp_mutex at a high level in dp_genl_openflow(), but it removes locking
from functions that are not called through dp_genl_openflow(): in
particular any Netlink command other than DP_GENL_C_OPENFLOW does not
go through that function, so those commands need to acquire the mutex
themselves.

15 years agobrcompat: Fix usage message.
Ben Pfaff [Tue, 30 Dec 2008 20:50:02 +0000 (12:50 -0800)]
brcompat: Fix usage message.

--brcompat isn't required and doesn't substitute for --config, so put it
in a different section.

15 years agobrcompat: Add note about required kernel module to vswitchd manpage.
Ben Pfaff [Tue, 30 Dec 2008 20:49:23 +0000 (12:49 -0800)]
brcompat: Add note about required kernel module to vswitchd manpage.

15 years agoSimplify lookup_dp() now that we can assume that dp_name is null-terminated.
Ben Pfaff [Tue, 30 Dec 2008 20:40:11 +0000 (12:40 -0800)]
Simplify lookup_dp() now that we can assume that dp_name is null-terminated.

15 years agoForce DP_GENL_A_DP_NAME and DP_GENL_A_PORTNAME to be null-terminated.
Ben Pfaff [Tue, 30 Dec 2008 20:34:39 +0000 (12:34 -0800)]
Force DP_GENL_A_DP_NAME and DP_GENL_A_PORTNAME to be null-terminated.

The kernel doesn't check for a null terminator on strings in Netlink
attributes unless you force it to do so.

15 years agoFactor datapath common code into new function lookup_dp().
Ben Pfaff [Tue, 30 Dec 2008 20:33:11 +0000 (12:33 -0800)]
Factor datapath common code into new function lookup_dp().

15 years agoFix GNU make warning about overriding commands for a target.
Ben Pfaff [Tue, 30 Dec 2008 19:40:22 +0000 (11:40 -0800)]
Fix GNU make warning about overriding commands for a target.

We would add a target to link a C file into datapath directories each
time that file was mentioned in a list of sources, so when we put a source
file into two different lists of sources it got two such targets.  Fixed
by using the GNU make $(sort) function to eliminate duplicates.

15 years agoUpdate dpif comments and prototypes.
Ben Pfaff [Tue, 30 Dec 2008 19:32:23 +0000 (11:32 -0800)]
Update dpif comments and prototypes.

Some of the comments weren't up-to-date, and the prototypes are easier
to understand if parameter names are included.

15 years agoRestore openflow-netlink.h ABI.
Ben Pfaff [Tue, 30 Dec 2008 19:31:25 +0000 (11:31 -0800)]
Restore openflow-netlink.h ABI.

Inserting DP_GENL_A_DP_NAME above DP_GENL_A_PORTNAME in commit
660f6596ba31, "First cut at bridge compatibility for vswitchd" forces users
not to use any existing builds of userspace utilities, because the
numbering of all the netlink attributes for OpenFlow has changed.  This
change restores the numbering and should make older dpctl, etc. still able
to work.

15 years agoUse rcu_dereference() before we dereference an RCU-protected pointer.
Ben Pfaff [Tue, 30 Dec 2008 19:23:36 +0000 (11:23 -0800)]
Use rcu_dereference() before we dereference an RCU-protected pointer.

The access to dps[i]->netdev->name is a dereference that should be
protected by rcu_dereference().

15 years agoFix off-by-one error in looking up datapaths by index.
Ben Pfaff [Tue, 30 Dec 2008 18:48:59 +0000 (10:48 -0800)]
Fix off-by-one error in looking up datapaths by index.

15 years agoFix missing symbol in brcompat kernel module on older kernels.
Justin Pettit [Tue, 30 Dec 2008 19:23:34 +0000 (11:23 -0800)]
Fix missing symbol in brcompat kernel module on older kernels.

In kernels older than 2.6.23, the genl_register_mc_group function is not
defined, so we fake it.  The original checkin didn't build the C file
that contains the function's definition.

15 years agoIncrease max datapaths to 256 (Bug #561).
Justin Pettit [Tue, 30 Dec 2008 18:55:33 +0000 (10:55 -0800)]
Increase max datapaths to 256 (Bug #561).

Increase the maximum number of datapaths from 32 to 256.  This ought to
be enough for anyone.

15 years agobrcompat: Build brcompat module only under Linux 2.6.
Ben Pfaff [Tue, 30 Dec 2008 18:26:03 +0000 (10:26 -0800)]
brcompat: Build brcompat module only under Linux 2.6.

brcompat fails to compile under Linux 2.4 due to the lack of brioctl_set()
and other symbols, but there's no intention of supporting Linux 2.4 for it
anyhow, so don't build it under Linux 2.4.

15 years agobrcompat: Remove policy from Netlink code.
Ben Pfaff [Tue, 30 Dec 2008 18:25:50 +0000 (10:25 -0800)]
brcompat: Remove policy from Netlink code.

Policies are only useful for data that is received by a Netlink socket.
They do not apply to data that is sent out.  Since this code does not
parse the messages that it receives at all, it does not need any policy.

15 years agobrcompat: Fix typo in user message.
Ben Pfaff [Tue, 30 Dec 2008 18:25:38 +0000 (10:25 -0800)]
brcompat: Fix typo in user message.

15 years agobrcompat: Indentation fixups.
Ben Pfaff [Tue, 30 Dec 2008 18:25:29 +0000 (10:25 -0800)]
brcompat: Indentation fixups.

In a few places four spaces were used in place of one tab. Elsewhere,
function arguments weren't lined up well.

15 years agoMake datapath compile with Xen kernel.
Ben Pfaff [Tue, 30 Dec 2008 18:01:06 +0000 (10:01 -0800)]
Make datapath compile with Xen kernel.

The Xen kernel is based on 2.6.18 but backports many features from later
kernels.  It is not always possible, therefore, to detect whether we need
to use compatibility code based on LINUX_VERSION_CODE.  This commit fixes
the problem by using configure-time tests to check for the need for the
compatibility code.

Build-tested on Linux 2.6.15 through 2.6.28 with the default configuration
(except that some kernels needed preemption turned off) and with Xen
kernel 2.6.18-92.1.10.el5.xs5.0.0.394.644.

Fixes bug #548.

15 years agoFirst cut at bridge compatibility for vswitchd.
Justin Pettit [Tue, 30 Dec 2008 06:53:08 +0000 (22:53 -0800)]
First cut at bridge compatibility for vswitchd.

This set of changes allows the bridge ioctls to be used for adding and
removing datapaths and interfaces.  To enable, one must insmod the
new "brcompat_mod.ko" kernel module.  Then, vswitchd is run with the
"--brcompat" flag.  See the man page for vswitchd for more details.

15 years agovswitchd: Fix SIGHUP behavior for bonded ports.
Ben Pfaff [Tue, 30 Dec 2008 00:17:09 +0000 (16:17 -0800)]
vswitchd: Fix SIGHUP behavior for bonded ports.

15 years agovswitchd: Properly renumber port_ifidx values on iface destruction.
Ben Pfaff [Tue, 30 Dec 2008 00:01:46 +0000 (16:01 -0800)]
vswitchd: Properly renumber port_ifidx values on iface destruction.

15 years agovswitchd: Revalidate all flows upon bridge configuration change.
Ben Pfaff [Tue, 30 Dec 2008 00:01:16 +0000 (16:01 -0800)]
vswitchd: Revalidate all flows upon bridge configuration change.

Otherwise, now-invalid flows can linger, causing trouble.

15 years agoNew function mac_learning_flush().
Ben Pfaff [Mon, 29 Dec 2008 23:55:54 +0000 (15:55 -0800)]
New function mac_learning_flush().

15 years agovswitchd: Fix svec_diff().
Ben Pfaff [Mon, 29 Dec 2008 22:29:26 +0000 (14:29 -0800)]
vswitchd: Fix svec_diff().

The logic bugs here were causing bridge.c to do too much work adding and
deleting interfaces unnecessarily and perhaps in some circumstances getting
the set of interfaces wrong entirely.

15 years agovswitchd: Comment out annoying bonding-related logging, for now.
Ben Pfaff [Mon, 29 Dec 2008 23:59:48 +0000 (15:59 -0800)]
vswitchd: Comment out annoying bonding-related logging, for now.

15 years agovswitchd: Fix svec memory leaks.
Ben Pfaff [Mon, 29 Dec 2008 21:30:48 +0000 (13:30 -0800)]
vswitchd: Fix svec memory leaks.

Pointed out by Justin.

15 years agoMake ds_cstr() always null-terminate the string.
Ben Pfaff [Mon, 29 Dec 2008 21:26:19 +0000 (13:26 -0800)]
Make ds_cstr() always null-terminate the string.

Most of the time the string in "struct ds" is
null-terminated, but there seem to be a few corner cases
where it is not.  Make ds_cstr() always put in the null
terminator, for safety.

Thanks to Justin for pointing out the problem.

15 years agovswitchd: Implement bonding link failure detection & failover.
Ben Pfaff [Mon, 29 Dec 2008 21:07:09 +0000 (13:07 -0800)]
vswitchd: Implement bonding link failure detection & failover.

15 years agoNew functions port_array_destroy(), port_array_clear().
Ben Pfaff [Mon, 29 Dec 2008 21:06:56 +0000 (13:06 -0800)]
New functions port_array_destroy(), port_array_clear().