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

57 Commits

Author SHA1 Message Date
Daniele Di Proietto
910885540a dpif-netdev: use dpif_packet structure for packets
This commit introduces a new data structure used for receiving packets from
netdevs and passing them to dpifs.
The purpose of this change is to allow storing some private data for each
packet. The subsequent commits make use of it.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2014-06-23 14:41:12 -07:00
Ben Pfaff
e5e4b47cc2 Fix log message weird suffixes.
I think these were leftovers from the removal of %z for MSVC that happened
some time ago.

VMware-BZ: 1265762
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Pritesh Kothari <pritesh.kothari@cisco.com>
2014-06-11 09:14:54 -07:00
YAMAMOTO Takashi
5ae76b41cb netdev-bsd: Fix a whitespace
Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
2014-05-21 15:21:24 +09:00
YAMAMOTO Takashi
e4b997e319 netdev-bsd: Sprinkle ALIGNED_CAST where appropriate
Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
2014-05-05 08:36:24 +09:00
Alex Wang
3e912ffcbb netdev: Add 'change_seq' back to netdev.
This commit can be seen as a partial revert of commit
da4a619179d (netdev: Globally track port status changes)
by adding the 'change_seq' to 'struct netdev'.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-04-10 12:55:28 -07:00
YAMAMOTO Takashi
671a7fdff8 netdev-bsd: Update for recent ofpbuf api changes
Leftovers from commit commit 1f317cb5.
("ofpbuf: Introduce access api for base, data and size.")

This fixes regressons introduced by commit 3f976e12.
("lib/ofpbuf: Rename private fields to discourage direct use.")

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
2014-04-10 13:47:54 +09:00
YAMAMOTO Takashi
a0cbddc04b netdev-bsd: compilation fixes
This fixes regressions from commit f7791740
("netdev: Rename netdev_rx to netdev_rxq")
and commit df1e5a3b.
("netdev: Extend rx_recv to pass multiple packets.")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-03-25 13:18:19 -07:00
Pravin
40d26f04b2 netdev: Send ofpbuf directly to netdev.
DPDK netdev need to access ofpbuf while sending buffer. Following
patch changes netdev_send accordingly.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@redhat.com>
2014-03-21 11:48:28 -07:00
Pravin
df1e5a3bc7 netdev: Extend rx_recv to pass multiple packets.
DPDK can receive multiple packets but current netdev API does
not allow that.  Following patch allows dpif-netdev receive batch
of packet in a rx_recv() call for any netdev port.  This will be
used by dpdk-netdev.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2014-03-21 11:48:28 -07:00
YAMAMOTO Takashi
7f542c09be netdev-bsd: Fix tx/rx stats for type=tap netdev
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-02-06 17:07:40 -08:00
Daniele Di Proietto
b681f93ff7 lib/netdev-bsd: simplify multiple struct definitions
Use a macro helper to initialize different netdev_*_class for bsd, like
in lib/netdev-linux.c
This helps adding other netdev types for bsd

Signed-off-by: Daniele Di Proietto <daniele.di.proietto@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-01-23 08:36:37 -08:00
Simon Horman
bfd3367b9e netdev_class: Pass a struct ofpbuf * to rx_recv()
Update the netdev_class so that struct ofpbuf * is passed to rx_recv()
to provide both the data and size of the data to read a packet into.

On success, update struct ofpbuf size inside netdev_class rx_recv
implementation and return 0. This moves logic from the caller.
On error a positive error code is returned, whereas previously
a negative error code was returned. This is a more common convention.

This patch should not have any behavioural changes.

This patch is in preparation for the netdev-linux variant of rx_recv()
making use of headroom in the struct ofpbuf * parameter to push a VLAN tag
obtained from auxdata.

Signed-off-by: Simon Horman <horms@verge.net.au>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2014-01-16 14:37:43 -08:00
YAMAMOTO Takashi
17d21c9ef0 netdev-bsd: remove an unused variable
this is a leftover of commit da4a6191.
("netdev: Globally track port status changes")

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-12-18 09:09:18 -08:00
Joe Stringer
da4a619179 netdev: Globally track port status changes
Previously, we tracked status changes for ofports on a per-device basis.
Each time in the main thread's loop, we would inspect every ofport
to determine whether the status had changed for corresponding devices.

This patch replaces the per-netdev change_seq with a global 'struct seq'
which tracks status change for all ports. In the average case where
ports are not constantly going up or down, this allows us to check the
sequence once per main loop and not poll any ports. In the worst case,
execution is expected to be similar to how it is currently.

In a test environment of 5000 internal ports and 50 tunnel ports with
bfd, this reduces average CPU usage of the main thread from about 40% to
about 35%.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-12-12 15:03:19 -08:00
Alin Serdean
34582733d9 Avoid printf type modifiers not supported by MSVC C runtime library.
The MSVC C library printf() implementation does not support the 'z', 't',
'j', or 'hh' format specifiers.  This commit changes the Open vSwitch code
to avoid those format specifiers, switching to standard macros from
<inttypes.h> where available and inventing new macros resembling them
where necessary.  It also updates CodingStyle to specify the macros' use
and adds a Makefile rule to report violations.

Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-25 23:38:59 -08:00
Alexandru Copot
7ba19d412a netdev: update IFF_LOOPBACK flag for linux and bsd devices
Signed-off-by: Alexandru Copot <alex.mihai.c@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-07 09:33:51 -07:00
YAMAMOTO Takashi
d8c5a1aee0 netdev-bsd: fix crashes
fix a regression added by commit 89454bf477d1dc95357792677ccbd4d483ab42d8.
"netdev: Fix deadlock when netdev_dump_queues() callback calls into netdev."

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-27 22:46:27 -07:00
Ben Pfaff
834d6cafe4 Use "error-checking" mutexes in place of other kinds wherever possible.
We've seen a number of deadlocks in the tree since thread safety was
introduced.  So far, all of these are self-deadlocks, that is, a single
thread acquiring a lock and then attempting to re-acquire the same lock
recursively.  When this has happened, the process simply hung, and it was
somewhat difficult to find the cause.

POSIX "error-checking" mutexes check for this specific problem (and
others).  This commit switches from other types of mutexes to
error-checking mutexes everywhere that we can, that is, everywhere that
we're not using recursive mutexes.  This ought to help find problems more
quickly in the future.

There might be performance advantages to other kinds of mutexes in some
cases.  However, the existing mutex type choices were just guesses, so I'd
rather go for easy detection of errors until we know that other mutex
types actually perform better in specific cases.  Also, I did a quick
microbenchmark of glibc mutex types on my host and found that the
error checking mutexes weren't any slower than the other types, at least
when the mutex is uncontended.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-08-20 13:40:02 -07:00
YAMAMOTO Takashi
7b6d4b2ac8 netdev-bsd: implement netdev_arp_lookup for NetBSD
Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-14 15:40:18 -07:00
YAMAMOTO Takashi
b72d8dc2da netdev-bsd: ioctl "cmd" is unsigned long, not int
Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-12 15:31:46 -07:00
Ben Pfaff
863838160e netdev: Make netdev access thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2013-08-09 21:34:02 -07:00
Ben Pfaff
9dc63482bb netdev: Adopt four-step alloc/construct/destruct/dealloc lifecycle.
This is the same lifecycle used in the ofproto provider interface.
Compared to the previous netdev provider interface, it has the
advantage that the netdev top layer can control when any given
netdev becomes visible to the outside world.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-09 21:21:38 -07:00
Ben Pfaff
996e5ae9e9 netdev-bsd: Make use of AF_LINK socket thread-safe in NetBSD.
Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
CC: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
2013-08-09 21:15:15 -07:00
Ben Pfaff
259e0b1ad1 netdev-linux, netdev-bsd: Make access to AF_INET socket thread-safe.
The only uses of 'af_inet_sock', in both drivers, were ioctls, so it seemed
like a good abstraction to write a function that just does such an ioctl,
and to factor out shared code into socket-util.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
2013-08-09 21:14:23 -07:00
Ben Pfaff
2f980d7417 netdev: Make netdev_get_devices() take a reference to each netdev.
This API change is necessary for thread safety, to be added in an upcoming
commit.  Otherwise, the client would not be able to actually use any of
the returned netdevs because they could already have been destroyed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2013-08-07 23:52:42 -07:00
Ben Pfaff
35bacb7fe3 netdev-bsd: Use xmemdup0() to simplify netdev_bsd_get_next_hop().
Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
CC: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
2013-08-07 23:40:32 -07:00
Ben Pfaff
9da7ae1298 netdev-bsd: Don't assume 'struct netdev' has offset 0.
The data items returned by netdev_get_devices() are "struct netdev *"s.
The code fixed up by this commit used them as "struct netdev_bsd *",
which happens to work because struct netdev happens to be at offset 0 in
each struct but it's better to do a proper cast in case someday
struct netdev gets moved to a nonzero offset.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-07 23:40:31 -07:00
Ben Pfaff
2b906eca2a netdev-bsd: Correctly handle IPv4 netmasks.
netdev_bsd_get_in4() did not set anything in its 'netmask' output argument
if the IPv4 address was cached, leaving it indeterminate.  It would also
mark the cache as valid even if there was an error retrieving the netmask.
This fixes both problems.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
2013-08-07 23:40:31 -07:00
Ben Pfaff
a5440992d6 netdev-bsd: Fix fd leak on error path.
Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
2013-08-07 23:40:30 -07:00
Ben Pfaff
6de8e4b2e8 netdev-bsd: Fix typo in label name.
Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
2013-08-07 23:40:30 -07:00
Ben Pfaff
23e29ebb84 netdev-bsd: Fix memory leak on error path.
Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: Ed Maste <emaste@freebsd.org>
2013-08-07 23:40:30 -07:00
YAMAMOTO Takashi
e4052cb95a netdev-bsd: Fix a build error.
fix a typo in the following commit.

> commit 10a89ef04df5669c5cdd02f786150a7ab8454e01
> Author: Ben Pfaff <blp@nicira.com>
> Date:   Mon Jun 24 10:54:49 2013 -0700
>
>     Replace all uses of strerror() by ovs_strerror(), for thread safety.
>
>     Signed-off-by: Ben Pfaff <blp@nicira.com>

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2013-07-01 21:10:34 -07:00
Ben Pfaff
10a89ef04d Replace all uses of strerror() by ovs_strerror(), for thread safety.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28 16:09:38 -07:00
Ed Maste
ee9e7b172b netdev-bsd: Silence warnings on unimplemented platform.
netdev_bsd_get_next_hop currently lacks an implementation on FreeBSD, so
its arguments are unused; mark them so.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-24 12:07:42 -07:00
Ed Maste
c61e1b7304 netdev-bsd: Correct pointer use after refactoring.
Introduced in commit 666afb55e84e9118812de81a75655ec9567b7a5b.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-23 08:10:47 -07:00
YAMAMOTO Takashi
3aacfbb359 factor out a function to extract stats from if_data to netdev_stats.
suggested by Ed Maste.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 21:02:02 -07:00
YAMAMOTO Takashi
d00409c5c6 implement get_next_hop for NetBSD
Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 21:01:42 -07:00
YAMAMOTO Takashi
bf8377a789 implement get_stats for NetBSD
Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 21:01:25 -07:00
YAMAMOTO Takashi
8cb67eb5a4 implement set_etheraddr for NetBSD
Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
2013-05-22 21:01:22 -07:00
YAMAMOTO Takashi
a0cf2887b1 missing ifdef netbsd guard for af_link_sock
pointed out by Ed Maste

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 20:51:39 -07:00
YAMAMOTO Takashi
ab317c3b06 netdev-bsd: NetBSD: keep a AF_LINK socket open
this will be used for get_stats and set_etheraddr

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 20:51:32 -07:00
YAMAMOTO Takashi
87ad1c0762 keep "kernel name" for each netdev
where interface renaming is not supported (NetBSD), remember both of
our netdev name and the correspoinding kernel name separately.
the latter is necessary to talk with kernel using interface names.
eg. ifioctls, bpf

XXX there should be a proper way to query kernel name.
Ben Pfaff suggested ovs-appctl but this patch doesn't implement it. (yet)

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 20:51:22 -07:00
YAMAMOTO Takashi
666afb55e8 add minimal NetBSD support
mostly ride on the existing FreeBSD support.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-22 20:39:14 -07:00
Ben Pfaff
b5d57fc879 netdev: Get rid of netdev_dev.
The distinction between struct netdev_dev and struct netdev has always
been confusing.  Now that previous commits have eliminated all interesting
state from struct netdev, this commit deletes it and renames struct
netdev_dev to take its place.  Now the situation makes much more sense and
I won't have to continue making embarrassed explanations in the future.

Good riddance.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-10 14:46:15 -07:00
Ben Pfaff
180c6d0b44 Rename superclass members to 'up'.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-05-10 14:42:30 -07:00
Ben Pfaff
796223f5bc netdev: Add new "struct netdev_rx" for capturing packets from a netdev.
Separating packet capture from "struct netdev" means that there is no
remaining per-"struct netdev" state, which will allow us to get rid of
"struct netdev_dev" (by renaming it "struct netdev").

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-05-10 14:39:36 -07:00
Ed Maste
bb79b46b34 netdev-bsd: Adjust argument line wrapping
This file presumably started out life as a copy of netdev-linux.c, and
some indentation was not updated after s/linux/bsd/.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-10 13:25:50 -07:00
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
Ed Maste
62d86422f9 netdev-bsd: Use UINT64_MAX for unsupported stats.
As documented in netdev-provider.h for the get_stats method.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-03 14:05:05 -07:00
YAMAMOTO Takashi
bf1aa7a053 fix an obvious mistake in a test of IFM_ETHER
fix a bug in FreeBSD code.  the fix is suggested by Ed Maste.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-22 08:34:53 -07:00