This new function allows callers to determine whether previously returned keys will be modified or reallocated on the next call to dpif_flow_dump_next(). This will be used in a future commit to allow batched flow deletion by revalidator threads.
Signed-off-by: Joe Stringer <joestrin...@nicira.com> --- v3: Renamed function and made it more specific to flow keys. --- lib/dpif-linux.c | 9 +++++++++ lib/dpif-netdev.c | 1 + lib/dpif-provider.h | 13 +++++++++++++ lib/dpif.c | 21 +++++++++++++++++++++ lib/dpif.h | 2 ++ 5 files changed, 46 insertions(+) diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index c77eb26..c99100f 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -1101,6 +1101,14 @@ dpif_linux_flow_dump_next(const struct dpif *dpif_, void *iter_, void *state_, return error; } +static bool +dpif_linux_flow_dump_next_may_destroy_keys(void *state_) +{ + struct dpif_linux_flow_state *state = state_; + + return state->buffer.size ? false : true; +} + static int dpif_linux_flow_dump_done(const struct dpif *dpif OVS_UNUSED, void *iter_) { @@ -1666,6 +1674,7 @@ const struct dpif_class dpif_linux_class = { dpif_linux_flow_dump_state_init, dpif_linux_flow_dump_start, dpif_linux_flow_dump_next, + dpif_linux_flow_dump_next_may_destroy_keys, dpif_linux_flow_dump_done, dpif_linux_flow_dump_state_uninit, dpif_linux_execute, diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 0646067..75aabc3 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1888,6 +1888,7 @@ const struct dpif_class dpif_netdev_class = { dpif_netdev_flow_dump_state_init, dpif_netdev_flow_dump_start, dpif_netdev_flow_dump_next, + NULL, dpif_netdev_flow_dump_done, dpif_netdev_flow_dump_state_uninit, dpif_netdev_execute, diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h index c85de5f..dd4f74e 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -312,6 +312,19 @@ struct dpif_class { const struct nlattr **actions, size_t *actions_len, const struct dpif_flow_stats **stats); + /* Determines whether the next call to 'flow_dump_next' with 'state' will + * modify or free the keys that it previously returned. 'state' must have + * been initialized by a call to 'flow_dump_state_init' for 'dpif'. + * + * 'dpif' guarantees that data returned by flow_dump_next() will remain + * accessible and unchanging until the next call. This function provides a + * way for callers to determine whether that guarantee extends beyond the + * next call. + * + * Returns true if the next call to flow_dump_next() is expected to be + * destructive to previously returned keys for 'state', false otherwise. */ + bool (*flow_dump_next_may_destroy_keys)(void *state); + /* Releases resources from 'dpif' for 'iter', which was initialized by a * successful call to the 'flow_dump_start' function for 'dpif'. Callers * must ensure that this function is called once within a given iteration, diff --git a/lib/dpif.c b/lib/dpif.c index 117d720..8cb2145 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -1056,6 +1056,27 @@ dpif_flow_dump_next(struct dpif_flow_dump *dump, void *state, return !error; } +/* Determines whether the next call to 'dpif_flow_dump_next' for 'dump' and + * 'state' will modify or free the keys that it previously returned. 'state' + * must have been initialized by a call to 'dpif_flow_dump_state_init' for + * 'dump'. + * + * 'dpif' guarantees that data returned by flow_dump_next() will remain + * accessible and unchanging until the next call. This function provides a way + * for callers to determine whether that guarantee extends beyond the next + * call. + * + * Returns true if the next call to flow_dump_next() is expected to be + * destructive to previously returned keys for 'state', false otherwise. */ +bool +dpif_flow_dump_next_may_destroy_keys(struct dpif_flow_dump *dump, void *state) +{ + const struct dpif *dpif = dump->dpif; + return (dpif->dpif_class->flow_dump_next_may_destroy_keys + ? dpif->dpif_class->flow_dump_next_may_destroy_keys(state) + : true); +} + /* Completes flow table dump operation 'dump', which must have been initialized * with a successful call to dpif_flow_dump_start(). Returns 0 if the dump * operation was error-free, otherwise a positive errno value describing the diff --git a/lib/dpif.h b/lib/dpif.h index 0c763dc..4e24416 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -523,6 +523,8 @@ bool dpif_flow_dump_next(struct dpif_flow_dump *, void *state, const struct nlattr **mask, size_t *mask_len, const struct nlattr **actions, size_t *actions_len, const struct dpif_flow_stats **); +bool dpif_flow_dump_next_may_destroy_keys(struct dpif_flow_dump *dump, + void *state); int dpif_flow_dump_done(struct dpif_flow_dump *); void dpif_flow_dump_state_uninit(const struct dpif *, void *state); -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev