From: Giuseppe Lettieri Date: Wed, 28 Aug 2013 15:28:10 +0000 (+0200) Subject: Merge branch 'mainstream' X-Git-Tag: sliver-openvswitch-2.0.90-1~18 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cc457b0fa2e45555b354d7107cabf9c9adc89183;hp=-c;p=sliver-openvswitch.git Merge branch 'mainstream' --- cc457b0fa2e45555b354d7107cabf9c9adc89183 diff --combined lib/automake.mk index 6843a6dd2,da1896a2e..fce8423ab --- a/lib/automake.mk +++ b/lib/automake.mk @@@ -95,8 -95,6 +95,8 @@@ lib_libopenvswitch_a_SOURCES = lib/multipath.c \ lib/multipath.h \ lib/netdev-dummy.c \ + lib/netdev-tunnel.c \ + lib/netdev-pltap.c \ lib/netdev-provider.h \ lib/netdev-vport.c \ lib/netdev-vport.h \ @@@ -129,6 -127,8 +129,8 @@@ lib/ofpbuf.c \ lib/ofpbuf.h \ lib/ovs-atomic-c11.h \ + lib/ovs-atomic-clang.h \ + lib/ovs-atomic-flag-gcc4.7+.h \ lib/ovs-atomic-gcc4+.c \ lib/ovs-atomic-gcc4+.h \ lib/ovs-atomic-gcc4.7+.h \ @@@ -203,8 -203,6 +205,8 @@@ lib/timeval.h \ lib/token-bucket.c \ lib/token-bucket.h \ + lib/tunalloc.c \ + lib/tunalloc.h \ lib/type-props.h \ lib/unaligned.h \ lib/unicode.c \ diff --combined lib/netdev-provider.h index 23905d413,9ab58fb22..2442b77b5 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@@ -478,22 -478,39 +478,39 @@@ struct netdev_class int (*get_queue_stats)(const struct netdev *netdev, unsigned int queue_id, struct netdev_queue_stats *stats); - /* Iterates over all of 'netdev''s queues, calling 'cb' with the queue's - * ID, its configuration, and the 'aux' specified by the caller. The order - * of iteration is unspecified, but (when successful) each queue is visited - * exactly once. - * - * 'cb' will not modify or free the 'details' argument passed in. It may - * delete or modify the queue passed in as its 'queue_id' argument. It may - * modify but will not delete any other queue within 'netdev'. If 'cb' - * adds new queues, then ->dump_queues is allowed to visit some queues - * twice or not at all. - */ - int (*dump_queues)(const struct netdev *netdev, - void (*cb)(unsigned int queue_id, - const struct smap *details, - void *aux), - void *aux); + /* Attempts to begin dumping the queues in 'netdev'. On success, returns 0 + * and initializes '*statep' with any data needed for iteration. On + * failure, returns a positive errno value. + * + * May be NULL if 'netdev' does not support QoS at all. */ + int (*queue_dump_start)(const struct netdev *netdev, void **statep); + + /* Attempts to retrieve another queue from 'netdev' for 'state', which was + * initialized by a successful call to the 'queue_dump_start' function for + * 'netdev'. On success, stores a queue ID into '*queue_id' and fills + * 'details' with the configuration of the queue with that ID. Returns EOF + * if the last queue has been dumped, or a positive errno value on error. + * This function will not be called again once it returns nonzero once for + * a given iteration (but the 'queue_dump_done' function will be called + * afterward). + * + * The caller initializes and clears 'details' before calling this + * function. The caller takes ownership of the string key-values pairs + * added to 'details'. + * + * The returned contents of 'details' should be documented as valid for the + * given 'type' in the "other_config" column in the "Queue" table in + * vswitchd/vswitch.xml (which is built as ovs-vswitchd.conf.db(8)). + * + * May be NULL if 'netdev' does not support QoS at all. */ + int (*queue_dump_next)(const struct netdev *netdev, void *state, + unsigned int *queue_id, struct smap *details); + + /* Releases resources from 'netdev' for 'state', which was initialized by a + * successful call to the 'queue_dump_start' function for 'netdev'. + * + * May be NULL if 'netdev' does not support QoS at all. */ + int (*queue_dump_done)(const struct netdev *netdev, void *state); /* Iterates over all of 'netdev''s queues, calling 'cb' with the queue's * ID, its statistics, and the 'aux' specified by the caller. The order of @@@ -647,9 -664,6 +664,9 @@@ extern const struct netdev_class netdev extern const struct netdev_class netdev_bsd_class; #endif +extern const struct netdev_class netdev_tunnel_class; +extern const struct netdev_class netdev_pltap_class; + #ifdef __cplusplus } #endif diff --combined lib/netdev.c index b1dfc08d9,5ed60624c..74f5f53ee --- a/lib/netdev.c +++ b/lib/netdev.c @@@ -109,8 -109,6 +109,8 @@@ netdev_initialize(void netdev_register_provider(&netdev_tap_class); netdev_register_provider(&netdev_bsd_class); #endif + netdev_register_provider(&netdev_tunnel_class); + netdev_register_provider(&netdev_pltap_class); ovsthread_once_done(&once); } @@@ -1400,30 -1398,78 +1400,78 @@@ netdev_get_queue_stats(const struct net return retval; } - /* Iterates over all of 'netdev''s queues, calling 'cb' with the queue's ID, - * its configuration, and the 'aux' specified by the caller. The order of - * iteration is unspecified, but (when successful) each queue is visited - * exactly once. + /* Initializes 'dump' to begin dumping the queues in a netdev. + * + * This function provides no status indication. An error status for the entire + * dump operation is provided when it is completed by calling + * netdev_queue_dump_done(). + */ + void + netdev_queue_dump_start(struct netdev_queue_dump *dump, + const struct netdev *netdev) + { + dump->netdev = netdev_ref(netdev); + if (netdev->netdev_class->queue_dump_start) { + dump->error = netdev->netdev_class->queue_dump_start(netdev, + &dump->state); + } else { + dump->error = EOPNOTSUPP; + } + } + + /* Attempts to retrieve another queue from 'dump', which must have been + * initialized with netdev_queue_dump_start(). On success, stores a new queue + * ID into '*queue_id', fills 'details' with configuration details for the + * queue, and returns true. On failure, returns false. * - * Calling this function may be more efficient than calling netdev_get_queue() - * for every queue. + * Queues are not necessarily dumped in increasing order of queue ID (or any + * other predictable order). * - * 'cb' must not modify or free the 'details' argument passed in. It may - * delete or modify the queue passed in as its 'queue_id' argument. It may - * modify but must not delete any other queue within 'netdev'. 'cb' should not - * add new queues because this may cause some queues to be visited twice or not - * at all. + * Failure might indicate an actual error or merely that the last queue has + * been dumped. An error status for the entire dump operation is provided when + * it is completed by calling netdev_queue_dump_done(). * - * Returns 0 if successful, otherwise a positive errno value. On error, some - * configured queues may not have been included in the iteration. */ + * The returned contents of 'details' should be documented as valid for the + * given 'type' in the "other_config" column in the "Queue" table in + * vswitchd/vswitch.xml (which is built as ovs-vswitchd.conf.db(8)). + * + * The caller must initialize 'details' (e.g. with smap_init()) before calling + * this function. This function will clear and replace its contents. The + * caller must free 'details' when it is no longer needed (e.g. with + * smap_destroy()). */ + bool + netdev_queue_dump_next(struct netdev_queue_dump *dump, + unsigned int *queue_id, struct smap *details) + { + const struct netdev *netdev = dump->netdev; + + if (dump->error) { + return false; + } + + dump->error = netdev->netdev_class->queue_dump_next(netdev, dump->state, + queue_id, details); + + if (dump->error) { + netdev->netdev_class->queue_dump_done(netdev, dump->state); + return false; + } + return true; + } + + /* Completes queue table dump operation 'dump', which must have been + * initialized with netdev_queue_dump_start(). Returns 0 if the dump operation + * was error-free, otherwise a positive errno value describing the problem. */ int - netdev_dump_queues(const struct netdev *netdev, - netdev_dump_queues_cb *cb, void *aux) + netdev_queue_dump_done(struct netdev_queue_dump *dump) { - const struct netdev_class *class = netdev->netdev_class; - return (class->dump_queues - ? class->dump_queues(netdev, cb, aux) - : EOPNOTSUPP); + const struct netdev *netdev = dump->netdev; + if (!dump->error && netdev->netdev_class->queue_dump_done) { + dump->error = netdev->netdev_class->queue_dump_done(netdev, + dump->state); + } + netdev_close(dump->netdev); + return dump->error == EOF ? 0 : dump->error; } /* Iterates over all of 'netdev''s queues, calling 'cb' with the queue's ID,