[ovs-dev] [PATCH 1/3] lib: Add nl_msg_end_non_empty_nested()
Jarno Rajahalme
jarno at ovn.org
Fri Jan 20 01:54:40 UTC 2017
Acked-by: Jarno Rajahalme <jarno at ovn.org>
> On Jan 13, 2017, at 4:13 PM, Andy Zhou <azhou at ovn.org> wrote:
>
> Later patch will make use of this function.
IMO it would be good for the commit message to also include the name of the function without referencing the title.
>
> Signed-off-by: Andy Zhou <azhou at ovn.org>
> ---
> lib/netlink.c | 13 +++++++++++++
> lib/netlink.h | 1 +
> 2 files changed, 14 insertions(+)
>
> diff --git a/lib/netlink.c b/lib/netlink.c
> index 4715d68..ad7d35a 100644
> --- a/lib/netlink.c
> +++ b/lib/netlink.c
> @@ -467,6 +467,19 @@ nl_msg_end_nested(struct ofpbuf *msg, size_t offset)
> attr->nla_len = msg->size - offset;
> }
>
> +/* Same as nls_msg_end_nested() when the nested Netlink contains non empty
> + * message. Otherwise, drop the nested message header from 'msg'. */
> +void
> +nl_msg_end_non_empty_nested(struct ofpbuf *msg, size_t offset)
> +{
> + nl_msg_end_nested(msg, offset);
> +
> + struct nlattr *attr = ofpbuf_at_assert(msg, offset, sizeof *attr);
> + if (!nl_attr_get_size(attr)) {
> + msg->size = offset;
> + }
> +}
> +
> /* Appends a nested Netlink attribute of the given 'type', with the 'size'
> * bytes of content starting at 'data', to 'msg'. */
> void
> diff --git a/lib/netlink.h b/lib/netlink.h
> index b931a41..7646f91 100644
> --- a/lib/netlink.h
> +++ b/lib/netlink.h
> @@ -79,6 +79,7 @@ void nl_msg_put_string(struct ofpbuf *, uint16_t type, const char *value);
>
> size_t nl_msg_start_nested(struct ofpbuf *, uint16_t type);
> void nl_msg_end_nested(struct ofpbuf *, size_t offset);
> +void nl_msg_end_non_empty_nested(struct ofpbuf *, size_t offset);
> void nl_msg_put_nested(struct ofpbuf *, uint16_t type,
> const void *data, size_t size);
>
> --
> 2.7.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
More information about the dev
mailing list