diff options
author | Ben Pfaff <blp@nicira.com> | 2011-10-25 16:54:42 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-11-17 10:11:54 -0800 |
commit | 39db78a0fb8bcf91a6b0e31867018572e2b6dbe9 (patch) | |
tree | 164ffb3d7a73b883ff39d84ed97eedc1671c9ba6 /lib/odp-util.c | |
parent | c4a0802f06ff2c66b6a2736491d046afb646bbc0 (diff) |
odp-util: New function factored out of put_userspace_action().
An upcoming patch to odp-util will add a new user, but this seems like a
reasonable change in any case.
Diffstat (limited to 'lib/odp-util.c')
-rw-r--r-- | lib/odp-util.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c index f67816ef..b4ebd792 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1388,3 +1388,25 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, return check_expectations(present_attrs, expected_attrs, key, key_len); } + +/* Appends an OVS_ACTION_ATTR_USERSPACE action to 'odp_actions' that specifies + * Netlink PID 'pid'. If 'cookie' is nonnull, adds a userdata attribute whose + * contents contains 'cookie' and returns the offset within 'odp_actions' of + * the start of the cookie. (If 'cookie' is null, then the return value is not + * meaningful.) */ +size_t +odp_put_userspace_action(uint32_t pid, const struct user_action_cookie *cookie, + struct ofpbuf *odp_actions) +{ + size_t offset; + + offset = nl_msg_start_nested(odp_actions, OVS_ACTION_ATTR_USERSPACE); + nl_msg_put_u32(odp_actions, OVS_USERSPACE_ATTR_PID, pid); + if (cookie) { + nl_msg_put_unspec(odp_actions, OVS_USERSPACE_ATTR_USERDATA, + cookie, sizeof *cookie); + } + nl_msg_end_nested(odp_actions, offset); + + return cookie ? odp_actions->size - NLA_ALIGN(sizeof *cookie) : 0; +} |