From patchwork Mon Apr 8 11:14:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 1920791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=K/5wKFc3; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.a=rsa-sha256 header.s=b header.b=hlZZWvEn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VCmkp3pFNz1yYT for ; Mon, 8 Apr 2024 21:16:48 +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:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eIAlzmkhN9wohDjDX7AypY1hc79p5ApATrxrhuPwAS8=; b=K/5wKFc3maRi8W 7um5Tc7qnpwYvNKTYd0+SuO69dA/X0c545ofch/goxADfQMEKiu5lj6ZimoWklLTQZ0lTBNQfLjBX LyjlPTxgUMmDjKf451gYspwZpnf49OGVW9/TN/CjNDpajEohuooWxAAaNVTzTKgy5Gm3SBmNSa0q5 Nknun6UjmYCm45QSfvVp+hQ9E7gAm5RslS775lTCV21+zFiP3w1JLG4HmQM0ttfFiftxTuGVWZD2L MER+Ui5XmZ8BhejCfivw2MSOrmaye6+ia9QnaRm6Ab5NVINHwmRcQQL5RN4sKUl+flhHt/6Hp5iB8 /LZFCU7NILHwScewL2sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtmxf-0000000FMHL-3YK8; Mon, 08 Apr 2024 11:14:51 +0000 Received: from dilbert.mork.no ([2a01:4f9:c010:a439::d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtmxa-0000000FMDE-0lb2 for openwrt-devel@lists.openwrt.org; Mon, 08 Apr 2024 11:14:48 +0000 Received: from canardo.dyn.mork.no ([IPv6:2a01:799:10da:6900:0:0:0:1]) (authenticated bits=0) by dilbert.mork.no (8.17.1.9/8.17.1.9) with ESMTPSA id 438BEVEG2906063 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK) for ; Mon, 8 Apr 2024 12:14:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1712574871; bh=TgHfj4RVMBqUXX0iFZCY31NZLRudxysM8h0g0REwcA4=; h=From:To:Subject:Date:Message-ID:From; b=hlZZWvEn5XFYcTaWu9nBpnzZAZaCfDqZIKcyiNiXJ/DL6aXEOjEFxIfITwRapsyjx zy5RfzKCxXxSo0wIw7/DLCjzOR1tGg9HRYxJiQUSRfDeEbZsNNWCbFuYFtZufAwx4t OjNklZF+SkHJ3QOKxFDhmc9gikwLtehXEznpcJpo= Received: from miraculix.mork.no ([IPv6:2a01:799:10da:690a:d43d:737:5289:b66f]) (authenticated bits=0) by canardo.dyn.mork.no (8.17.1.9/8.17.1.9) with ESMTPSA id 438BEVqd550128 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK) for ; Mon, 8 Apr 2024 13:14:31 +0200 Received: (nullmailer pid 655646 invoked by uid 1000); Mon, 08 Apr 2024 11:14:31 -0000 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: openwrt-devel@lists.openwrt.org Subject: libubus ubus_invoke() with an extended struct blob_attr *msg as input Organization: m Date: Mon, 08 Apr 2024 13:14:31 +0200 Message-ID: <87edbgrtrc.fsf@miraculix.mork.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.3 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240408_041446_962689_89221D50 X-CRM114-Status: GOOD ( 12.40 ) X-Spam-Score: -0.1 (/) 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: Not too sure about any of this, so I just wanted to ask if this would make sense: bjorn@miraculix:/usr/local/src/git/ubus$ git diff diff --git a/libubus-req.c b/libubus-req.c index ae9d1925ecdf..cf85303e6aed 100644 --- a/libubus-req.c +++ b/libubus-req.c @@ -197,7 +197,7 @@ void ub [...] Content analysis details: (-0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 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 Not too sure about any of this, so I just wanted to ask if this would make sense: bjorn@miraculix:/usr/local/src/git/ubus$ git diff The reason is that I spent some time scratching my head trying to figure out why the blob I passed to ubus_invoke() had no effect at all. It turned out to be because I passed a msg parameter with a blobmsg header (and name). I know it sounds like a strange thing to do. But the input was passed to my program as an element of a larger json struct. So I simply ran blobmsg_add_json_from_string() and blobmsg_parse() on that, extracting the attribute with the input for my ubus call. Which means that the attribute ended up with a blobmsg_hdr. I can fix the problem now that I know of it, although it doesn't seem like there's any helpers doing just that? But I think it would be nice if this just worked either way. And I believe the above diff will do that. AFAICS, it changes nothing unless the BLOB_ATTR_EXTENDED flag is set. Bjørn diff --git a/libubus-req.c b/libubus-req.c index ae9d1925ecdf..cf85303e6aed 100644 --- a/libubus-req.c +++ b/libubus-req.c @@ -197,7 +197,7 @@ void ubus_complete_deferred_request(struct ubus_context *ctx, struct ubus_reques static void ubus_put_data(struct blob_buf *buf, struct blob_attr *msg) { if (msg) - blob_put(buf, UBUS_ATTR_DATA, blob_data(msg), blob_len(msg)); + blob_put(buf, UBUS_ATTR_DATA, blobmsg_data(msg), blobmsg_len(msg)); else blob_put(buf, UBUS_ATTR_DATA, NULL, 0); }