From patchwork Tue Jun 7 10:11:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dbugnar X-Patchwork-Id: 631419 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rP6qr2gwdz9ssP for ; Tue, 7 Jun 2016 20:14:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=P63Fltuj; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAE0b-0005Lq-Mr; Tue, 07 Jun 2016 10:13:17 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAE0Z-0005EP-VF for lede-dev@lists.infradead.org; Tue, 07 Jun 2016 10:13:16 +0000 Received: by mail-wm0-x243.google.com with SMTP id n184so22877726wmn.1 for ; Tue, 07 Jun 2016 03:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Kk73pBu68cTXPeP+Fu2tQdopgs5Q3r2vX18dB2LgLI=; b=P63FltujdoHpF10uq6AeL8SzIECVEJjkRhEaXhyZuJcvYKB89kPsijSE4smmol96Hm zZ+Xs9GD12tF6WPXZN6o4ZtMvG/c29LePtjCZgwYT7rS2ELsYenfCdgEZAhkxzDnqlBE E8YNJoa+FXxYXBm+DPjQoWudNy/lhkT6tfRHl9eESj8s+nzvDII7DHneH/giDgjkn90v rZ54Lg21CFPJCsi9BqPp4wq05RwRSwMbF1OjeX5N2if85tUE697MgCrNZYFlH7AfjXpg vMa6sEs8Tkkf//y7pje/MS1TiSQyHyxcZHMf/UT1sEtIk5zFNAXOY9tbGmFwHpKSN1+b X1Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7Kk73pBu68cTXPeP+Fu2tQdopgs5Q3r2vX18dB2LgLI=; b=QtHxzr23n9IwXRldGg9HKpTsk0tcCEzusA6L1uJhgqM2vJPH6bvdWIzof1Uk1rLGB6 QIzbLAtW5R8+9ZT04VlfNBmT5vq/cgu5vsxNrNS2+i1d+vMxKWKcJHDHD6YtP56ffXIh ++PBFhKq4WlhvRBbt9VZdupjgCBlyyzfy/NIvrZLF4wmpYBMhgG6HCyCnbloO/E4pRUb RXWNs74IbgH1Gv0i9SStfBXtQUjNoAcUDdVhPz2w9WB6QJv5Qc80Cw29V5U0Mc1BjTzt 2Ig6DiM2nR/FLVdK0gowoOYfvXFGU1SqAzOpXaVxp8ycx4g3j9raYKow0niPw8dF/JuO 011Q== X-Gm-Message-State: ALyK8tIdntNmflP1jMAyWB0wC0NW2PUPJXJ4/HYPx1i8dNZnwUu+PVi6dL4mAAfezgdhmg== X-Received: by 10.194.23.1 with SMTP id i1mr20111398wjf.142.1465294376649; Tue, 07 Jun 2016 03:12:56 -0700 (PDT) Received: from localhost.localdomain ([5.2.198.78]) by smtp.gmail.com with ESMTPSA id a199sm5683479wma.2.2016.06.07.03.12.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jun 2016 03:12:55 -0700 (PDT) From: Dan Bugnar To: lede-dev@lists.infradead.org Date: Tue, 7 Jun 2016 13:11:16 +0300 Message-Id: <1465294276-15925-3-git-send-email-danutbug@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465294276-15925-1-git-send-email-danutbug@gmail.com> References: <1465294276-15925-1-git-send-email-danutbug@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160607_031316_159947_D8069A02 X-CRM114-Status: GOOD ( 10.91 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (danutbug[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] [ubox] logd: add ubus reload method X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dan Bugnar MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add ubus method to set the buffer size. Example: ubus call log reload "{\"log_buffer_size\":size}" Signed-off-by: Dan Bugnar --- log/logd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/log/logd.c b/log/logd.c index 27d3cac..563c545 100644 --- a/log/logd.c +++ b/log/logd.c @@ -26,11 +26,16 @@ #include "syslog.h" +#define LOG_DEFAULT_SIZE 16 * 1024 + int debug = 0; static struct blob_buf b; static struct ubus_auto_conn conn; static LIST_HEAD(clients); +static const struct blobmsg_policy reload_policy = + { .name = "log_buffer_size", .type = BLOBMSG_TYPE_INT32 }; + static const struct blobmsg_policy read_policy = { .name = "lines", .type = BLOBMSG_TYPE_INT32 }; @@ -124,9 +129,29 @@ write_log(struct ubus_context *ctx, struct ubus_object *obj, return 0; } +static int +reload_log(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct blob_attr *tb; + int size = 0; + + if (msg) { + blobmsg_parse(&reload_policy, 1, &tb, blob_data(msg), blob_len(msg)); + if (tb) { + size = blobmsg_get_u32(tb); + log_buffer_reinit(size < 1 ? LOG_DEFAULT_SIZE : size * 1024); + } + } + + return 0; +} + static const struct ubus_method log_methods[] = { { .name = "read", .handler = read_log, .policy = &read_policy, .n_policy = 1 }, { .name = "write", .handler = write_log, .policy = &write_policy, .n_policy = 1 }, + { .name = "reload", .handler = reload_log, .policy = &reload_policy, .n_policy = 1 }, }; static struct ubus_object_type log_object_type =