From patchwork Fri Aug 27 11:22:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nicola.pancheri@netduma.com X-Patchwork-Id: 1521641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oNMiDr9Q; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netduma-com.20150623.gappssmtp.com header.i=@netduma-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=rmRtHSBw; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gwy764HvVz9sPf for ; Fri, 27 Aug 2021 21:25:06 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9FTc/9rTidxnk6hwyp/wrcsousLNhzSQHueSW/zQiv0=; b=oNMiDr9Q3gtB1Q J6ak4MbtfXuU8svn20OWduaGKLgl2UpZgGcUyIsOYd7JY62Xsejfi8K30ZNBayf1dgGyMkq8nOcCv NQWgkvZxpE323pDBWkLIXZVCIL4fqrA47SSXbSiC+HTjjCweYqsbJsGZ6E0SrsmIAybh2ZN7NgCcq 5svVOZFSJOTL5G4jnTLdY9UL5pXyIotR1Tp7YeVZbhx6YS3BRCPW7LkkWujopdqy7+HLuPCpLSVYe fGvXnHJfLXE6tBZMJu6vwjraOaisg8VbdOEvOv/eAWzoKpmOBa3UOj9oVPGqkxWicY3dU+lumJzwy Vekdoj/XDU5krn/6yHtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZwF-00CK22-3d; Fri, 27 Aug 2021 11:22:23 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZwB-00CK1j-FG for openwrt-devel@lists.openwrt.org; Fri, 27 Aug 2021 11:22:20 +0000 Received: by mail-wr1-x432.google.com with SMTP id b6so9827826wrh.10 for ; Fri, 27 Aug 2021 04:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netduma-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hmHfUbl1xUfMHIBLOJMv64rTnOD3O4fry5zdSSvP1A8=; b=rmRtHSBwTBhWOEQ2ZBkOAfzZh3skau8/RZklQhM2vvySaXP+wPVNL0TZMQ5I9fk9BR 0nw8fBBIfaul7vP0ktRoiSyeuzAFU1kwKGdIgablt8MLDosdNziia8jDvX7NrgDUXa4R exsxL60I1So4PYBcqjyjaMrzFruml5ux75OW4kif8kTh7DQYOkN1HFdjvBvKGhCLY6m+ dYM34buqgDwCLow+dQ1zXE0ySI4Y006mpiX/oywCk9iQi8nZUfsyvLIYUXTNGM9mGTkZ Bud7VviE7Yc9NlSKV+WNiE+h8Ma+lAIFkhZ47Tfnc36b/mF8CrRmfMx2oKN19TPxVdxp teFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hmHfUbl1xUfMHIBLOJMv64rTnOD3O4fry5zdSSvP1A8=; b=AK9o+S6+Jx5oouIrwMe8qdMULoxbK1oNS4TME6A1U04czau5491BpMB8jD7s3Me1py Qbhac9J4kcAY4XiTrAE0nOMkvWE4zNYNb8ZEv081Rh7+oJf6lrN4wgWrrgK8lKtmFBdr aUp2o80KTlzPRowluKwlAzv+HNefFn/mPXNEUAJGCPatQgPaAT3iKiHmQnrXZCpHRRUL JQFY+UhuA62GpBg69wM3d5LVKQd7rIrsqzbHb2I4IQEwOE6CJPuch0xnQ8o1zE3AQwqq VZvOgYneF+fVT/zApAgjnWHCXUtxrzp1zfSJWfnR5TLrhP3TC50/2SMGp1slRmv+4BSt PFTQ== X-Gm-Message-State: AOAM530B4u1Rktiat+V4ACEnB6Wxe6yCaLr9SehTCaOU7Kd5JQJpMiBA v0tAQHX0w0y4EHKbaqkPGLDfmV40KJtvTm+0klo= X-Google-Smtp-Source: ABdhPJwyVAGRLe8o3WYfEu4AXS0Kh9bPMj01BJOr+Xgn8/CT+PeNftwHN1KSSBBYAZPE2YWiq3M2JA== X-Received: by 2002:a05:6000:1b8d:: with SMTP id r13mr9644842wru.230.1630063337028; Fri, 27 Aug 2021 04:22:17 -0700 (PDT) Received: from lin-dev-004.modem ([77.95.36.54]) by smtp.gmail.com with ESMTPSA id v28sm6006964wrv.93.2021.08.27.04.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 04:22:16 -0700 (PDT) From: nicola.pancheri@netduma.com To: openwrt-devel@lists.openwrt.org Cc: Nicola Pancheri Subject: [PATCH] ubus/lua: add fd sending to ubus requests Date: Fri, 27 Aug 2021 12:22:10 +0100 Message-Id: <20210827112210.34910-1-nicola.pancheri@netduma.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210827_042219_608687_4F0A9C43 X-CRM114-Status: UNSURE ( 8.82 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Nicola Pancheri Exposes the ubus file descriptor sharing interface to Lua. Signed-off-by: Nicola Pancheri --- lua/ubus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) Content analysis details: (0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:432 listed in] [list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Nicola Pancheri Exposes the ubus file descriptor sharing interface to Lua. Signed-off-by: Nicola Pancheri --- lua/ubus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/ubus.c b/lua/ubus.c index e2bb081..8378a25 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -321,7 +321,8 @@ ubus_method_handler(struct ubus_context *ctx, struct ubus_object *obj, lua_pushnil(state); else ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true); - lua_call(state, 2, 1); + lua_pushnumber(state,req->req_fd); + lua_call(state, 3, 1); if (lua_isnumber(state, -1)) rv = lua_tonumber(state, -1); } @@ -668,6 +669,12 @@ ubus_lua_call(lua_State *L) const char *path = luaL_checkstring(L, 2); const char *func = luaL_checkstring(L, 3); + int fd = -1; + if( lua_isnumber(L,5) ){ + fd = lua_tointeger(L,5); + lua_pushvalue( L, 4 ); + } + luaL_checktype(L, 4, LUA_TTABLE); blob_buf_init(&c->buf, 0); @@ -688,7 +695,7 @@ ubus_lua_call(lua_State *L) } top = lua_gettop(L); - rv = ubus_invoke(c->ctx, id, func, c->buf.head, ubus_lua_call_cb, L, c->timeout * 1000); + rv = ubus_invoke_fd(c->ctx, id, func, c->buf.head, ubus_lua_call_cb, L, c->timeout * 1000, fd); if (rv != UBUS_STATUS_OK) {