summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-03-02 13:25:10 -0800
committerBen Pfaff <blp@nicira.com>2011-03-30 15:08:47 -0700
commit19cf40693da2e6e7612268fc6708fc6c879ebdff (patch)
tree199c07cd3598b1d41a8eb0282003b655495d1c0f /lib
parent3f19d399f51def640101001f28387baade399621 (diff)
downloadopenvswitch-19cf40693da2e6e7612268fc6708fc6c879ebdff.tar.gz
odp-util: Replace ODPUTIL_FLOW_KEY_U32S by new struct odputil_keybuf.
This seems to me to better encapsulate the inherent ugliness.
Diffstat (limited to 'lib')
-rw-r--r--lib/dpif-netdev.c6
-rw-r--r--lib/odp-util.h11
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 035ceaedd..762d24b39 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -872,7 +872,7 @@ struct dp_netdev_flow_state {
uint32_t bucket;
uint32_t offset;
struct nlattr *actions;
- uint32_t keybuf[ODPUTIL_FLOW_KEY_U32S];
+ struct odputil_keybuf keybuf;
struct dpif_flow_stats stats;
};
@@ -909,9 +909,9 @@ dpif_netdev_flow_dump_next(const struct dpif *dpif, void *state_,
if (key) {
struct ofpbuf buf;
- ofpbuf_use_stack(&buf, state->keybuf, sizeof state->keybuf);
+ ofpbuf_use_stack(&buf, &state->keybuf, sizeof state->keybuf);
odp_flow_key_from_flow(&buf, &flow->key);
- assert(buf.base == state->keybuf);
+ assert(buf.base == &state->keybuf);
*key = buf.data;
*key_len = buf.size;
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 4020660b4..a88c7eec8 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -86,11 +86,12 @@ void format_odp_actions(struct ds *, const struct nlattr *odp_actions,
* key types are added. */
BUILD_ASSERT_DECL(__ODP_KEY_ATTR_MAX == 14);
-/* We allocate temporary on-stack buffers for flow keys as arrays of uint32_t
- * to ensure proper 32-bit alignment for Netlink attributes. (An array of
- * "struct nlattr" might not, in theory, be sufficiently aligned because it
- * only contains 16-bit types.) */
-#define ODPUTIL_FLOW_KEY_U32S DIV_ROUND_UP(ODPUTIL_FLOW_KEY_BYTES, 4)
+/* A buffer with sufficient size and alignment to hold an nlattr-formatted flow
+ * key. An array of "struct nlattr" might not, in theory, be sufficiently
+ * aligned because it only contains 16-bit types. */
+struct odputil_keybuf {
+ uint32_t keybuf[DIV_ROUND_UP(ODPUTIL_FLOW_KEY_BYTES, 4)];
+};
void odp_flow_key_format(const struct nlattr *, size_t, struct ds *);