[ovs-discuss] [PATCH 00/20] Implement abstract interfaces to network devices

Ben Pfaff blp at nicira.com
Fri Jul 24 21:19:43 UTC 2009


This series of commits first refactors the network device layer to be
more amenable to portability, then it (in a big commit toward the end)
actually abstracts the network device implementation into a class
structure.  This should make it easier to port netdev to other
systems, or to support more than one kind of network device on a
single system.

-------------------------------------------------------------------------------
db5307b shash: Make shash_add() return the new node.


 lib/shash.c |    3 ++-
 lib/shash.h |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)


-------------------------------------------------------------------------------
1db9ef7 shash: Introduce new macros SHASH_FOR_EACH, SHASH_FOR_EACH_SAFE.

This is both more convenient and cleaner than using HMAP_FOR_EACH(_SAFE)
directly.

 lib/shash.c   |    2 +-
 lib/shash.h   |    7 +++++++
 lib/unixctl.c |    2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)


-------------------------------------------------------------------------------
f6ddd03 netdev: Change netdev_get_etheraddr() to return an error code.

To make the netdev code more portable, it needs to support returning error
codes from functions that don't have them.  This commit changes
netdev_get_etheraddr() to return an error code and updates all of its
callers.

 lib/dhcp-client.c |   13 ++++++++-----
 lib/netdev.c      |   12 +++++++-----
 lib/netdev.h      |    2 +-
 ofproto/ofproto.c |    2 +-
 4 files changed, 17 insertions(+), 12 deletions(-)


-------------------------------------------------------------------------------
a650cde netdev: Change netdev_get_mtu() to return an error code.

To make the netdev code more portable, it needs to support returning error
codes from functions that don't have them.  This commit changes
netdev_get_mtu() to return an error code and updates its caller.

 CodingStyle       |    2 +-
 lib/dhcp-client.c |    2 +-
 lib/dpif-netdev.c |    2 +-
 lib/netdev.c      |   15 ++++++++++-----
 lib/netdev.h      |    2 +-
 5 files changed, 14 insertions(+), 9 deletions(-)


-------------------------------------------------------------------------------
7f90b4d netdev: Change netdev_get_in4() to return an error code.

Until now, netdev_get_in4() and netdev_nodev_get_in4() have returned a
bool that represents success or failure.  This commit changes the return
value to an int that can indicate what kind of error occurred, which is
both more consistent with the rest of the netdev interfaces and more
meaningful, and updates all callers to the new interface.

 extras/ezio/ovs-switchui.c |    2 +-
 lib/netdev.c               |   16 ++++++++++------
 lib/netdev.h               |    4 ++--
 3 files changed, 13 insertions(+), 9 deletions(-)


-------------------------------------------------------------------------------
e53ee17 netdev: Get rid of netdev_open_tap().

netdev_open() can always be used in place of netdev_open_tap().  The
former is going to be generalized to support pluggable network device
types, so it makes sense to use it everywhere.

 lib/dpif-netdev.c |    4 ++-
 lib/netdev.c      |   80 +++++++++++++++++++++++-----------------------------
 lib/netdev.h      |    1 -
 3 files changed, 38 insertions(+), 47 deletions(-)


-------------------------------------------------------------------------------
8532d95 netdev: New function netdev_exists().

This new function allows cleanup of code that was using
netdev_nodev_get_flags() or ad-hoc methods to detect whether a network
device with the given name exists.

 lib/netdev.c             |   15 +++++++++++++++
 lib/netdev.h             |    2 ++
 vswitchd/ovs-brcompatd.c |   35 ++---------------------------------
 3 files changed, 19 insertions(+), 33 deletions(-)


-------------------------------------------------------------------------------
ea9ff95 netdev: Add 'netdev' parameter to netdev_add_router().

When there is the possibility of multiple classes of netdevs,
netdev_add_router() needs to know which of these to use, so it needs a
"struct netdev *" parameter.

 lib/dhcp-client.c |    2 +-
 lib/netdev.c      |    5 +++--
 lib/netdev.h      |    2 +-
 vswitchd/bridge.c |    2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)


-------------------------------------------------------------------------------
ac4eb03 ofproto: Don't use netdev_nodev_get_etheraddr() in pick_datapath_id().

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

This commit gets rid of a usage of netdev_nodev_get_etheraddr() in
pick_datapath_id(), by using the netdev that the datapath already has open
for the local port.

 ofproto/ofproto.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)


-------------------------------------------------------------------------------
7fa0199 vswitchd: Factor out iteration over interfaces with deletion.

Two different pieces of code in vswitchd were both iterating over all
the interfaces in a bridge and deleting some of them, then deleting any
ports that ended up with no interfaces because of this.  This commit
factors this operation out into a helper function.

 vswitchd/bridge.c |  118 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 69 insertions(+), 49 deletions(-)


-------------------------------------------------------------------------------
6abac5f vswitchd: Keep a netdev open for each interface.

This will allow the vswitch to use the netdev functions that take a
netdev parameter instead of the ones that take a device name.

 vswitchd/bridge.c |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)


-------------------------------------------------------------------------------
c30af65 vswitchd: Don't keep track of mac in struct iface.

It's easy to get the Ethernet address of the interface from the netdev
code, and so we don't have to keep track of it in the bridge too.

 vswitchd/bridge.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)


-------------------------------------------------------------------------------
a06807d netdev: Make netdev_find_dev_by_in4() use netdevs, not device names.

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

Also updates the only user of netdev_find_dev_by_in4().

 lib/netdev.c      |   47 ++++++++++++++++++-----------------------------
 lib/netdev.h      |    3 ++-
 ofproto/in-band.c |   26 +++++++++++++++++---------
 3 files changed, 37 insertions(+), 39 deletions(-)


-------------------------------------------------------------------------------
e8bbd57 vswitchd: Avoid netdev_nodev_set_policing().

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

 vswitchd/automake.mk    |    2 -
 vswitchd/bridge.c       |   11 +++++++++
 vswitchd/ovs-vswitchd.c |    3 --
 vswitchd/port.c         |   56 -----------------------------------------------
 vswitchd/port.h         |   22 ------------------
 5 files changed, 11 insertions(+), 83 deletions(-)


-------------------------------------------------------------------------------
5935c51 vswitchd: Avoid netdev_nodev_*() functions.

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.  This commit converts all of the users of these functions to use
the corresponding functions that take a "struct netdev *" instead.

 vswitchd/bridge.c        |  125 ++++++++++++++++++++++++---------------------
 vswitchd/ovs-brcompatd.c |   10 +++-
 2 files changed, 75 insertions(+), 60 deletions(-)


-------------------------------------------------------------------------------
6fb5698 netdev: Make netdev_get_vlan_vid() take a netdev instead of a name.

For consistency, it's best if every netdev function takes a netdev instead
of a device name.  The netdev_nodev_*() functions have always been a bit
ugly.

 lib/netdev.c      |   14 +++++++-------
 lib/netdev.h      |    2 +-
 vswitchd/bridge.c |    3 +--
 3 files changed, 9 insertions(+), 10 deletions(-)


-------------------------------------------------------------------------------
2a0781a netdev: Remove netdev_nodev_*() functions.

These functions are now unused, so they may be deleted.

 lib/netdev.c |  103 +++++++++++++++------------------------------------------
 lib/netdev.h |   10 ------
 2 files changed, 27 insertions(+), 86 deletions(-)


-------------------------------------------------------------------------------
21daba1 netdev: Implement an abstract interface to network devices.

This new abstraction layer allows multiple implementations of network
devices in a single running process.  This will be useful, for example, to
support network devices that are simulated entirely in the running process
or that communicate with other processes over Unix domain sockets, etc.

The reimplemented tap device support in this commit has not been tested.

 lib/dpif-linux.c          |   58 +-
 lib/dpif.c                |    8 +-
 lib/netdev-linux.c        | 1615 +++++++++++++++++++++++++++++++++++++++++++--
 lib/netdev-linux.h        |    3 -
 lib/netdev-provider.h     |  284 ++++++++
 lib/netdev.c              | 1606 +++++++++++----------------------------------
 lib/netdev.h              |   37 +-
 ofproto/ofproto.c         |   12 +-
 utilities/ovs-openflowd.c |    2 +
 vswitchd/ovs-brcompatd.c  |    3 +-
 vswitchd/ovs-vswitchd.c   |    3 +
 11 files changed, 2301 insertions(+), 1330 deletions(-)


-------------------------------------------------------------------------------
aa215b2 netdev-linux: Rename "linux_netdev_*" to "lxnetdev_*".

It was getting to be too confusing to have both netdev_linux_* functions
and linux_netdev_* functions.  Rename the latter to make the distinction
more obvious.

 lib/dpif-linux.c   |   14 ++++++------
 lib/netdev-linux.c |   62 ++++++++++++++++++++++++++--------------------------
 lib/netdev-linux.h |   18 +++++++-------
 3 files changed, 47 insertions(+), 47 deletions(-)


-------------------------------------------------------------------------------
43299ce lxnetdev: Document.


 lib/netdev-linux.c |   15 +++++++++++++++
 lib/netdev-linux.h |   12 ++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)






More information about the discuss mailing list