2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-24 02:47:14 +00:00

221 Commits

Author SHA1 Message Date
Ben Pfaff
4b60911067 netdev: Factor restoring flags into new "struct netdev_saved_flags".
This gets rid of the only per-instance data in "struct netdev", which
will make it possible to merge "struct netdev_dev" into "struct netdev" in
a later commit.

Ed Maste wrote the netdev-bsd changes in this commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ed Maste <emaste@freebsd.org>
Tested-by: Ed Maste <emaste@freebsd.org>
2013-05-10 11:24:07 -07:00
Ben Pfaff
559eb2308b netdev-linux: Mark more static data as "const".
This makes this code more obviously thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-03 13:29:47 -07:00
Ben Pfaff
c4c7a3d7a1 netdev-linux: Fix netdev_linux_send() return value in corner case.
A negative 'sock' means there was an error but netdev_linux_send() returns
a positive errno value on error.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-02-28 10:40:57 -08:00
Ben Pfaff
8450059ee8 netdev-linux: Check return value of set_nonblocking().
It's unlikely to fail but checking it can't hurt.

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-02-01 14:27:03 -08:00
Ethan Jackson
c060c4cf83 netdev-vport: Build on all platforms.
This patch removes the final bit of linux specific code which
prevents building netdev-vport everywhere.  With this, other
platforms automatically get access to patch ports, and (if their
datapath supports it), flow based tunneling.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2013-01-28 19:09:58 -08:00
Thomas Graf
e5c0801582 linux: Increase accuracy of ingress_policing_rate at low rates
The current method of calculating the ingress policer rate
can lead to inaccuracy if ingress_policing_rate is set to
a smallish values because the rate is divided by 8 first
which causes rounding errors.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-01-25 15:25:21 -08:00
Ben Pfaff
cb22974d77 Replace most uses of assert by ovs_assert.
This is a straight search-and-replace, except that I also removed #include
<assert.h> from each file where there were no assert calls left.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-01-16 16:03:37 -08:00
Ethan Jackson
f431bf7d78 netdev: Parse and make available tunnel configuration.
Future patches will need to know the details of a netdev's tunnel
configuration from outside the netdev library.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2013-01-15 16:21:09 -08:00
Ethan Jackson
275707c33f netdev: Rename get_drv_info() to get_status().
get_status() is a much more intuitive name since "status" is what
the database column is called.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2013-01-03 16:55:43 -08:00
Ethan Jackson
2f31a8229e netdev-vport: Remove set_stats() implementation.
The only user of netdev_set_stats() is bonding (for updating the
fake interface).  This interface is never a vport, so it seems
quite a bit cleaner to keep the relevant code in the netdev-linux
library where it's needed, instead of in netdev-vport, where it
adds needless complexity.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-12-26 13:01:33 -08:00
Ben Pfaff
ed36537ebf packets: Change IP_ARGS interface to take an ovs_be32 instead of a pointer.
An ovs_be32 is a more obvious way to represent an IP address than a
pointer to one.  It is also more type-safe, especially since "sparse" is
able to check that the argument is in network byte order.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2012-12-12 15:26:21 -08:00
Justin Pettit
33d82a56df netdev-linux: Use underlying tap device on netdev_linux_listen().
Commit acf608 (ofproto-dpif: Use a single underlying datapath across
multiple bridges.) broke connectivity to userspace datapath devices.
The code assumed the first caller to open a tap device with
netdev_linux_open() wanted to write to it.  This commit moves that logic
to when netdev_linux_listen() is called.

Thanks to Ben Pfaff for helping debug the issue.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Reported-by: Simon Horman <horms@verge.net.au>
Tested-by: Simon Horman <horms@verge.net.au>
2012-12-07 15:04:36 -08:00
Justin Pettit
bcb1f5a1fd netdev-linux: Don't log vport warnings when kernel datapath not loaded.
The *_get_stats functions call get_stats_via_vport(), which tries to get
information about ports attached to the kernel datapath.  When a pure
userspace switch is used (eg, the OVS kernel module isn't loaded), ports
are not attached to a kernel datapath, so warnings get logged.  This
commit handles that case and doesn't log a warning.  However, if the
kernel datapath is loaded, ports attached to a userspace datapath will
still log a warning.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-16 12:35:55 -08:00
Justin Pettit
7eb1bd8112 netdev-linux: "Down" tap devices before setting hw addr.
On Linux, it is not possible to set the mac address on "up" tap
interfaces.  This commit temporarily "down"s the interface so the
address can be set for the netdev_linux_set_etheraddr() call.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-16 12:35:55 -08:00
Ben Pfaff
d02a5f8ea4 ofproto: Report 0 Mbps when speed not available instead of 100 Mbps.
When a link is down, or when a link has no speed because it is not a
physical interface, Open vSwitch previously reported that its rate is 100
Mbps as a default.  This is counterintuitive, however, so this commit
changes Open vSwitch behavior to report 0 Mbps when a link is down or its
speed is otherwise unavailable.

Bug #13388.
Reported-by: Hiroshi Tanaka <htanaka@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-11-03 18:00:39 -07:00
Ben Pfaff
ebc56baa41 util: New macro CONST_CAST.
Casts are sometimes necessary.  One common reason that they are necessary
is for discarding a "const" qualifier.  However, this can impede
maintenance: if the type of the expression being cast changes, then the
presence of the cast can hide a necessary change in the code that does the
cast.  Using CONST_CAST, instead of a bare cast, makes these changes
visible.

Inspired by my own work elsewhere:
http://git.savannah.gnu.org/cgit/pspp.git/tree/src/libpspp/cast.h#n80

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-08-03 13:33:13 -07:00
Ben Pfaff
ab985a77bb netdev-linux: Break ethtool coverage counter into "get" and "set" versions.
Reads and writes have difference performance implications so it's better to
separate them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-21 08:00:08 -07:00
Ethan Jackson
79f1cbe9f8 lib: New data structure - smap.
A smap is a string to string hash map.  It has a cleaner interface
than shash's which were traditionally used for the same purpose.
This patch implements the data structure, and changes netdev and
its providers to use it.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-06-14 15:09:31 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc.

Feature #10593
Signed-off-by: Raju Subramanian <rsubramanian@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-02 17:08:02 -07:00
Mehak Mahajan
f125905cdd Allow configuring DSCP on controller and manager connections.
The changes allow the user to specify a separate dscp value for the
controller connection and the manager connection. The value will take
effect on resetting the connections. If no value is specified a default
value of 192 is chosen for each of the connections.

Feature #10074
Requested-by: Rajiv Ramanathan <rramanathan@nicira.com>
Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
2012-03-23 18:13:08 -07:00
Pravin B Shelar
2c2ea5a88a netdev: Rename netdev->get_status() to netdev->get_drv_info().
get_status actually returns driver information, so get_drv_info()
is better name.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-22 10:58:32 -07:00
Ben Pfaff
f486e8405a netdev-linux: Fix use-after-free when netdev_dump_queues() deletes queues.
iface_configure_qos() passes a callback to netdev_dump_queues() that can
delete queues.  The netdev-linux implementation of this function was
unprepared for the callback to delete queues, so this could cause a
use-after-free.  This fixes the problem in netdev_linux_dump_queues() and
documents that netdev_dump_queues() implementations must support deletions
in the callback.

Found by valgrind:

==1593== Invalid read of size 8
==1593==    at 0x4A8C43: netdev_linux_dump_queues (hmap.h:326)
==1593==    by 0x4305F7: bridge_reconfigure (bridge.c:3084)
==1593==    by 0x431384: bridge_run (bridge.c:1892)
==1593==    by 0x432749: main (ovs-vswitchd.c:96)
==1593==  Address 0x632e078 is 8 bytes inside a block of size 32 free'd
==1593==    at 0x4C240FD: free (vg_replace_malloc.c:366)
==1593==    by 0x4A4D74: hfsc_class_delete (netdev-linux.c:3250)
==1593==    by 0x42AA59: iface_delete_queues (bridge.c:3055)
==1593==    by 0x4A8C8C: netdev_linux_dump_queues (netdev-linux.c:1881)
==1593==    by 0x4305F7: bridge_reconfigure (bridge.c:3084)
==1593==    by 0x431384: bridge_run (bridge.c:1892)

Bug #10164.
Reported-by: Ram Jothikumar <ram@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-19 13:48:24 -07:00
Ethan Jackson
a00ca915ff netdev: Consistently use 'enum netdev_features'.
Without this patch sparse gives me warnings.  At any rate, it's
cleaner to be consistent.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-09 13:58:03 -08:00
Pravin B Shelar
c7b1b0a535 netdev-linux: Cache error code from do_get_ifindex().
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-09 13:00:29 -08:00
Pravin B Shelar
51f8745865 netdev-linux: Cache error code from get-features.
Following patch adds support for caching error code from ETHTOOL_GSET
call. Since internal device is virtual device device feature does not
make much sense, so netdev_get_features op is removed for internal
devices.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-09 12:59:58 -08:00
Pravin B Shelar
c9f716683d netdev-linux: Cache error code from set-policing.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-09 12:59:27 -08:00
Pravin B Shelar
44445cac40 netdev-linux: Cache error code from ether-addr ioctl.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-09 12:58:10 -08:00
Pravin B Shelar
90a6637d5e netdev-linux: Cache error code from mtu ioctl.
netdev linux devices uses mtu ioctl to get and set MTU for a device.
By caching error code from ioctl we can reduce number of ioctl calls
for device which is unregistered from system.
netdev notification is used to update mtu which saves get-mtu-ioctl.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-09 12:57:48 -08:00
Pravin B Shelar
4f925bd39b netdev-linux: Cache drv-info for net device.
Netdev-linux calls ETHTOOL_GDRVINFO on every netdev_linux_get_status()
which is not optimal as drv-info does not change for given device.
So following patch changes netdev_linux_get_status() to read drv-info at
device initialization and cache it.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-09 12:57:13 -08:00
Ben Pfaff
8e8cddf794 netdev-linux: Use "read", not "recv", for tap devices.
"recv" only works for sockets, but tap devices aren't sockets.

Makes the userspace switch work again.

Reported-by: Ravi Kerur <Ravi.Kerur@telekom.com>
Reported-by: 胡靖飞 <hujingfei914@msn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-08 14:28:24 -08:00
Ben Pfaff
2a529ead2a netdev-linux: Fix build failure with old kernel headers.
The "speed_hi" member was only introduced in 2.6.27, so builds against
older kernel headers failed.

speed_hi is fully backward compatible with older kernels, because older
kernels always set it to 0, so we could easily introduce a compatibility
layer here, but in fact I don't know of any OVS users who have interfaces
faster than 65.5 Gb/s, so it's hardly urgent.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 15:48:00 -08:00
Ben Pfaff
6c0386119d netdev: Abstract "features" interface away from OpenFlow 1.0.
netdev_get_features() and other functions have always used OpenFlow 1.0
"enum ofp_port_features" bits as part of their interface.  This commit
switches over to using an internally defined interface that is not tied
directly to any OpenFlow version, making evolution of each side of the
interface easier in the future.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 14:05:09 -08:00
Pravin B Shelar
ac8c341227 netdev-linux: Make netdev_set_policing coverage counter consistent with other counters.
Most of coverage counters in netdev-linux are counting actual system
calls rather than reads from cached data.
Following patch fixes it by incrementing it after cache check.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-03-05 15:42:41 -08:00
Pravin B Shelar
bba1e6f3ac netdev-linux: Fix stats for ovs internal device.
There is no need to retrieve linux system stats for internal devices
as all relevant stats for virtual device like internal device are
already reported by OVS over vport-stats. As a result it also fixes
error stats for internal-devices as they are not counted twice.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-02-29 14:09:05 -08:00
Ben Pfaff
8aa77183a1 netdev-linux: Factor out duplicate ifi_flags update code.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-02-14 16:46:40 -08:00
Ethan Jackson
059e5f4fce netdev-linux: Use 'unsigned int's to track device flags.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-02-14 16:44:21 -08:00
Ethan Jackson
c37d4da4f0 netdev-linux: Cache flags using netlink.
Before this patch, every request for a 'netdev_dev''s flags
required an ioctl call.  This occurred every time
netdev_get_carrier() was called, which theoretically was very often
if there were a large number of devices.  We were already using
netlink to keep track of the IFF_RUNNING flag. This patch
generalizes the code to keep track of all flags using the same
netlink code.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-02-14 16:40:43 -08:00
Ethan Jackson
755be9ea9d netdev-linux: Get carrier from ioctl instead of sysfs.
When a netdev Linux device is created or its netlink cache is
invalidate, it needs an alternative method to update the its
carrier status.  Previous patches retrieved this information from a
sysfs file.  This patch switches to ioctl which is significantly
simpler, and likely quite a bit faster as well.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-02-14 16:40:43 -08:00
Pravin B Shelar
153e54814d netdev-linux: Add MTU check before setting MTU.
Following patch check if current MTU needs to be changed before
issuing set-mtu ioctl.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-01-25 15:44:26 -08:00
Ben Pfaff
0e15264f96 unixctl: Implement quoting.
The protocol used by ovs-appctl has a long-standing bug that there
is no way to distinguish "ovs-appctl a b c" from "ovs-appctl 'a b c'".
This isn't a big deal because none of the current commands really
want to accept arguments that include spaces, but it's kind of a silly
limitation.

At the same time, the internal API is awkward because every user is
stuck doing its own argument parsing, which is no fun.

This commit fixes both problems, by adding shell-like quoting to the
protocol and modifying the internal API from one that passes a string
to one that passes in an array of pre-parsed strings.  Command
implementations may now specify how many arguments they expect.  This
simplifies some command implementations significantly.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-12-19 14:53:34 -08:00
Ben Pfaff
02e83e83b4 netdev-linux: Report error for truncated packets on receive.
Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-12-19 14:53:28 -08:00
Ben Pfaff
a57a8488da netdev-linux: Translate errno value to name in log message.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-12-19 14:53:24 -08:00
Justin Pettit
f850000440 netdev-linux: Don't restrict policing to IPv4 and don't call "tc".
Mike Bursell pointed out that our policer only works on IPv4
traffic--and specifically not IPv6.  By using the "basic" filter, we can
enforce policing on all traffic for a particular interface.

Jamal Hadi Salim pointed out that calling "tc" directly with system() is
pretty ugly.  This commit switches our remaining "tc" calls to directly
sending the appropriate netlink messages.

Suggested-by: Mike Bursell <mike.bursell@citrix.com>
Suggested-by: Jamal Hadi Salim <hadi@cyberus.ca>
2011-12-05 14:08:06 -08:00
Ben Pfaff
1f6e0fbd81 netdev-linux: Ref and unref the netdev_linux_cache_notifier for taps too.
netdev-linux uses netdev_linux_cache_notifier to flush its cache when the
kernel notifies userspace that a particular network device's configuration
or status has changed.  This is as applicable to tap devices as to system
and internal devices, so we should create and destroy the notifier for
tap devices also.

I doubt that in practice it's possible to run ovs-vswitchd without having
a non-tap device open, at least with the kernel datapath, because the
local port for a bridge is not a tap device, so there should be no need to
backport this to older versions.

Reported-by: Gaetano Catalli <gaetano.catalli@gmail.com>
2011-12-02 10:39:07 -08:00
Ben Pfaff
025e874a9c vlandev: New library for working with Linux VLAN devices. 2011-11-23 15:32:36 -08:00
Ben Pfaff
aaf2fb1aac netdev-linux: Reorganize slightly. 2011-11-23 13:19:53 -08:00
Ben Pfaff
52e2fbfbab netdev: Remove netdev_get_vlan_vid().
It has no remaining users.
2011-11-23 13:19:53 -08:00
Ethan Jackson
65c3058c22 vswitchd: New column "link_resets".
An interface's 'link_resets' column represents the number of times
Open vSwitch has observed its link_state change.
2011-10-17 15:03:03 -07:00
Ethan Jackson
3a18312428 netdev-linux: Maintain carrier flag constantly.
Before this patch, the carrier of a linux device was only updated
if requested by a caller.  This patch updates it whenever it
changes.
2011-10-17 15:03:03 -07:00
Ben Pfaff
bb7d0e2287 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.
2011-09-22 11:54:22 -07:00