* [PATCH] genl: Add l_genl_msg_append_attrv
@ 2016-10-06 9:18 Andrew Zaborowski
2016-10-10 15:04 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Zaborowski @ 2016-10-06 9:18 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]
Try to minimise the amount of buffers allocated and copied by clients
when building a message attribute that is a concatenation of other
buffers, such as an IE sequence.
---
ell/genl.c | 32 ++++++++++++++++++++++++++++++++
ell/genl.h | 2 ++
2 files changed, 34 insertions(+)
diff --git a/ell/genl.c b/ell/genl.c
index 85e447a..c522ae7 100644
--- a/ell/genl.c
+++ b/ell/genl.c
@@ -793,6 +793,38 @@ LIB_EXPORT bool l_genl_msg_append_attr(struct l_genl_msg *msg, uint16_t type,
return true;
}
+LIB_EXPORT bool l_genl_msg_append_attrv(struct l_genl_msg *msg, uint16_t type,
+ struct iovec *iov, size_t iov_len)
+{
+ struct nlattr *nla;
+ size_t len = 0;
+ unsigned int i;
+
+ if (unlikely(!msg))
+ return false;
+
+ for (i = 0; i < iov_len; i++)
+ len += iov[i].iov_len;
+
+ if (msg->len + NLA_HDRLEN + NLA_ALIGN(len) > msg->size)
+ return false;
+
+ nla = msg->data + msg->len;
+ nla->nla_len = NLA_HDRLEN + len;
+ nla->nla_type = type;
+
+ msg->len += NLA_HDRLEN;
+
+ for (i = 0; i < iov_len; i++, iov++) {
+ memcpy(msg->data + msg->len, iov->iov_base, iov->iov_len);
+ msg->len += iov->iov_len;
+ }
+
+ msg->len += NLA_ALIGN(len) - len;
+
+ return true;
+}
+
LIB_EXPORT bool l_genl_msg_enter_nested(struct l_genl_msg *msg, uint16_t type)
{
struct nlattr *nla;
diff --git a/ell/genl.h b/ell/genl.h
index 5b37d55..fe188d9 100644
--- a/ell/genl.h
+++ b/ell/genl.h
@@ -71,6 +71,8 @@ int l_genl_msg_get_error(struct l_genl_msg *msg);
bool l_genl_msg_append_attr(struct l_genl_msg *msg, uint16_t type,
uint16_t len, const void *data);
+bool l_genl_msg_append_attrv(struct l_genl_msg *msg, uint16_t type,
+ struct iovec *iov, size_t iov_len);
bool l_genl_msg_enter_nested(struct l_genl_msg *msg, uint16_t type);
bool l_genl_msg_leave_nested(struct l_genl_msg *msg);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] genl: Add l_genl_msg_append_attrv
2016-10-06 9:18 [PATCH] genl: Add l_genl_msg_append_attrv Andrew Zaborowski
@ 2016-10-10 15:04 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2016-10-10 15:04 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
Hi Andrew,
On 10/06/2016 04:18 AM, Andrew Zaborowski wrote:
> Try to minimise the amount of buffers allocated and copied by clients
> when building a message attribute that is a concatenation of other
> buffers, such as an IE sequence.
> ---
> ell/genl.c | 32 ++++++++++++++++++++++++++++++++
> ell/genl.h | 2 ++
> 2 files changed, 34 insertions(+)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-10 15:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-06 9:18 [PATCH] genl: Add l_genl_msg_append_attrv Andrew Zaborowski
2016-10-10 15:04 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.