From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] [PATCH lttng-tools 1/4] Fix: validate number of subbuffers after tweaking properties
Date: Wed, 20 Apr 2016 11:19:57 -0400 [thread overview]
Message-ID: <1461165600-17288-2-git-send-email-mathieu.desnoyers@efficios.com> (raw)
In-Reply-To: <1461165600-17288-1-git-send-email-mathieu.desnoyers@efficios.com>
There are properties that are tweaked by each of ust and kernel channel
create functions after a validation on the number of subbuffers for
overwrite channels. Move validation after those properties
modifications.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
src/bin/lttng-sessiond/channel.c | 25 +++++++++++++++++++++++++
src/bin/lttng-sessiond/cmd.c | 10 ----------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c
index 8ceb4e8..0119abf 100644
--- a/src/bin/lttng-sessiond/channel.c
+++ b/src/bin/lttng-sessiond/channel.c
@@ -179,6 +179,19 @@ error:
return ret;
}
+static int channel_validate(struct lttng_channel *attr)
+{
+ /*
+ * The ringbuffer (both in user space and kernel) behave badly
+ * in overwrite mode and with less than 2 subbuf so block it
+ * right away and send back an invalid attribute error.
+ */
+ if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
+ return -1;
+ }
+ return 0;
+}
+
/*
* Create kernel channel of the kernel session and notify kernel thread.
*/
@@ -207,6 +220,12 @@ int channel_kernel_create(struct ltt_kernel_session *ksession,
attr->attr.output = LTTNG_EVENT_MMAP;
}
+ /* Validate common channel properties. */
+ if (channel_validate(attr) < 0) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
/* Channel not found, creating it */
ret = kernel_create_channel(ksession, attr);
if (ret < 0) {
@@ -305,6 +324,12 @@ int channel_ust_create(struct ltt_ust_session *usess,
attr->attr.output = LTTNG_EVENT_MMAP;
}
+ /* Validate common channel properties. */
+ if (channel_validate(attr) < 0) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
/*
* Validate UST buffer size and number of buffers: must both be power of 2
* and nonzero. We validate right here for UST, because applications will
diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
index ba963ff..73942a6 100644
--- a/src/bin/lttng-sessiond/cmd.c
+++ b/src/bin/lttng-sessiond/cmd.c
@@ -1322,16 +1322,6 @@ int cmd_enable_channel(struct ltt_session *session,
attr->attr.switch_timer_interval = 0;
}
- /*
- * The ringbuffer (both in user space and kernel) behave badly in overwrite
- * mode and with less than 2 subbuf so block it right away and send back an
- * invalid attribute error.
- */
- if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
- ret = LTTNG_ERR_INVALID;
- goto error;
- }
-
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{
--
2.1.4
next prev parent reply other threads:[~2016-04-20 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-20 15:19 [lttng-dev] [PATCH lttng-tools 0/4] Allow discard buffers in snapshot sessions Mathieu Desnoyers
2016-04-20 15:19 ` Mathieu Desnoyers [this message]
2016-04-20 15:19 ` [lttng-dev] [PATCH lttng-tools 2/4] Allow channel mode override " Mathieu Desnoyers
2016-04-20 15:19 ` [lttng-dev] [PATCH lttng-tools 3/4] tests: test kernel snapshot with discard buffers Mathieu Desnoyers
2016-04-20 15:20 ` [lttng-dev] [PATCH lttng-tools 4/4] tests: test ust " Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461165600-17288-2-git-send-email-mathieu.desnoyers@efficios.com \
--to=mathieu.desnoyers@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox