2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-17 14:28:02 +00:00
Commit Graph

1923 Commits

Author SHA1 Message Date
Ben Pfaff
f1588b1fa1 datapath: Remove implementation of port groups.
The "port group" concept seems like a good one, but it has not been
used very much in userspace so far, so before we commit ourselves to
a frozen API that we must maintain forever, remove it.  We can always
add it back in later as a new kind of vport.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2010-10-11 12:40:11 -07:00
Ben Pfaff
2b9d658984 netdev-vport: Merge in netdev-patch and netdev-tunnel.
The only real difference between netdev-patch and netdev-tunnel is in their
parse_config() implementation.  That's a lot of extra code to maintain, for
questionable benefit.  This commit merges them into the netdev-vport code,
which was heretofore merely a collection of helper functions.
2010-10-11 12:40:11 -07:00
Ben Pfaff
0bb5c3ec4d ofproto: Get rid of port_changed_cb.
Jesse pointed out that port_changed_cb isn't a great interface.  It's only
around because, earlier, we had a lousy interface for monitoring netdev
status, so that we needed to pass along information obtained by ofproto
into the bridge.  But netdev_monitor is now sufficiently sophisticated that
the bridge can set up an independent netdev_monitor without any important
loss of efficiency.  Since this makes the code cleaner, this commit does
so.
2010-10-11 10:40:05 -07:00
Ben Pfaff
784032d000 vswitchd: Better tolerate changes in datapath ports.
Until now, a command that removed and added ports in a single change to
the database, e.g.:
	ovs-vsctl del-port br0 vif1.0 -- add-port br0 vif2.0
typically failed, because of this sequence of events:

1. Bridge code removes vif1.0 from br0.
2. Bridge code adds vif2.0 to br0.
3. ofproto_run() receives kernel notification that vif1.0 was deleted, so
   it notifies the bridge by calling back to bridge_port_changed_ofhook_cb,
   which sees that it has an interface with the specified port number, and
   deletes it.  Oops--this is where the problem occurs.  For completeness:
4. ofproto_run() receives kernel notification that vif2.0 was added, so
   it notifies the bridge by calling back to ,
   which sees that it has no interface with the specified port number, and
   does nothing.

This commit fixes the problem by making bridge_port_changed_ofhook_cb() not
care about ports being dropped.  This is a corner case that we shouldn't
work too hard to care about, since it can only happen if an administrator
is meddling with datapaths using ovs-dpctl, and the consequences are simply
that packets directed to that device will take longer to be rerouted to
another device (it will take a while for the MAC learning table to time out
the entry).  Basically, the admin gets what he deserves.

Thanks to Jesse Gross for identifying the problem.

Bug #3671.
2010-10-11 10:40:05 -07:00
Ben Pfaff
64d64dd7bb vswitchd: Only try to open netdev once.
The previous commit arranged to always open the netdev for bridge ports
within the loop that adds new ports to datapaths.  So now the additional
attempt to open them within the following loop is superfluous and
presumably will always fail.  This commit drops it and merges two
iterations through bridge ports into a single one, since the first is now
trivial.
2010-10-11 10:40:05 -07:00
Ben Pfaff
3a6ccc8c00 vswitchd: Support changing the type of a bridge port.
Until now, if the type of a bridge port changed in the database, then
ovs-vswitchd would report an error and keep it the same type.  This commit
changes the behavior to something more reasonable: the old datapath port is
deleted and replaced by a new datapath port of the correct type.
2010-10-11 10:40:05 -07:00
Ben Pfaff
6cefe1da77 vswitchd: Make type of interface easier to determine.
Suggested-by: Jesse Gross <jesse@nicira.com>
2010-10-11 10:40:05 -07:00
Ben Pfaff
82057f5137 vswitchd: Create all interfaces at the same time.
It seems inconsistent to create some early, some late.  I hope that
this helps to clarify what is happening.
2010-10-11 10:40:05 -07:00
Ben Pfaff
43776b8fa5 vswitchd: Break set_up_iface() into two different functions.
set_up_iface() had two only loosely related purposes.  It's cleaner to use
two separate functions.
2010-10-11 10:40:05 -07:00
Ben Pfaff
75ae71da6b vswitchd: Drop redundant 'iface_cfg' parameter to set_up_iface().
iface_cfg is also available as iface->cfg, so there's no benefit in also
passing it as a separate parameter.

Also, get rid of the one-liner reconfigure_iface() function that wasn't
helping with anything.
2010-10-11 10:40:05 -07:00
Jesse Gross
17a07f9f9d tunneling: Internal dev vport can be NULL.
Commit 4bee42 "tunnel: Correctly check for internal device." fixed
the call to internal_dev_get_vport() by first checking that the
device is in fact an internal device.  However, it also accidentally
removed the check ensuring that the vport itself was not NULL.  This
adds that check back by redoing the previous change in a more robust
manner.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2010-10-08 15:43:38 -07:00
Justin Pettit
da3827b551 netdev: Enforce a floor "linux-htb" min-rate 2010-10-08 14:30:31 -07:00
Justin Pettit
015c93a49a netdev: Don't divide by zero when "linux-htb" zero min-rate is used
A "min-rate" of zero for the "linux-htb" QoS type would cause a divide
by zero exception.  This patch prevents that by just returning zero.  A
later patch will try to enforce reasonable values for "min-rate".

Bug #3745
2010-10-08 14:22:36 -07:00
Justin Pettit
5db39d100c classifier: Add missing argument in CLASSIFIER_FOR_EACH_EXACT_RULE_SAFE
The CLASSIFIER_FOR_EACH_EXACT_RULE_SAFE macro was missing its "MEMBER"
argument.  It doesn't currently cause any problems because no one uses
the macro.
2010-10-08 11:19:02 -07:00
Justin Pettit
c5cd8b2ef1 ovs-openflowd: Don't segfault when no controllers specified
If no controllers are specified on the command-line, ovs-openflowd adds
a couple of its own.  The code that accounts for the controllers
correctly allocated space for them, but used the command-line count to
determine how many to set.  This led to a segfault when later code tried
to dereference them.

Reported-by: Derek Cormier <derek.cormier@lab.ntt.co.jp>
2010-10-07 23:51:02 -07:00
Ben Pfaff
0de7a4b484 ofproto: Drop flows from datapath more quickly under heavy load.
In normal operation it makes sense to keep track of all of the flows that
have been seen recently and to cache all of them in the kernel.  Under
unusual conditions, such as those caused by network scanning tools or by an
actual targeted DoS attack against the vswitch, the number of flows can
explode to extremely high numbers (hundreds of thousands or more).  In such
a situation the vswitch needs to guard against memory exhaustion by
expiring flows more quickly and more often.  This commit implements an
inexpensive technique for determining which flows should be dropped in such
a situation.
2010-10-07 16:44:32 -07:00
Ben Pfaff
35950f0cfa classifier: Introduce macros for iterating exact-match flows.
This special case of iterating through flows is easier and presumably
faster to implement using a macro.
2010-10-07 10:36:02 -07:00
Ben Pfaff
da89bf9eb7 ofproto: Iterate through exact-match rules first during expiration.
A wildcarded flow is idle only if all of its subrules have expired because
they were idle, so unless we expire exact-match rules first it is possible
that a wildcarded flow fails to expire as soon as it should.

(The current implementation of classifier_for_each() iterates through
exact-match rules before wildcarded rules, but nothing in the interface
guarantees that.)
2010-10-07 10:30:54 -07:00
Ben Pfaff
8497dd4121 ofproto: Drop unneeded poll_immediate_wake().
This poll_immediate_wake() is unnecessary because netflow_run() is always
called afterward within the same poll loop.  It's better to delete it, to
avoid wasting CPU.
2010-10-07 10:30:54 -07:00
Ben Pfaff
431d470740 ofproto: Fix effective memory leak for uninstallable flows.
In one or two corner cases, flows cannot be installed because every packet
in the flow must be processed by userspace.  The code to expire rules was
ignoring these uninstallable rules, and thus they would never get freed,
even after they became idle.  This commit fixes the problem.
2010-10-07 10:30:54 -07:00
Ben Pfaff
3b58761604 ofproto: Factor conditional out of loop in send_flow_removed(). 2010-10-07 10:30:54 -07:00
Ben Pfaff
4a4cdb3b24 ofproto: Group functions related to flow expiration together.
This should be a purely stylistic change, with no effect on behavior.

This commit changes the callback pointer passed to the
classifier_for_each() from a pointer to an ofproto to a pointer to a
structure that includes an ofproto.  Future commits planned will add
more members to this new structure.
2010-10-06 14:39:56 -07:00
Ben Pfaff
3dffcf0701 ofproto: Avoid wasting memory malloc()'ing empty action sets for subrules.
GNU libc treats malloc(0) as malloc(1).  Subrules always have an n_actions
of 0, so this code was wasting time and memory for subrules.  This commit
stops doing that.

Also audits and fixes some very pedantic potential problems with null
pointers; e.g. the C standard says that NULL may not be compared with the
< operator, even if both arguments are null, and it also says that a null
pointer may not be passed to memcpy() or memcmp(), even if the length is
zero.
2010-10-06 14:21:47 -07:00
Ben Pfaff
b8dcf5e9c5 netdev: Pass class structure, instead of type, to "create" function.
This opens up the possibility of storing private data at a relative offset
to the class structure, instead of having to keep a separate table.
2010-10-06 13:49:07 -07:00
Ben Pfaff
6fcfff1b11 netdev-vport: Fix typo in comment.
Must have been a stray s/gre/patch/ in this file's history.
2010-10-06 13:45:55 -07:00
Jesse Gross
668aedc070 datapath: Force our include directory to be first.
XenServer puts our header files in the standard system search path
by default.  This is normally OK, except when we introduce new things
which aren't in those headers.  Since the system picks up the older files
first this leads to undefined sysmbols.

Signed-off-by: Jesse Gross <jesse@nicira.com>
2010-10-05 18:12:05 -07:00
Ethan Jackson
7ed7b619e3 xenserver: ovs-external-ids log to file instead of syslog
ovs-external-ids was crashing on startup because it was brought up
before /dev/log exists.  The simplest solution to this problem is
to have it log to /var/log/openvswitch/ovs-external-ids.log .  This
is consistent with vswitchd and ovsdb-server.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2010-10-05 01:12:56 +00:00
Jesse Gross
4bee421f3a tunnel: Correctly check for internal device.
With header caching we check to see if the next device in the stack
is an OVS device and, if so, cache that flow as well.  However, the
test for this called internal_dev_get_vport() assuming that it would
return NULL if the device is not an internal device.  It doesn't,
however, it just returns the offset from the device where the vport
data structure would be if it were an internal device.  This changes
it to explicitly check for an internal device first to avoid a panic.

Bug #3470

Reported-by: Ram Jothikumar <rjothikumar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Reviewed-by: Justin Pettit <jpettit@nicira.com>
2010-10-04 16:31:31 -07:00
Justin Pettit
eedc0097f4 Add Nicira extension for modifying queue without transmitting
The OpenFlow OFPAT_ENQUEUE action sets a queue id and outputs the packet
in one shot.  There are times in which the queue should be set, but the
output port is not yet known.  This commit adds the NXAST_SET_QUEUE and
NXAST_POP_QUEUE Nicira extension actions to modify the queue
configuration without requiring a port argument.

CC: Jeremy Stribling <strib@nicira.com>
CC: Keith Amidon <keith@nicira.com>
2010-10-02 18:36:10 -07:00
Ben Pfaff
9ebc44ae8c netflow: Avoid (theoretically) looping 2**32 times.
If the netflow byte counter is UINT64_MAX, or at any rate much larger than
UINT32_MAX, netflow_expire() could loop for a very long time.  This commit
avoids that case.

This is only a theoretical bug fix.  I don't know of any actual bug that
would cause a counter to be that high.
2010-10-01 14:31:48 -07:00
Ben Pfaff
48f846e66e netflow: Do 64-bit division less often.
64-bit division is expensive.  Usually we can avoid it entirely, as done by
this patch.
2010-10-01 14:31:48 -07:00
Ben Pfaff
8b055d9253 INSTALL.Linux: Describe how to upgrade the Open vSwitch database.
Suggested-by: Parham Kiani <pkiani@essex.ac.uk>
2010-10-01 13:51:54 -07:00
Ben Pfaff
d4cdc6b4c4 ovs-controller: Improve QoS abilities.
This makes it a little easier to test Open vSwitch QoS features using
ovs-controller, by making it possible to assign queues on the basis of
input port, instead of just allowing a single queue for a whole switch.

CC: Michael Mao <mmao@nicira.com>
2010-10-01 13:41:40 -07:00
Ben Pfaff
ad67e56888 learning-switch: Introduce struct for configuration.
This should make extensions easier.
2010-10-01 13:09:05 -07:00
Ben Pfaff
09913dfd25 ovs-controller: Make --with-flows read the file only once, at startup.
A couple of people have reported that ovs-controller --with-flows is
confusing.  This seems to be because it doesn't read the file with the
flows until the first connection from a switch.  Then, if the file has a
syntax error, it exits.

This commit changes the behavior so that it reads the file immediately at
startup instead.
2010-10-01 13:09:05 -07:00
Ben Pfaff
0e581146fe ofp-parse: Add test. 2010-10-01 13:09:05 -07:00
Ben Pfaff
3ff4f87161 ofp-print: Make output easier to read. 2010-10-01 13:09:05 -07:00
Ben Pfaff
15f1f1b63a ofp-parse: Factor out duplicated code into new functions. 2010-10-01 13:08:33 -07:00
Ben Pfaff
bb98f9b951 ofp-parse: Properly byteswap in_port. 2010-10-01 13:08:33 -07:00
Ben Pfaff
1ac788f67f ofproto: Only dump queue statistics if the queue really exists.
Without this commit, "ovs-ofctl queue-stats br0 ALL 1" will print something
like the following if port 3 has queue 1 but none of the other ports do:

    stats_reply (xid=0x7b378): flags=none type=5(queue)
     4 queues
      port 0 queue 1: bytes=?, pkts=?, errors=?
      port 1 queue 1: bytes=?, pkts=?, errors=?
      port 2 queue 1: bytes=?, pkts=?, errors=?
      port 3 queue 1: bytes=0, pkts=0, errors=0

With this commit, it will print the following instead, which seems more
useful:

   stats_reply (xid=0x3ada1): flags=none type=5(queue)
    1 queues
     port 3 queue 1: bytes=0, pkts=0, errors=0
2010-10-01 10:40:01 -07:00
Ben Pfaff
d5590e7e41 netdev-linux: Fix off-by-one error dumping queue stats.
Linux kernel queue numbers are one greater than OpenFlow queue numbers, for
HTB anyhow.  The code to dump queues wasn't compensating for this, so this
commit fixes it up.
2010-10-01 10:40:00 -07:00
Ben Pfaff
d2805da2cb ovs-ofctl: Add "queue-stats" command to print queue stats. 2010-10-01 10:40:00 -07:00
Ben Pfaff
4e8e4213a8 Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.
These macros require one fewer argument by switching, which makes code
that uses them shorter and more readable.
2010-10-01 10:25:29 -07:00
Ben Pfaff
adf7cfd851 util: New macro OBJECT_CONTAINING.
This macro is a variant on CONTAINER_OF that takes an object pointer
instead of a type name as its second argument.  In the following commit
this will simplify many users of CONTAINER_OF.
2010-10-01 10:25:10 -07:00
Ben Pfaff
ca0f572cfe ofproto: Use hash table instead of sparse array for ofports.
The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.
2010-10-01 10:25:10 -07:00
Ben Pfaff
0cc96e48ab sflow: Use hash table instead of sparse array for sflow ports.
The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.
2010-10-01 10:25:10 -07:00
Ben Pfaff
d9a8717a00 bridge: Use hash table instead of sparse array for bridge ports.
The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.
2010-10-01 10:25:10 -07:00
Ben Pfaff
f309964762 hmap: New function hmap_clear(). 2010-10-01 10:25:10 -07:00
Ben Pfaff
93b13be8e6 netdev-linux: Use hash table instead of sparse array for QoS classes.
The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.
2010-10-01 10:25:10 -07:00
Ben Pfaff
0c18b5a065 ovs-vsctl: Reduce log level for "Called as..." for read-only invocations.
When ovs-vsctl is not actually going to modify the database, it is less
interesting in the log, so we might as well only log it at "debug" level.

Suggested-by: Neil McKee <neil.mckee@inmon.com>
2010-10-01 10:22:03 -07:00