From patchwork Fri Nov 13 08:30:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43e; helo=mail-wr1-x43e.google.com; envelope-from=swupdate+bncbcxploxj6ikrbvuixh6qkgqe7auaejy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=V87YsEGC; dkim-atps=neutral Received: from mail-wr1-x43e.google.com (mail-wr1-x43e.google.com [IPv6:2a00:1450:4864:20::43e]) (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 4CXWs93vbmz9sTv for ; Fri, 13 Nov 2020 19:31:22 +1100 (AEDT) Received: by mail-wr1-x43e.google.com with SMTP id h11sf3407250wrq.20 for ; Fri, 13 Nov 2020 00:31:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256279; cv=pass; d=google.com; s=arc-20160816; b=qnc36vrojmsZjgmIbpvTTv0b7IhcCxpdbVQA83qkxnCuAx03GkeUAqWLFDvpukzlLr Ht4wI4IcP/ts7UyIhaEvlJ2R0vK9B23eqUCmuVhrF51bzUAf5DWYkH3T9XfnnSYvPW93 z2dJcRHE+QhOZXL5exOMQF2JrWoLPh3xot+XZHbBfw7TmEwr0kadk3t9z8DAs1Xf7Uhr lDm9md+Ymk0+FEwZpDc1i1NaWxTu2QY6hAdfOE/YytPSWPu41MuVOeMY3jisg6fwTaLW xRHUkWuEtiy0Nl4rOGbb1wtTHs5lW+RIA7XWOje4DtaRunyWQxqL5T9zrlBNYJGE/xnU dpmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Ft8j4ttPC/YC18kpZuaf1estp4vSVUp72Qx1SHlUZpM=; b=F5exrY7qH+wu0V6MtfJZJrXX5pjYqAZj8Q+hO1gB358ZYtH0OE0rtoRFbo7YeU6sEf ylfz97FLSzJGW7bVE6SEXXJ+dQX926ig/HeZ44xy3KYB7/IjdY3qdcT/XkFsLPGGYxQ4 SSywhVDGEOYucnvnHBJ+70b4FyEIqSKRbNp5qHtVbLj1jcFL/ekgFeW2lDBD+VzN0WvR /GNO5EO/hyJKavbBdndkwoYXKLLkblNmZnrVZx7+fNyGjlhCJ9xTbatfmuIB7p50uUVO CZtVSHwoCG8C853TMUiO672uRxMbopclbsYEoeal3747Ol9hdLnbV6Z5RyXHrEqN26BP V8YQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Ft8j4ttPC/YC18kpZuaf1estp4vSVUp72Qx1SHlUZpM=; b=V87YsEGCqJGGJTB/HJwI1H6JXdggTnVIayzfuQLwQXHAPv4hOXilDCEBQm6Hno1rp8 JzA3mgnjgoD6zmJxSVjll+/Fdryy4MssyfTShbjE1SqgDReSld48aqxfjWzxcxFprMYT qgMGHk14VxFqpJv56jq1b+PHzNj99kS0AUj9C26EmQCPfXWihgt1LtHUGvo/LJEzT6in F6RhEqwCfFq9MRJ+37+s5uYnKt7PP+eYdqBBVOsBBc1GX+3LKroNs4v1NNOlx+mBPLfx 1yTTOzJF67aeofan6gDWdgFyS4V8Pw0xbCSzeq8U2bdq0bHsoZR/tgmBdCV2YxjInZeP 4N5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Ft8j4ttPC/YC18kpZuaf1estp4vSVUp72Qx1SHlUZpM=; b=HgntvHhnSLMKy72k+bWYhBJqwYZbK/PxzCkEArl4JThXjjAE7sGh06zx6cW/HXH4w1 WknTfVmaTsqkh7fI5yitpKDlWiq7NNXJD7KVQL0zjRobNjDlPhLwjTjUtPq7H2tGPXio MhmnqU6SD6DqVzoW7JlR/PiqwDspiBEdFP9Ux8jbeNnrfdQlkFXoj+3SpdjQtFVTthtI UQmXEk6RVMTJFMWOuZZXjC65xx1sV2N3a1PKfgPDmIst+ikRI4HfkuTV1jgCuWr2YW1Y +s/z//iQpNdmgo6dnewbiBxIj2zj0h3A9fMjKJaR8y+EX3+siy+sXPs6o5VDSeSIXyaK XacQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530ePzo81jtn2HdEmgaQe+g0jOV+UB44Nv/VGdURMxlSixzDzAY8 8ZANXooSZ3XUPwFaA2u63hE= X-Google-Smtp-Source: ABdhPJwBHGv2tyzs9dGSLhSDnfouoXBKTZOBwVy3w5Zww381zefp3FoKxY+QXYqDpmkOspFyaD+fwg== X-Received: by 2002:a05:6000:372:: with SMTP id f18mr2052637wrf.149.1605256278666; Fri, 13 Nov 2020 00:31:18 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:c689:: with SMTP id j9ls4279807wrg.0.gmail; Fri, 13 Nov 2020 00:31:17 -0800 (PST) X-Received: by 2002:adf:eb4c:: with SMTP id u12mr2015478wrn.73.1605256277599; Fri, 13 Nov 2020 00:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256277; cv=none; d=google.com; s=arc-20160816; b=X/4tmV0UbxuhZpQeqqfEL6xwwHBZbB8l8Mzk9UlMkl0pBl9DiEnjDtztXmxdl78ZTo cKmyP8cl/Cpi6YvrQlwNzYEPbOgghVM7d76mmcpfcM+aux+mMh36WT3Q3qbnAkMpZEee b3lQu+SUe9vSaMBHhARAudGx0AJaWSFgN7bOLjojgh+iOhvp/ookVspkeTi7wB4e/3ha sVC/R2D0dbyeALEI+pB15LTfsxpIqWUe5/dORFYTK+OuTbpCS0PHgyptc4UtRsTbs8+u LCB/WFBdcnxFHi+I/bRIya+fyDnyvpWHgirQyEbbQDEt4rOaO3WoLBUWqwOclRP74Ojv 5yJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1NU62j/4ZhmT14bVM4mxUL9LZYVW2JaG8Aofow793kE=; b=xnhvTY7DXjdC848qp2oVRoh3+U7g6789rV8HCq1Loiqm/AuyobiHioaTsPpF9X4mJx gwoYkG7ETtLKRBShQVALCWT0zVVKJ0wBzyCi4HnFLhTezZTRBfP9eELLPk606v+Mz+JU MzIugLVGk5cBGWQm+8d+SMGNuCM2r8fJAJxXw2mHUe8/+kpQo2ib1VybZOTjNMT5FoyM yQVoEeI0TGVQM2WarAvzyT5sBir9PcGRClBw+wyXEN6BuWF+ZtLa+nD51gvHQUIFLMeO 1n7RILrV8gvbnfiuZpiPZemfG290ZS1wsYiosxXE5l7WYGQiIACERAOpO6O0fIrL47Oo DLew== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id w62si197720wma.1.2020.11.13.00.31.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:17 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWs1300jz1rwb8; Fri, 13 Nov 2020 09:31:17 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWs12r1Cz1tD9Y; Fri, 13 Nov 2020 09:31:17 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id kBfl17xVI498; Fri, 13 Nov 2020 09:31:16 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:16 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 613A44540286; Fri, 13 Nov 2020 09:31:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id aihCrWrjJd1M; Fri, 13 Nov 2020 09:31:11 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id AC44345405D7; Fri, 13 Nov 2020 09:31:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 01/10] Move global structure for installer in private header Date: Fri, 13 Nov 2020 09:30:59 +0100 Message-Id: <20201113083108.12567-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The "struct installer" is a shared global data structure used to store setup for the current installation and to lock if an update is running by storing the current status. It is loaded just by the initiator of an update (the installers as streaming or file). It should be better moved to a private file instead of beeing in util.h that is included by all due to get logging facilities. Signed-off-by: Stefano Babic --- core/network_thread.c | 1 + core/stream_interface.c | 1 + include/installer_priv.h | 25 +++++++++++++++++++++++++ include/util.h | 12 ------------ 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 include/installer_priv.h diff --git a/core/network_thread.c b/core/network_thread.c index b565a80..698c139 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -27,6 +27,7 @@ #include "network_ipc.h" #include "network_interface.h" #include "installer.h" +#include "installer_priv.h" #include "swupdate.h" #include "pctl.h" #include "generated/autoconf.h" diff --git a/core/stream_interface.c b/core/stream_interface.c index 87883ae..8285c72 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -40,6 +40,7 @@ #include "network_interface.h" #include "mongoose_interface.h" #include "installer.h" +#include "installer_priv.h" #include "progress.h" #include "pctl.h" #include "state.h" diff --git a/include/installer_priv.h b/include/installer_priv.h new file mode 100644 index 0000000..a84143d --- /dev/null +++ b/include/installer_priv.h @@ -0,0 +1,25 @@ +/* + * (C) Copyright 2020 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _INSTALLER_PRIV_H +#define _INSTALLER_PRIV_H + +#include "swupdate_status.h" + +struct installer { + int fd; /* install image file handle */ + RECOVERY_STATUS status; /* "idle" or "request source" info */ + RECOVERY_STATUS last_install; /* result from last installation */ + int last_error; /* error code if installation failed */ + char errormsg[64]; /* error message if installation failed */ + sourcetype source; /* Who triggered the update */ + int dry_run; /* set it if no changes in hardware must be done */ + unsigned int len; /* Len of data valid in info, data is optional */ + char info[2048]; /* info */ +}; + +#endif diff --git a/include/util.h b/include/util.h index 7d9c721..99da3a8 100644 --- a/include/util.h +++ b/include/util.h @@ -76,18 +76,6 @@ enum { RECOVERY_DWL, }; -struct installer { - int fd; /* install image file handle */ - RECOVERY_STATUS status; /* "idle" or "request source" info */ - RECOVERY_STATUS last_install; /* result from last installation */ - int last_error; /* error code if installation failed */ - char errormsg[64]; /* error message if installation failed */ - sourcetype source; /* Who triggered the update */ - int dry_run; /* set it if no changes in hardware must be done */ - unsigned int len; /* Len of data valid in info */ - char info[2048]; /* info */ -}; - typedef void (*notifier) (RECOVERY_STATUS status, int error, int level, const char *msg); void notify(RECOVERY_STATUS status, int error, int level, const char *msg); From patchwork Fri Nov 13 08:31:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::437; helo=mail-wr1-x437.google.com; envelope-from=swupdate+bncbcxploxj6ikrbweixh6qkgqe7ygpwyy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=E5BOIXh1; dkim-atps=neutral Received: from mail-wr1-x437.google.com (mail-wr1-x437.google.com [IPv6:2a00:1450:4864:20::437]) (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 4CXWs92vzJz9sSn for ; Fri, 13 Nov 2020 19:31:24 +1100 (AEDT) Received: by mail-wr1-x437.google.com with SMTP id w6sf3423003wrk.1 for ; Fri, 13 Nov 2020 00:31:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256281; cv=pass; d=google.com; s=arc-20160816; b=Q6SprEd2k9fjzupSQYu9xR09GR6e0VPwTMiCmiMV4WGwghtovq3Cis8GUKDUD+hLby t7eDcYImGYMn/Klch1BvElVBnKi9FU6w/ltLQVPp8+bhrVDyCKicUruIzOHjVqaszTln 2e1mI4llKdc006w9lhVrJT4AZdAL/v1/RN2LArAShPVfGqDO5yEN3BNYAR4hUvhiglce jHEPDyFc5K9nNpY86E7VBeI9l65RLXEOFDhRDsi41qmsM0Tw/WeZSnqJ3ssMGi1qlLuQ 26VL+eIA2+Z2INlLgFaOj7hXExO1pL50eb+pGJMzYVFVzr7NPK1gIxAwOPLbyNs8InRx 6LUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=DVP6XfBphM0wiiiPlDoLJBGWvRtlmQPQqnEn2XCFxxA=; b=VIACVTUNIvkusq/lq9xNOPap+WHTeo2YYFfa4e1A0qc1MaOaAMRtFj0UyCQiC99zi/ ByaHdLZGnzJsFYiRhiHpv0TY/XiponMREhaCfENXJj7p2tswpLqA9vZSG9VYY785sPDk GmFsfzfT2uMutG4SyVk95sjuP4gYFLKS7R821+0O6uilALFuh0Zh6O7d6HuMrITM/rxq 1bcMb44Xtgo1sXXLlDjEx13emD4BAjJKuSBP7N2cSgHTaoUnni8P6EwnK4MbnTAZM09V KwkxSP9EhSSlC1tL1Zv65pwWUG6pPmwp7DQcM/LqfgPO0rVk+ew3KMlG9aT61rq/3sJz n6BQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=DVP6XfBphM0wiiiPlDoLJBGWvRtlmQPQqnEn2XCFxxA=; b=E5BOIXh1FCVGC7jFHQ4JYocWI0/XrwbHmAWLNxt/NVRZsmBsX9m7qrZ2j4BLUHZNE9 moSRiuuXTlbGvekCns8VWhuOKK57WhP75aidEGwvyG7y+FPL0sKcVDL2zEXMXzDQrFc4 41RxU7OEi2TSUJ+iZYNcK69LepOGW215SpUa2tF5klApLvPjAMvObVFm/lU+1tKacTRY XbvhUmoBcgvAYTMM44JgcYguqx8K45xCyH1QqTE3qotW0+1aUYtW8UAsau8LsTvNrMd5 Hg5bBZaGqvY2gA+jz/zKmtdYF4fMrXf/InXKIJrV34rhAIO11dM3HLjVvnv30nRU7ezY YjRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=DVP6XfBphM0wiiiPlDoLJBGWvRtlmQPQqnEn2XCFxxA=; b=ck10BfAsw4fvmwW1ajuFRc+ufyZhuupZoL+4Ri2gtkeOoFMoXQZJxIMtxFnA18NkkV U/WbrC91XQj3DfVl5U54ESfG4ijVz0PhVLe7INAZE104679mDhCfYOfDvwBi9HMAGv0i BkZHul6ZhYOfezaRxveEcjGbGPp5DCAtXuXb+/KGsGCk0VXBWVZxU5nv2bXt/2Mg14Et z62g37g95DUFTFWKWUITbWpaq0JuU9PJZG8ENxQj1Gg8/YYVLTRd08IMX9GmBWx7Mnxi cpuIpqHls+ghZeFCazr3LVYyL5+Dm3MBh3b/D9xS8o026gRQX5sUhXEhYt5IsW2K8gGG Q9SQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5322IC1KlOuRyalcJzCvjrTTB76qKgr3SZoXdxKQfRF7VBnaM3Bj L4bG+d/KexKGCMDwnwanYxw= X-Google-Smtp-Source: ABdhPJy9QLd6l7+btGDqrqCrH2tXmMfcpMYaWBx0Z0ANkXUGFXMiLsNOhAcR8QZnekKcR/+H0fdxFw== X-Received: by 2002:a1c:3502:: with SMTP id c2mr1332341wma.79.1605256281020; Fri, 13 Nov 2020 00:31:21 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:c689:: with SMTP id j9ls4279981wrg.0.gmail; Fri, 13 Nov 2020 00:31:20 -0800 (PST) X-Received: by 2002:adf:c443:: with SMTP id a3mr2003276wrg.249.1605256280138; Fri, 13 Nov 2020 00:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256280; cv=none; d=google.com; s=arc-20160816; b=rnknlZEmwD7JhR7TjSe08lJFZLTexjARskY4VOpVKplm5Ki94PYz7DkobAO+tV6IG3 KhQJvIUGTFHnxwNZPRKhc0bDVkRQKVtnbC+gAeaLGaQFLALWhZsFILGudxb0kCFeeo/t FywWYF4vB4ozgNkxY/qPVSdSMiHroWg2nmKLWCNlw4kIagkRtMD5ao7VLW6MMBlGtJmm AIxpkcih9gkinEk+6yBy9lbaNEQXi80MXausITteWAGUlXMAo3W+9q+e8oiDv9XWLVFM xBdW1zDY2biqyvBevWDk/bMrKNCEn12JXamRH4HA3cEz6V4tv12e4iPhRnX+0Xqfx/g3 26DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=P84uLHkfVKN8u+aSOIr5OnMNPOO5Ej8EyxQ8wofZtDY=; b=TCh8sVeqW9ivuFphCJ4xU+xe/mMNmfCsarJKatBKFqrBgw/nJ8fdJzPV+413Tbnqao WcXsqQAD2lDS5BFsVJl7UisUajU2FJLHodQEVliTO5Lq/Mwh7iKo4JKrFgZdLFaqLr08 K0N4vIAfby/JaFxFx04TpuMfDjSDm78ZoTEyiLHAFYzfF38prHGcLyS1XDY490uCMjNK z97Bv1fAGWFBd1lUPGmIPAro5ZslsclzO59f2aCOfAKFCXndbx75XNo+qSKSQl5PZwSB rzixJbTrh//rapwu4xUTAf5uIMXR0Xv7SLTwLXOq0x5/GZJbyvq72nKmgY/9sHkVQXDO z3Fg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id i3si247466wra.1.2020.11.13.00.31.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:20 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWs36qbwz1qs10; Fri, 13 Nov 2020 09:31:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWs36fxwz1tD9Y; Fri, 13 Nov 2020 09:31:19 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id d_CdH-Qeh44c; Fri, 13 Nov 2020 09:31:18 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:18 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id B14AD4540286; Fri, 13 Nov 2020 09:31:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ublbyVouWD0w; Fri, 13 Nov 2020 09:31:15 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id B75584540646; Fri, 13 Nov 2020 09:31:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 02/10] IPC: simplify API using a single structure Date: Fri, 13 Nov 2020 09:31:00 +0100 Message-Id: <20201113083108.12567-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Drop most parameters and move them (info) inside a generic request structure. Signed-off-by: Stefano Babic --- bindings/lua_swupdate.c | 2 +- corelib/channel_curl.c | 9 ++++++--- include/network_ipc.h | 25 ++++++++++++++++++++++--- ipc/network_ipc-if.c | 12 ++++++++++-- ipc/network_ipc.c | 19 ++++++++++++++++--- mongoose/mongoose_interface.c | 6 +++++- tools/swupdate-client.c | 5 ++++- 7 files changed, 64 insertions(+), 14 deletions(-) diff --git a/bindings/lua_swupdate.c b/bindings/lua_swupdate.c index 2fa0b61..d17a596 100644 --- a/bindings/lua_swupdate.c +++ b/bindings/lua_swupdate.c @@ -137,7 +137,7 @@ static int ctrl_connect(lua_State *L) { return 2; } - int connfd = ipc_inst_start_ext(SOURCE_LOCAL, 0, NULL, false); + int connfd = ipc_inst_start_ext(SOURCE_LOCAL, NULL, 0); if (connfd < 0) { lua_pop(L, 1); lua_pushnil(L); diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index a91cf5f..5c80770 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1037,11 +1037,14 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) goto cleanup_header; } + struct swupdate_request req; + swupdate_prepare_req(&req); + req.dry_run = channel_data->dry_run; + req.len = channel_data->info == NULL ? 0 : strlen(channel_data->info); + req.info = channel_data->info; for (int retries = 3; retries >= 0; retries--) { file_handle = ipc_inst_start_ext(channel_data->source, - channel_data->info == NULL ? 0 : strlen(channel_data->info), - channel_data->info, - channel_data->dry_run); + &req, sizeof(struct swupdate_request)); if (file_handle > 0) break; sleep(1); diff --git a/include/network_ipc.h b/include/network_ipc.h index b30f10b..18da134 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -11,6 +11,7 @@ #include #include +#include #include "swupdate_status.h" #ifdef __cplusplus @@ -34,7 +35,8 @@ typedef enum { SWUPDATE_SUBPROCESS, REQ_INSTALL_DRYRUN, SET_AES_KEY, - SET_UPDATE_STATE /* set bootloader ustate */ + SET_UPDATE_STATE, /* set bootloader ustate */ + REQ_INSTALL_EXT } msgtype; /* @@ -77,9 +79,24 @@ typedef struct { msgdata data; } ipc_message; +#define SWUPDATE_API_VERSION 0x1 +/* + * Install structure to be filled before calling + * ipc and async functions + */ +struct swupdate_request { + unsigned int apiversion; + int type; + bool dry_run; + size_t len; + const char *info; + char *software_set; + char *running_mode; +}; + char *get_ctrl_socket(void); int ipc_inst_start(void); -int ipc_inst_start_ext(sourcetype source, size_t len, const char *info, bool dry_run); +int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size); int ipc_send_data(int connfd, char *buf, int size); void ipc_end(int connfd); int ipc_get_status(ipc_message *msg); @@ -91,9 +108,11 @@ typedef int (*writedata)(char **buf, int *size); typedef int (*getstatus)(ipc_message *msg); typedef int (*terminated)(RECOVERY_STATUS status); int ipc_wait_for_complete(getstatus callback); +void swupdate_prepare_req(struct swupdate_request *req); int swupdate_image_write(char *buf, int size); int swupdate_async_start(writedata wr_func, getstatus status_func, - terminated end_func, bool dry_run); + terminated end_func, + void *priv, ssize_t size); int swupdate_set_aes(char *key, char *ivt); #ifdef __cplusplus diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index 6db1522..ba521ec 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -108,7 +108,7 @@ static pthread_t start_ipc_thread(void *(* start_routine) (void *), void *arg) * Only one running request is accepted */ int swupdate_async_start(writedata wr_func, getstatus status_func, - terminated end_func, bool dry_run) + terminated end_func, void *priv, ssize_t size) { struct async_lib *rq; int connfd; @@ -122,7 +122,7 @@ int swupdate_async_start(writedata wr_func, getstatus status_func, rq->get = status_func; rq->end = end_func; - connfd = ipc_inst_start_ext(SOURCE_UNKNOWN, 0, NULL, dry_run); + connfd = ipc_inst_start_ext(SOURCE_UNKNOWN, priv, size); if (connfd < 0) return connfd; @@ -171,3 +171,11 @@ int swupdate_set_aes(char *key, char *ivt) return ipc_send_cmd(&msg); } + +void swupdate_prepare_req(struct swupdate_request *req) { + if (!req) + return; + memset(req, 0, sizeof(struct swupdate_request)); + req->apiversion = SWUPDATE_API_VERSION; + return; +} diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index 9b5d811..d817ffc 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -175,12 +176,24 @@ int ipc_get_status_timeout(ipc_message *msg, unsigned int timeout_ms) return ret; } -int ipc_inst_start_ext(sourcetype source, size_t len, const char *buf, bool dry_run) +int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size) { int connfd; ipc_message msg; ssize_t ret; - + bool dry_run = false; + struct swupdate_request *req = NULL; + size_t len = 0; + const char *buf = NULL; + + if (priv) { + if (size != sizeof(struct swupdate_request)) + return -EINVAL; + req = (struct swupdate_request *)priv; + dry_run = req->dry_run; + len = req->len; + buf = req->info; + } connfd = prepare_ipc(); if (connfd < 0) return -1; @@ -233,7 +246,7 @@ int ipc_inst_start_ext(sourcetype source, size_t len, const char *buf, bool dry_ */ int ipc_inst_start(void) { - return ipc_inst_start_ext(SOURCE_UNKNOWN, 0, NULL, false); + return ipc_inst_start_ext(SOURCE_UNKNOWN, NULL, 0); } /* diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 588f62a..d34262b 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -288,7 +288,11 @@ static void upload_handler(struct mg_connection *nc, int ev, void *p) break; } - fus->fd = ipc_inst_start_ext(SOURCE_WEBSERVER, strlen(mp->file_name), mp->file_name, false); + struct swupdate_request req; + swupdate_prepare_req(&req); + req.len = strlen(mp->file_name); + req.info = mp->file_name; + fus->fd = ipc_inst_start_ext(SOURCE_WEBSERVER, &req, sizeof(req)); if (fus->fd < 0) { mg_http_send_error(nc, 500, "Failed to queue command"); free(fus); diff --git a/tools/swupdate-client.c b/tools/swupdate-client.c index 32928f5..0dc19a2 100644 --- a/tools/swupdate-client.c +++ b/tools/swupdate-client.c @@ -129,8 +129,11 @@ static int send_file(const char* filename) { /* May be set non-zero by end() function on failure */ end_status = EXIT_SUCCESS; + struct swupdate_request req; + swupdate_prepare_req(&req); + req.dry_run = dry_run; rc = swupdate_async_start(readimage, printstatus, - end, dry_run); + end, &req, sizeof(req)); /* return if we've hit an error scenario */ if (rc < 0) { From patchwork Fri Nov 13 08:31:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbcxploxj6ikrbwmixh6qkgqej7av5hy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=nYPZLu6X; dkim-atps=neutral Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (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 4CXWs96Ggwz9sVL for ; Fri, 13 Nov 2020 19:31:25 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id j9sf3561097ljb.3 for ; Fri, 13 Nov 2020 00:31:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256282; cv=pass; d=google.com; s=arc-20160816; b=hHGUo6bke9ofj/t08jAZlWsvvlkKi0rThdDNSXpe6dT0typUc4gynK2UUzu5tUSR8l /lljhCRE/+KbCVHT7hbJW/I7OlNYlUrIT68DXzIasKN+R7uWeo2Wp4b/lCqz8OFYmb85 7Npy1Gjog9GeqPzkIztwtzHt5Og36Pdqdp1n7afTjiQFJ3p+2HvuPcG5n4ByL5lYMJ0q CUApAheI+D1pWr9YcMjYaEOAdBdx9rWVR7mWYe5ujNL/lzlPJsiytenxdZrGmHnIZFhK ipuFXxPkBHfYKPOLIGmWgQWD0cyScjmu4290d3G5dnzDGrf6tsf3zo61QducA4hJ3U7W gCfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=l9kHzr1ipEHeWzsBaSAsZBqk5ncIUgXZ2Z2WDUBftt0=; b=eGxbKK5W6ztpLPpagLiyfdmp1uec4gWxg+ak1FXwvnO42MUEILQP4QeXbwU3UgMrit 8yjmCJIbplXho3z8byiPoXc+GzfZyCtEsgfZ5/JqArXXuKs0Q0BHDiRp3qgAk6QSdX83 v9NwjmrqhI15oHWZh6Yf1pcv5sJXogYT4N6yfVKGfTlfUsgbnHEntPXT+m+n0Zsap2Wb Ail4hxMP4Er66die+UpOPWqIbjlHmmZMYGitF6aq0Z6yJHt/bOseq5wsXdtvzkXTsun3 94T48pMU/Y5jg7VkFJ6pD3hcLMfIl3xRNDbGtwDdLVoO3BMT5EM8X5dY/ugISkWv9i+R R9SA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=l9kHzr1ipEHeWzsBaSAsZBqk5ncIUgXZ2Z2WDUBftt0=; b=nYPZLu6XPXpxD//PSUUNLGQfMZWuwFxQZujx+lHHN5g3lGIPb0zq9LNDIpJVd/V9yW GDymwIMwE1tkhDJaBD2YrNBNf0i41uT2lj9etxTyKfKTDy16TVWrFTfFlgS0yofOWjm+ dFR0eZjf6QbBTUK8dQH+sEmQPBdhUSHO5iAuYzkSGRSv0Sr99RljTOoHxo+Q1Oz502sh QuC3Dzu4F+3xF1CY58/NNyTM+sRJEwGnAC6dTZDtClOgOgdXnh/AteUvsCidmJQbbaht HXemRIcOCAYTcgeGyLICClKXNUDbbRpyc7NsY2ERRBtJBKvzge1T4Ixr7cwwop5Rbl5Q fmBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=l9kHzr1ipEHeWzsBaSAsZBqk5ncIUgXZ2Z2WDUBftt0=; b=BM17lou/GdhPbDGTsQ5/5XnQpVbs4KmXBflgGyfHhA51uENCLynu3BdcQsONjZ/NSN XxDudYjQUuSICACK2JatgR7BU064f7fZgqF01hDU35VhZBGKbiPc7unzgp9Et2vg31RQ hU+nmv0J/VhVbcaIj4ZtlZu9/bpBxSqeY3zpQ54qmesztAVLmHD3P5dptASX7CyvgYC1 n9eGikniRGbKTlZwSl/bx9VWET5lILyxV13u/OCoPsttvGvssKAOE/b0oExC1EheKNCv ISE+WQ2/2uXNxpvZiDNZsWtIIZkn6IlQulVH7q7NGQjTlkQ/9NYocK6OJJJeqjDNj6aD rB7w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531VjCNnyfHBX4O9ygFUeDbR1hip/MAUysLSWlZxUmNVnzXXdnYK 2qFwKEodCO25g+6Ye0azWQc= X-Google-Smtp-Source: ABdhPJxJo/vocU8sEB8qdyamXqimQnvsozzrQjAPTLs6qT8rh9itbpDVNDq+YjqjErfentffcsZpWA== X-Received: by 2002:a2e:860b:: with SMTP id a11mr631449lji.364.1605256282181; Fri, 13 Nov 2020 00:31:22 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:6b0b:: with SMTP id d11ls4007056lfa.1.gmail; Fri, 13 Nov 2020 00:31:21 -0800 (PST) X-Received: by 2002:a19:4843:: with SMTP id v64mr413978lfa.273.1605256280959; Fri, 13 Nov 2020 00:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256280; cv=none; d=google.com; s=arc-20160816; b=QNi3UhCO70gJ6AR5wdDvCfeQi3kHukvUf/K/3UpDgQQaUmOU6/+3MuYt02UAfL29Mx +MpQcFCbmzUKeeDVbBMk98rpH7Se940dFt0ZYewtQ54TPm3JXpryrJLQvpkaBSPkzAoI M1xvdG1CeoFE7tQ5R89YkdFe7KxYTKMjQePTCqmrrpc0tFX2/ocXY3Oy0xYER7FwzhFq /u7qAFJE8rEwy81zzYBPYqk3D/qoBpa2CoFu1a3Kp4be8DL/cksYij4cqElhRvg+IZx/ Fc3dmyl+iotD3P1v6yAlur/bktTu9sAE+4GiM+ZTkYmA7UOX7fu8m80kYZmBTIoWlXWD Txiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=KSN/9Kel+n/1pLs9wnnSS0cx6pDtMckCRl9ZdxqeNkk=; b=QUdvtb1n0dAH6batn//uF5VhWbS0Viyw4K6ylihZ6Alt6s9lOFbyh0+8qZiWaHE2Sd hP53icv4tJbspSlgInSReEUfS/ITl2ZE7RPqu6xHLaZ/S2F5MDIGByMPinWZXr61KA4l Mq8FvJQ5icUmluXO+ZPt/RJDvI8tMIhypJpCppDfaDAw0wuV4eBoseTByLd5Pa2ii5BF DNnr3a1cxR3/TxDLi/3B8nwvxAw2QdRQ4YpikI2/NxNCZSzYZYxWOtRbu4Q8in5vLUUV TzmQcgcOHuCL84pe2HBtLXGZYsXBdYWStEbp2hlLYXmMXzUsq4CLLhMJJ8G/I5k9blfs IPDA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id j2si213916lfe.9.2020.11.13.00.31.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:20 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWs429LQz1qs10; Fri, 13 Nov 2020 09:31:20 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWs41zlrz1tD9Y; Fri, 13 Nov 2020 09:31:20 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id TQILV9rWbC8l; Fri, 13 Nov 2020 09:31:19 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:19 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 50A0445405D7; Fri, 13 Nov 2020 09:31:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7ToxkfJ5XKsV; Fri, 13 Nov 2020 09:31:17 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id C61B54540691; Fri, 13 Nov 2020 09:31:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 03/10] IPC: drop unused parameter and change name Date: Fri, 13 Nov 2020 09:31:01 +0100 Message-Id: <20201113083108.12567-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The "info" buffer used to trigger an update is quite unused. The name of the original SWU is pushed in case of local update, but it is not used. Drop the filename and change the name to a more generic data, as this will be used to pass a request structure with several fields instead of pure formatted strings. Signed-off-by: Stefano Babic --- core/network_thread.c | 4 ---- core/stream_interface.c | 3 +-- include/installer_priv.h | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index 698c139..2c383b7 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -350,7 +350,6 @@ void *network_thread (void *data) if (instp->status == IDLE) { instp->fd = ctrlconnfd; instp->source = msg.data.instmsg.source; - instp->len = min(msg.data.instmsg.len, sizeof(instp->info)); /* * Communicate if a dry run is asked and set it @@ -360,9 +359,6 @@ void *network_thread (void *data) else instp->dry_run = 0; - memcpy(instp->info, msg.data.instmsg.buf, - instp->len); - /* * Prepare answer */ diff --git a/core/stream_interface.c b/core/stream_interface.c index 8285c72..633116d 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -607,8 +607,7 @@ void *network_initializer(void *data) int get_install_info(sourcetype *source, char *buf, size_t len) { len = min(len, inst.len); - - memcpy(buf, inst.info, len); + memcpy(buf, inst.data, len); *source = inst.source; return len; diff --git a/include/installer_priv.h b/include/installer_priv.h index a84143d..9322a68 100644 --- a/include/installer_priv.h +++ b/include/installer_priv.h @@ -19,7 +19,7 @@ struct installer { sourcetype source; /* Who triggered the update */ int dry_run; /* set it if no changes in hardware must be done */ unsigned int len; /* Len of data valid in info, data is optional */ - char info[2048]; /* info */ + char data[2048]; /* This is a placeholder for installation request */ }; #endif From patchwork Fri Nov 13 08:31:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::640; helo=mail-ej1-x640.google.com; envelope-from=swupdate+bncbcxploxj6ikrbxeixh6qkgqestrkrla@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=MEErpIyy; dkim-atps=neutral Received: from mail-ej1-x640.google.com (mail-ej1-x640.google.com [IPv6:2a00:1450:4864:20::640]) (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 4CXWsD0xNXz9sVK for ; Fri, 13 Nov 2020 19:31:27 +1100 (AEDT) Received: by mail-ej1-x640.google.com with SMTP id dx19sf3425561ejb.7 for ; Fri, 13 Nov 2020 00:31:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256284; cv=pass; d=google.com; s=arc-20160816; b=GtJ5b0iCHHZTKeyWaMXOu7gT3+nVmxTE+3h3H80S3VMfcCTQ1iNK+z/ukkLN5X1vaH ps4idmvOAIkhIWok5HU8D1CK+VtxoslMH3DFB3p4uKtazILS0BkjKmR84Z8EzNyf34Br wmKiX7jzhg3ms2WSc2PT/b+3EiFA45J73x9sxypxm40lsIGPfRzx27Xidf4yvTa/Klno xh8mt9Zuzz09pue3NGH+RvnieIb+aJvn4ThzzCDvXxVwo342HVyxF1YohxvGMTWhdj5M fXv9HoC3rmrS5lL24YOlikvZ0oKys4CKUvY20loXj1rikt8kO/nQHqURr3AA/y+XKtZF PcBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=3mAaOiB+X7YOtPl6X4oCmhOc4j3l0xpawAoDzy8L25Y=; b=erAjrdkTC1r2aUHrPgWekNLXqdu+Gu+hLskwIuPSmtH1QnShkNsUtLpveSOBJDVNjz fMksKp7Rn7QjeAUSSPNljmYo0YrJxii3RcMCyjPMqLo2YO+7Mie3Eg6AnjhnraagQJGq fTsiTyVeoP5QAcdL6KC8RiJ4ov2riJ0PyGRXQdOwWCXo7gTZbSsFgqzC80DiNkfT9z1q 89ufR9k+4klVJCIhE6pJ+WFavkqVpN83+2ZHTdoCUkJ2pD6QSyR8F68JS7Hqw7yIMAG3 qDgCKgQGjMnMuCMopWXA0WcmMjUikLxUpYw6a6fX8Mqmt0JBEWqUqYfdOBkvp1Zp4F2K YD1A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=3mAaOiB+X7YOtPl6X4oCmhOc4j3l0xpawAoDzy8L25Y=; b=MEErpIyyO4p8P55ChQwXUjf42EUT33cWSh9rX9fHIKx0X9qrv8JzdKFDBvRIgezEhw fayd+DpsWbmFK0zwdU1cTm7ZYCxOt6i72ivHHoJ6NuvE0pyqn2952eg6cBAgElK+TRj5 2GtYqYy+DRzmwcupSuu5Zt1lN3I5VuSnauLmdUnB9avrkhpSk+vLN1giQmnn6m2APLOE ROldGqI+IV1VJX1gAdqxQZpgyCbjKZia8Wv10T0P5+ngCa2SsbqYsKUgVg3F9/zg0VKo MKP8QAPGSRCES1pGk0VhEIQnXaLkbMdj1r4kaCHoENY+8Y7nZ3RVIPPk1+h5WRjmZ6z+ UsQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=3mAaOiB+X7YOtPl6X4oCmhOc4j3l0xpawAoDzy8L25Y=; b=l3KUhzgRZPLH1oHqzGzTFQ6l+++sceq5pHeXvDHc33aCyiX+rhf5iUlN5geF9LGCzZ ZJhNeNbEGUzqm8px2VhbaDERSTbe3fjY/nRVfUZytoCkYmyYLa8F1hLHORTotbVPRImy NRpK46SIO3L3AIN2NViioHHvkR2/zZrLMYTgUxFqnCNH3/mxMXK1lQoDyTqlYjhPcJ2D 2HJzYMM7Iuauh0mVjs+oF/5n5wR2kfqtJmRFtKuLVQ8eHEBdb/169SeRNGj9s9r7KjT9 85yp/BqP/6xvbhXHIZX3RKOAsaI6LzdcfZqW06pISf3ZIkxvi2/gEAirOawXHnwmkQih 7Slg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532h/abNlKVnY3E5TO9Rjzx/5bl35uCEz7xY0yVpz/qwQhs/D1kg u3piCVbSw3eecLP/XDHu6n4= X-Google-Smtp-Source: ABdhPJx8FSgj1SifsGY6/0atRv7l1Ei2eaKPNN8XhUXNhfWPbsrBY9nNT5+mQkAY6BEhzzLUolZ/yA== X-Received: by 2002:a50:d315:: with SMTP id g21mr1393344edh.84.1605256284797; Fri, 13 Nov 2020 00:31:24 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:a98c:: with SMTP id jr12ls2702230ejb.2.gmail; Fri, 13 Nov 2020 00:31:23 -0800 (PST) X-Received: by 2002:a17:907:119e:: with SMTP id uz30mr889088ejb.125.1605256283700; Fri, 13 Nov 2020 00:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256283; cv=none; d=google.com; s=arc-20160816; b=aSmW/8yey6cXILLiS29+/FoLXhWdXMV2A9IFeVGd7QKm6foxmN86d+e7c/veS0P0fB u8TG6jghJs//vtslpZoe3HJxYUPjV1N7aD2m3/mLpkANv6aCAHjcr1281rtEeeRovgkt Vs7mJdsHXo5xkh8o10fiwHcEM2d+n2hRyYLYUBnIwCm311TK36YbzbIwvcYKL6JOy3fg RoBaKhExmyWRJSIkl0CCSLOI0QLlsJBF55TnzVQljhT1/Pgcy2MxNbQqSdzRYF1Ymn+r /+QObZjzjab/govY1SekxF2VBkDgmjt7X7h6rTVdue5Bd14SNhsoiWdaCPIPKXyZyjZu 4k4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ieubZbmjBRnaYQOhHDslsZEoU2dHyP+F7YdbF5NpKZY=; b=kOHekjQwQaNrNeeZbwdldfJ7gP1AED+/gUWD8zRv4obqjW/4AOSohpv2/BqzICfFvl ZLpIStqjqnKuZTCB6ejHlGeKypN7LIlP/Yrmlp3OkKppNeK5SPTbIEN/aaGqIK4YrN5H NTRhd8+oO4G6fOEizED/rWstR0C275Qb84k1MOFe7uWRHw7MfUXZVKKsR02eD9XbBcYh eU1quN6jyO7JtBMNx/h7liOajmi6Vr01f80f24DwxKkzJXfNR1eEJPt1jcFXmZHaHlzk 3w/kJUWcuMDjJW2Evzdn+wgApv/1JErnYYMNgSrXP0Xkl6ytycL5ycy4nXR+1V3kdOCe Z37w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id v7si427695edj.5.2020.11.13.00.31.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:23 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWs73B1bz1qs10; Fri, 13 Nov 2020 09:31:23 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWs72xqYz1tD9Y; Fri, 13 Nov 2020 09:31:23 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id L3ESHY_Jv47Y; Fri, 13 Nov 2020 09:31:21 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:21 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 6697C4540286; Fri, 13 Nov 2020 09:31:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pA3hhu7UfJ7w; Fri, 13 Nov 2020 09:31:18 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id D57DF4540815; Fri, 13 Nov 2020 09:31:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 04/10] IPC: rework install IPC for future extensions Date: Fri, 13 Nov 2020 09:31:02 +0100 Message-Id: <20201113083108.12567-5-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The IPC was originally very simple and used just to send a SWU to SWUpdate. Later, additional features were added to communicate with internal SWUpdate's processes, like suricatta or the installer. The same message for install was (mis)used, letting the interface quite confused. Adding new commands is then difficult, because changes in the messages mean changes in more subsystems.This patch addresses all these topics. The message used to communicate with processes is renamed to "procmsg" from "instmsg", but without changing its fields. A new "instmsg" is created from scratch and this contains an "install request" structuire, that the originator must fill with setup for the installation. Each interface is updated to the new interface. The API ro external processes is changed, but it will contain a field to track the API version and to allow to have compatibility layers in future to avoid further breakages. The "install request" is thought to add more information as in the past, and to allow to change an installation per instance, while most parameters are now set just at the startup via configuration file or command line parameters. Signed-off-by: Stefano Babic --- core/network_thread.c | 20 ++++-------- core/stream_interface.c | 8 ++--- corelib/channel_curl.c | 7 +++-- corelib/downloader.c | 1 + include/installer_priv.h | 6 ++-- include/network_ipc.h | 40 ++++++++++++++---------- ipc/network_ipc.c | 57 ++++++++++++++++------------------ mongoose/mongoose_interface.c | 3 +- suricatta/server_hawkbit.c | 14 ++++----- suricatta/suricatta.c | 6 ++-- tools/swupdate-hawkbitcfg.c | 20 ++++++------ tools/swupdate-sendtohawkbit.c | 12 +++---- 12 files changed, 97 insertions(+), 97 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index 2c383b7..a3c10a0 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -263,7 +263,7 @@ void *network_thread (void *data) switch (msg.type) { case POST_UPDATE: if (postupdate(get_swupdate_cfg(), - msg.data.instmsg.len > 0 ? msg.data.instmsg.buf : NULL) == 0) { + msg.data.procmsg.len > 0 ? msg.data.procmsg.buf : NULL) == 0) { msg.type = ACK; sprintf(msg.data.msg, "Post-update actions successfully executed."); } else { @@ -279,14 +279,14 @@ void *network_thread (void *data) * the payload */ - pipe = pctl_getfd_from_type(msg.data.instmsg.source); + pipe = pctl_getfd_from_type(msg.data.procmsg.source); if (pipe < 0) { ERROR("Cannot find channel for requested process"); msg.type = NACK; break; } TRACE("Received Message for %s", - pctl_getname_from_type(msg.data.instmsg.source)); + pctl_getname_from_type(msg.data.procmsg.source)); if (fcntl(pipe, F_GETFL) < 0 && errno == EBADF) { ERROR("Pipe not available or closed: %d", pipe); msg.type = NACK; @@ -316,10 +316,10 @@ void *network_thread (void *data) FD_ZERO(&pipefds); FD_SET(pipe, &pipefds); tv.tv_usec = 0; - if (!msg.data.instmsg.timeout) + if (!msg.data.procmsg.timeout) tv.tv_sec = DEFAULT_INTERNAL_TIMEOUT; else - tv.tv_sec = msg.data.instmsg.timeout; + tv.tv_sec = msg.data.procmsg.timeout; ret = select(pipe + 1, &pipefds, NULL, NULL, &tv); /* @@ -349,15 +349,7 @@ void *network_thread (void *data) TRACE("Incoming network request: processing..."); if (instp->status == IDLE) { instp->fd = ctrlconnfd; - instp->source = msg.data.instmsg.source; - - /* - * Communicate if a dry run is asked and set it - */ - if (msg.type == REQ_INSTALL_DRYRUN) - instp->dry_run = 1; - else - instp->dry_run = 0; + instp->req = msg.data.instmsg.req; /* * Prepare answer diff --git a/core/stream_interface.c b/core/stream_interface.c index 633116d..e7298d9 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -500,7 +500,7 @@ void *network_initializer(void *data) /* * Check if the dry run flag is overwritten */ - if (inst.dry_run) + if (inst.req.dry_run) software->globals.dry_run = 1; else software->globals.dry_run = 0; @@ -606,9 +606,9 @@ void *network_initializer(void *data) */ int get_install_info(sourcetype *source, char *buf, size_t len) { - len = min(len, inst.len); - memcpy(buf, inst.data, len); - *source = inst.source; + len = min(len - 1, strlen(inst.req.info)); + strncpy(buf, inst.req.info, len); + *source = inst.req.source; return len; } diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 5c80770..bf39063 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1040,8 +1040,11 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) struct swupdate_request req; swupdate_prepare_req(&req); req.dry_run = channel_data->dry_run; - req.len = channel_data->info == NULL ? 0 : strlen(channel_data->info); - req.info = channel_data->info; + req.source = channel_data->source; + if (channel_data->info) { + strncpy(req.info, channel_data->info, + sizeof(req.info) - 1 ); + } for (int retries = 3; retries >= 0; retries--) { file_handle = ipc_inst_start_ext(channel_data->source, &req, sizeof(struct swupdate_request)); diff --git a/corelib/downloader.c b/corelib/downloader.c index 462d379..cda5cb1 100644 --- a/corelib/downloader.c +++ b/corelib/downloader.c @@ -49,6 +49,7 @@ static RECOVERY_STATUS download_from_url(channel_data_t* channel_data) TRACE("Image download started : %s", channel_data->url); RECOVERY_STATUS result = SUCCESS; + channel_data->source = SOURCE_DOWNLOADER; channel_op_res_t chanresult = channel->get_file(channel, channel_data); if (chanresult != CHANNEL_OK) { result = FAILURE; diff --git a/include/installer_priv.h b/include/installer_priv.h index 9322a68..1a7013a 100644 --- a/include/installer_priv.h +++ b/include/installer_priv.h @@ -9,6 +9,7 @@ #define _INSTALLER_PRIV_H #include "swupdate_status.h" +#include "network_ipc.h" struct installer { int fd; /* install image file handle */ @@ -16,10 +17,7 @@ struct installer { RECOVERY_STATUS last_install; /* result from last installation */ int last_error; /* error code if installation failed */ char errormsg[64]; /* error message if installation failed */ - sourcetype source; /* Who triggered the update */ - int dry_run; /* set it if no changes in hardware must be done */ - unsigned int len; /* Len of data valid in info, data is optional */ - char data[2048]; /* This is a placeholder for installation request */ + struct swupdate_request req; }; #endif diff --git a/include/network_ipc.h b/include/network_ipc.h index 18da134..238709f 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -49,6 +49,21 @@ enum { CMD_ENABLE /* Enable or disable suricatta mode */ }; +#define SWUPDATE_API_VERSION 0x1 +/* + * Install structure to be filled before calling + * ipc and async functions + */ +struct swupdate_request { + unsigned int apiversion; + sourcetype source; + bool dry_run; + size_t len; + char info[512]; + char software_set[256]; + char running_mode[256]; +}; + typedef union { char msg[128]; struct { @@ -57,6 +72,14 @@ typedef union { int error; char desc[2048]; } status; + struct { + struct swupdate_request req; + unsigned int len; /* Len of data valid in buf */ + char buf[2048]; /* + * Buffer that each source can fill + * with additional information + */ + } instmsg; struct { sourcetype source; /* Who triggered the update */ int cmd; /* Optional encoded command */ @@ -66,7 +89,7 @@ typedef union { * Buffer that each source can fill * with additional information */ - } instmsg; + } procmsg; struct { char key_ascii[65]; /* Key size in ASCII (256 bit, 32 bytes bin) + termination */ char ivt_ascii[33]; /* Key size in ASCII (16 bytes bin) + termination */ @@ -79,21 +102,6 @@ typedef struct { msgdata data; } ipc_message; -#define SWUPDATE_API_VERSION 0x1 -/* - * Install structure to be filled before calling - * ipc and async functions - */ -struct swupdate_request { - unsigned int apiversion; - int type; - bool dry_run; - size_t len; - const char *info; - char *software_set; - char *running_mode; -}; - char *get_ctrl_socket(void); int ipc_inst_start(void); int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size); diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index d817ffc..71bbb50 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -72,20 +72,20 @@ int ipc_postupdate(ipc_message *msg) { ssize_t ret; char* tmpbuf = NULL; - if (msg->data.instmsg.len > 0) { - if ((tmpbuf = strndupa(msg->data.instmsg.buf, - msg->data.instmsg.len > sizeof(msg->data.instmsg.buf) - ? sizeof(msg->data.instmsg.buf) - : msg->data.instmsg.len)) == NULL) { + if (msg->data.procmsg.len > 0) { + if ((tmpbuf = strndupa(msg->data.procmsg.buf, + msg->data.procmsg.len > sizeof(msg->data.procmsg.buf) + ? sizeof(msg->data.procmsg.buf) + : msg->data.procmsg.len)) == NULL) { close(connfd); return -1; } } memset(msg, 0, sizeof(*msg)); if (tmpbuf != NULL) { - msg->data.instmsg.buf[sizeof(msg->data.instmsg.buf) - 1] = '\0'; - strncpy(msg->data.instmsg.buf, tmpbuf, sizeof(msg->data.instmsg.buf) - 1); - msg->data.instmsg.len = strnlen(tmpbuf, sizeof(msg->data.instmsg.buf) - 1); + msg->data.procmsg.buf[sizeof(msg->data.procmsg.buf) - 1] = '\0'; + strncpy(msg->data.procmsg.buf, tmpbuf, sizeof(msg->data.procmsg.buf) - 1); + msg->data.procmsg.len = strnlen(tmpbuf, sizeof(msg->data.procmsg.buf) - 1); } msg->magic = IPC_MAGIC; msg->type = POST_UPDATE; @@ -181,18 +181,28 @@ int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size) int connfd; ipc_message msg; ssize_t ret; - bool dry_run = false; - struct swupdate_request *req = NULL; - size_t len = 0; - const char *buf = NULL; + struct swupdate_request *req; + struct swupdate_request localreq; + if (priv) { + /* + * To be expanded: in future if more API will + * be supported, a conversion will be take place + * to send to the installer a single identifiable + * request + */ if (size != sizeof(struct swupdate_request)) return -EINVAL; req = (struct swupdate_request *)priv; - dry_run = req->dry_run; - len = req->len; - buf = req->info; + } else { + /* + * ensure that a valid install request + * reaches the installer, add an empty + * one with default values + */ + swupdate_prepare_req(&localreq); + req = &localreq; } connfd = prepare_ipc(); if (connfd < 0) @@ -204,22 +214,9 @@ int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size) * Command is request to install */ msg.magic = IPC_MAGIC; - msg.type = (!dry_run) ? REQ_INSTALL : REQ_INSTALL_DRYRUN; - - /* - * Pass data from interface originating - * the update, if any - */ - msg.data.instmsg.source = source; - if (len > sizeof(msg.data.instmsg.buf)) - len = sizeof(msg.data.instmsg.buf); - if (!source) { - msg.data.instmsg.len = 0; - } else { - msg.data.instmsg.len = len; - memcpy(msg.data.instmsg.buf, buf, len); - } + msg.type = REQ_INSTALL; + msg.data.instmsg.req = *req; ret = write(connfd, &msg, sizeof(msg)); if (ret != sizeof(msg)) { close(connfd); diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index d34262b..8bb41bf 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -291,7 +291,8 @@ static void upload_handler(struct mg_connection *nc, int ev, void *p) struct swupdate_request req; swupdate_prepare_req(&req); req.len = strlen(mp->file_name); - req.info = mp->file_name; + strncpy(req.info, mp->file_name, sizeof(req.info) - 1); + req.source = SOURCE_WEBSERVER; fus->fd = ipc_inst_start_ext(SOURCE_WEBSERVER, &req, sizeof(req)); if (fus->fd < 0) { mg_http_send_error(nc, 500, "Failed to queue command"); diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index db82ac8..5373db5 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -1843,8 +1843,8 @@ static server_op_res_t server_activation_ipc(ipc_message *msg) update_state_t update_state = STATE_NOT_AVAILABLE; struct json_object *json_root; - json_root = server_tokenize_msg(msg->data.instmsg.buf, - sizeof(msg->data.instmsg.buf)); + json_root = server_tokenize_msg(msg->data.procmsg.buf, + sizeof(msg->data.procmsg.buf)); if (!json_root) return SERVER_EERR; @@ -1942,7 +1942,7 @@ static server_op_res_t server_activation_ipc(ipc_message *msg) } } - msg->data.instmsg.len = 0; + msg->data.procmsg.len = 0; cleanup: free(details); @@ -1956,8 +1956,8 @@ static server_op_res_t server_configuration_ipc(ipc_message *msg) unsigned int polling; json_object *json_data; - json_root = server_tokenize_msg(msg->data.instmsg.buf, - sizeof(msg->data.instmsg.buf)); + json_root = server_tokenize_msg(msg->data.procmsg.buf, + sizeof(msg->data.procmsg.buf)); if (!json_root) return SERVER_EERR; @@ -1979,7 +1979,7 @@ server_op_res_t server_ipc(ipc_message *msg) { server_op_res_t result = SERVER_OK; - switch (msg->data.instmsg.cmd) { + switch (msg->data.procmsg.cmd) { case CMD_ACTIVATION: result = server_activation_ipc(msg); break; @@ -1996,7 +1996,7 @@ server_op_res_t server_ipc(ipc_message *msg) } else msg->type = ACK; - msg->data.instmsg.len = 0; + msg->data.procmsg.len = 0; return SERVER_OK; } diff --git a/suricatta/suricatta.c b/suricatta/suricatta.c index e5f8cc4..9e07efb 100644 --- a/suricatta/suricatta.c +++ b/suricatta/suricatta.c @@ -46,8 +46,8 @@ static server_op_res_t suricatta_enable(ipc_message *msg) struct json_object *json_root; json_object *json_data; - json_root = server_tokenize_msg(msg->data.instmsg.buf, - sizeof(msg->data.instmsg.buf)); + json_root = server_tokenize_msg(msg->data.procmsg.buf, + sizeof(msg->data.procmsg.buf)); if (!json_root) { msg->type = NACK; ERROR("Wrong JSON message, see documentation"); @@ -92,7 +92,7 @@ static server_op_res_t suricatta_ipc(int fd, time_t *seconds) if (ret != sizeof(msg)) return SERVER_EERR; - switch (msg.data.instmsg.cmd) { + switch (msg.data.procmsg.cmd) { case CMD_ENABLE: result = suricatta_enable(&msg); /* diff --git a/tools/swupdate-hawkbitcfg.c b/tools/swupdate-hawkbitcfg.c index 3ccc24c..2e5a332 100644 --- a/tools/swupdate-hawkbitcfg.c +++ b/tools/swupdate-hawkbitcfg.c @@ -47,16 +47,16 @@ static void send_msg(ipc_message *msg) { int rc; - fprintf(stdout, "Sending: '%s'", msg->data.instmsg.buf); + fprintf(stdout, "Sending: '%s'", msg->data.procmsg.buf); rc = ipc_send_cmd(msg); fprintf(stdout, " returned %d\n", rc); if (rc == 0) { fprintf(stdout, "Server returns %s\n", (msg->type == ACK) ? "ACK" : "NACK"); - if (msg->data.instmsg.len > 0) { + if (msg->data.procmsg.len > 0) { fprintf(stdout, "Returned message: %s\n", - msg->data.instmsg.buf); + msg->data.procmsg.buf); } } } @@ -80,11 +80,11 @@ int main(int argc, char *argv[]) { } memset(&msg, 0, sizeof(msg)); - msg.data.instmsg.source = SOURCE_SURICATTA; + msg.data.procmsg.source = SOURCE_SURICATTA; msg.type = SWUPDATE_SUBPROCESS; - size = sizeof(msg.data.instmsg.buf); - buf = msg.data.instmsg.buf; + size = sizeof(msg.data.procmsg.buf); + buf = msg.data.procmsg.buf; /* Process options with getopt */ while ((c = getopt_long(argc, argv, "p:edh", @@ -92,12 +92,12 @@ int main(int argc, char *argv[]) { switch (c) { case 'p': opt_p = 1; - msg.data.instmsg.cmd = CMD_CONFIG; + msg.data.procmsg.cmd = CMD_CONFIG; polling_time = strtoul(optarg, NULL, 10); break; case 'e': case 'd': - msg.data.instmsg.cmd = CMD_ENABLE; + msg.data.procmsg.cmd = CMD_ENABLE; opt_e = 1; enable = (c == 'e'); break; @@ -121,12 +121,12 @@ int main(int argc, char *argv[]) { */ if (opt_p) { snprintf(buf, size, "{ \"polling\" : \"%lu\"}", polling_time); - msg.data.instmsg.len = strnlen(buf, size); + msg.data.procmsg.len = strnlen(buf, size); send_msg(&msg); } if (opt_e) { snprintf(buf, size, "{ \"enable\" : %s}", enable ? "true" : "false"); - msg.data.instmsg.len = strnlen(buf, size); + msg.data.procmsg.len = strnlen(buf, size); send_msg(&msg); } diff --git a/tools/swupdate-sendtohawkbit.c b/tools/swupdate-sendtohawkbit.c index 0c65ce4..3701fb9 100644 --- a/tools/swupdate-sendtohawkbit.c +++ b/tools/swupdate-sendtohawkbit.c @@ -43,12 +43,12 @@ int main(int argc, char *argv[]) { } memset(&msg, 0, sizeof(msg)); - msg.data.instmsg.source = SOURCE_SURICATTA; - msg.data.instmsg.cmd = CMD_ACTIVATION; + msg.data.procmsg.source = SOURCE_SURICATTA; + msg.data.procmsg.cmd = CMD_ACTIVATION; msg.type = SWUPDATE_SUBPROCESS; - size = sizeof(msg.data.instmsg.buf); - buf = msg.data.instmsg.buf; + size = sizeof(msg.data.procmsg.buf); + buf = msg.data.procmsg.buf; /* * Build a json string with the command line parameters @@ -91,8 +91,8 @@ int main(int argc, char *argv[]) { else written = snprintf(buf, size, "}"); - fprintf(stdout, "Sending: '%s'", msg.data.instmsg.buf); - msg.data.instmsg.len = strnlen(msg.data.instmsg.buf, sizeof(msg.data.instmsg.buf)); + fprintf(stdout, "Sending: '%s'", msg.data.procmsg.buf); + msg.data.procmsg.len = strnlen(msg.data.procmsg.buf, sizeof(msg.data.procmsg.buf)); rc = ipc_send_cmd(&msg); From patchwork Fri Nov 13 08:31:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::137; helo=mail-lf1-x137.google.com; envelope-from=swupdate+bncbcxploxj6ikrbx4ixh6qkgqef2xlizq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=NrcAblWO; dkim-atps=neutral Received: from mail-lf1-x137.google.com (mail-lf1-x137.google.com [IPv6:2a00:1450:4864:20::137]) (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 4CXWsJ0Y5Sz9sSn for ; Fri, 13 Nov 2020 19:31:31 +1100 (AEDT) Received: by mail-lf1-x137.google.com with SMTP id j66sf3172103lfj.9 for ; Fri, 13 Nov 2020 00:31:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256288; cv=pass; d=google.com; s=arc-20160816; b=SPgb20bOHPN3H0odOFciQ6Pj08YbOrlqNbhOFH92rU7XhM7BlG3/cec0M1W1s7JfJ+ +M+/0qoqKm4MhpyuApnMq5Mp7IAABA8zm5CvZKJ2MPLaovX3JnqvN6U85PV9mcb1R9AH 7QFiw566/qbpbcc7KizKQmjAOu/PmuORfuYBRTsLARoEDTqVsZB1S7BlLQ4SFIWUFplB PxORatNW4txf5oMve+Hl9tE0x0OSXZR+yTdxMBgXfUmcZkMw2O5eaHmTSqbYjVHWyLHb n1xd9QqCH5ZLFp1oNhWWe8eYjvvczJcx+NbjENzF/xIHI7T4irOFMgUHDkhLVbZ0XguF LtUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=ccNbMlWqRt3Ji7yr2tRrHwssgGOJ/nJXImcwjVQLB98=; b=hkNLEB+klQprIiFNCIdvRHBaTCySbGwuD8P0uBiBSfVSzl3OQcu7qft70/xQpnQRoE At492ry/l6Dh9ktMaMDRb2JueyGgSCdJXYKtybrl10Tjh6WBLuodRn4EiLkdZdskIKWz GlJsBjaT3zO57VvchRw3qteiWe6KmQNQeFdLkyQyb1BkqWuDDczVcldjHr01A7fk5CbH 6Z+kJvQ0krwkKKU77P0Wd7YiIkiSYijs5ao0bQN1aAJ8t0mQ4eEYcp2L6Krq6yh6SYOs DlitzOIpsuppY9++TUKUtwtQMhoZyyHs0Dp+mJSStgpH8QYT1rc7LynPROlqKzIYSF/K PO8w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ccNbMlWqRt3Ji7yr2tRrHwssgGOJ/nJXImcwjVQLB98=; b=NrcAblWO6kCdowwqa2mXrBczkevD77xAcOfYUw7IdkgtbLxoSdATuWx3fyWMnxrzc+ ycQ7slSmTg4jq/xMi/2bayc0gyMPS7UyGwnwo6qkivAqNUXnU+uNZexRuPx0Oq4fB/XR bk9R5rH0LVFL1GEtQAUsm8Kg/Jk5J3Y7Ro/akw2oamoVhzbpfJrYMGLLtPbSOEBKf4xB v3bua8WRpjsKdYLtBQf4SKVjlp8shvgVNw2nXHx17HRP9aPGCuNitsvme4uORlO6VTV7 yS30cjcsgOaPYoiOTatkb8/8EafZAue/FL6AEbpb9iQJ+O8kshRM6mxRhwGnPUny3lJT gpyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ccNbMlWqRt3Ji7yr2tRrHwssgGOJ/nJXImcwjVQLB98=; b=EVDN0DqiwUWPvh78yzHVxwQB+6+1IhK8lyisjL34VVA32094vdi8zFAOnKBYsApn4j YBIH2RhZtbMyXrchm61U7GujEg1qh3pKlCxHDNACApxISFzwhV6dbfEQgoGsy66WKqAU JuRjgxZMr+CcgfLe/XkZppn5TdPVz+pPn3ubUi48SS7ptOJTf44KJh+khRU9pas8ZOYl UOVrZe4n0Mhy6Ql54CxsTk6JCJszeb4rqcuQ0J/3rRqMJGQmPpRocTLkPXgAo9ZzdseZ 4Qv7sptFkE3SbXev+lejf5HxR3MOI43TXOGxZ1ODCvb4bbQ9GwLZX8/MChBlbe0CxUmo nIGQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5301oqk6LpdeBKecKEyv6tQoKUKjfDme12wHhjqnm9ltvCVV7xrH ZhNxlk538Vo+WdCKnHSWbA0= X-Google-Smtp-Source: ABdhPJxJrYflr5ZTiTSPDXU1r+fNiRsQCGyz1ejs5SFg01+tixOnZERsdi9qEVa4bw++cfVYccDTuA== X-Received: by 2002:ac2:4195:: with SMTP id z21mr506984lfh.259.1605256287995; Fri, 13 Nov 2020 00:31:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:ccc2:: with SMTP id c185ls4016187lfg.3.gmail; Fri, 13 Nov 2020 00:31:26 -0800 (PST) X-Received: by 2002:ac2:52b3:: with SMTP id r19mr433749lfm.140.1605256286749; Fri, 13 Nov 2020 00:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256286; cv=none; d=google.com; s=arc-20160816; b=jBsqqKUbSohMh+8/HT3Lbhn7iuAf5Ub7pFK74O5C3OWtRJcf6FDu7cDSXWNRkO0l5g uA9leUZiEpjkKTi6swlvfRW3g8BGBVhTd3B9xD58c8M/Y/XPazSiiXApCHHDuijzsyZD FLOYqQH7YcgebFwrt6+0WkBu3ak/tN9Y13yUi1riGv6N5PwEaXYAXMBbrIUkY6v57S6N p8uA/X1HzbHarA0YIPfEh36MQBCGCAWr2GgqM+sE5Jl8hm4TyODcjJuJMtD3mXt9iuY/ KOU70cqrQrfhat47vPqlViHhXWL/hilCyAZt+JaI4BE5cdPNnZ/lAW1OEl6aw0476mTu YdjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ReP8TFd3tUl4PqSv9gotZ6dyV3myxV8sVNMmvhZaCqo=; b=Dv7qS/UmzZ+It3yAIv1PLI4kgmmGLJiKJhdeV9i9AIs4Muc1SSITm/PK2iz5Hf0YrB GumJcSb0lsPG47vboQRFwrQGu5AJj4196L6bu4Hrebvz4lfMe+qbR8E+Rp9jhOShLDGL v8HpqMbhyU/2Y0PsxZoAgxn3SpwaLGan6tR8guaYKeMArsF8MC5SpZI7iZ0W2jtmKNwX mjgvgbXp/5Oe143GQEtd2Fg4CSmOJtI9ovHDjqRk5oeOB8DwxSO/7tFIlNqMizabhhTK LgSjca9jSLa1fUNQpdMTO4xjeirQQI+1EIEU1dYSVHRUqPJdJKFRf7BYuuvsarBEq5h3 v7MA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id 20si200344lfd.10.2020.11.13.00.31.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:26 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWsB1YrYz1rwZx; Fri, 13 Nov 2020 09:31:26 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWsB1L2Cz1tD9Y; Fri, 13 Nov 2020 09:31:26 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id XLMauH5IUdOd; Fri, 13 Nov 2020 09:31:23 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:23 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 3F08B45405D7; Fri, 13 Nov 2020 09:31:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ij8qVfklYiOS; Fri, 13 Nov 2020 09:31:19 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id E3EC24540935; Fri, 13 Nov 2020 09:31:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 05/10] IPC: drop source parameter Date: Fri, 13 Nov 2020 09:31:03 +0100 Message-Id: <20201113083108.12567-6-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , source is part of the request structure passed to the IPC interface and does not need to be explicitely set. Signed-off-by: Stefano Babic --- bindings/lua_swupdate.c | 5 ++++- corelib/channel_curl.c | 3 +-- include/network_ipc.h | 2 +- ipc/network_ipc-if.c | 2 +- ipc/network_ipc.c | 4 ++-- mongoose/mongoose_interface.c | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bindings/lua_swupdate.c b/bindings/lua_swupdate.c index d17a596..3172152 100644 --- a/bindings/lua_swupdate.c +++ b/bindings/lua_swupdate.c @@ -130,6 +130,7 @@ static luaL_Reg ctrl_methods[] = { */ static int ctrl_connect(lua_State *L) { struct ctrl_obj *p = (struct ctrl_obj *) auxiliar_checkclass(L, "swupdate_control", 1); + struct swupdate_request req; if (p->socket != -1) { lua_pop(L, 1); lua_pushnil(L); @@ -137,7 +138,9 @@ static int ctrl_connect(lua_State *L) { return 2; } - int connfd = ipc_inst_start_ext(SOURCE_LOCAL, NULL, 0); + swupdate_prepare_req(&req); + req.source = SOURCE_LOCAL; + int connfd = ipc_inst_start_ext(&req, sizeof(req)); if (connfd < 0) { lua_pop(L, 1); lua_pushnil(L); diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index bf39063..a3e785f 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1046,8 +1046,7 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) sizeof(req.info) - 1 ); } for (int retries = 3; retries >= 0; retries--) { - file_handle = ipc_inst_start_ext(channel_data->source, - &req, sizeof(struct swupdate_request)); + file_handle = ipc_inst_start_ext( &req, sizeof(struct swupdate_request)); if (file_handle > 0) break; sleep(1); diff --git a/include/network_ipc.h b/include/network_ipc.h index 238709f..9558183 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -104,7 +104,7 @@ typedef struct { char *get_ctrl_socket(void); int ipc_inst_start(void); -int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size); +int ipc_inst_start_ext(void *priv, ssize_t size); int ipc_send_data(int connfd, char *buf, int size); void ipc_end(int connfd); int ipc_get_status(ipc_message *msg); diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index ba521ec..fb59339 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -122,7 +122,7 @@ int swupdate_async_start(writedata wr_func, getstatus status_func, rq->get = status_func; rq->end = end_func; - connfd = ipc_inst_start_ext(SOURCE_UNKNOWN, priv, size); + connfd = ipc_inst_start_ext(priv, size); if (connfd < 0) return connfd; diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index 71bbb50..f3097ca 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -176,7 +176,7 @@ int ipc_get_status_timeout(ipc_message *msg, unsigned int timeout_ms) return ret; } -int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size) +int ipc_inst_start_ext(void *priv, ssize_t size) { int connfd; ipc_message msg; @@ -243,7 +243,7 @@ int ipc_inst_start_ext(sourcetype source, void *priv, ssize_t size) */ int ipc_inst_start(void) { - return ipc_inst_start_ext(SOURCE_UNKNOWN, NULL, 0); + return ipc_inst_start_ext(NULL, 0); } /* diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 8bb41bf..e7a2743 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -293,7 +293,7 @@ static void upload_handler(struct mg_connection *nc, int ev, void *p) req.len = strlen(mp->file_name); strncpy(req.info, mp->file_name, sizeof(req.info) - 1); req.source = SOURCE_WEBSERVER; - fus->fd = ipc_inst_start_ext(SOURCE_WEBSERVER, &req, sizeof(req)); + fus->fd = ipc_inst_start_ext(&req, sizeof(req)); if (fus->fd < 0) { mg_http_send_error(nc, 500, "Failed to queue command"); free(fus); From patchwork Fri Nov 13 08:31:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::438; helo=mail-wr1-x438.google.com; envelope-from=swupdate+bncbcxploxj6ikrbxmixh6qkgqeimpak4q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=PhaaZ6e0; dkim-atps=neutral Received: from mail-wr1-x438.google.com (mail-wr1-x438.google.com [IPv6:2a00:1450:4864:20::438]) (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 4CXWsD69JGz9sSn for ; Fri, 13 Nov 2020 19:31:28 +1100 (AEDT) Received: by mail-wr1-x438.google.com with SMTP id z7sf2061882wrl.14 for ; Fri, 13 Nov 2020 00:31:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256286; cv=pass; d=google.com; s=arc-20160816; b=oMo2RfsDVbY7ZUKtfMAL6STc2yG3CxxkASP6HSBoEJ4GrCvT7/PbhzvZn6fa1jOdfo uj8dW/lOUkKvw5QUnwtJ03QVWnSiWpGl17dacFQQSK2fe/uvk4U0uVVuXBkojUDxohMx zkSfxFJwyFS9AqHp1FEf1OVEivOyCQCYsKRJmI4Yttow/IepJc8bGwZaKUIFD92bFXT5 PceZrxNSxSiSNXqv/5iAY7CJ4SPm4Sy7tgXCy6TrHqB707aVdQnsZfY1fnU7I7oWbkS6 h9dtbdc9xhx/zdSfund+6TpHfYZQuGOK0JeBmsAWff1Ki8o7xMwKxXfGsdVPnq++Uewo 5ykA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=B+ryCUU0puDGQhIH+TbWcNHAFPYorxVi00O+x6x06Jk=; b=OXixIHIcCRaOvujWXfK+RgtKNHeUW8HfoZtPl+5dJ0jUTNtTitYq1EE/ygglFWf8Uo NfQL1QLM25IiNiTwqnmxh8HpZllgn6pFNC65ZdCjWqk1FZLxFxUhf1NZ2dHQeh369zdk Ccjy6cLVAw+c/7RvJKdjqZLS8nN8i4pY3yDgTHad8aIQ5QVCpWFIAQ+seLJCGFXMRzd4 HVgaMpgEKoN8an1ZJNv/t8hjVEeLxDJ/6iHofJ10O0kNQu6T/MeG1X8b8WEEqMJbhysv EWTPd07T64cztGDz40i1GIavCle9czjwKaC9+nImF/xHH6EMG+n34nYWZwF93LfIMznY Ac5w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=B+ryCUU0puDGQhIH+TbWcNHAFPYorxVi00O+x6x06Jk=; b=PhaaZ6e0JSQKSgpKZFINwK1iW+P3jzwQLkGpVoKtxoUauBiLCxiYbOJno9tlLcQD1P uqjGWpD91XnC9e1Ol86A36Sdrgio2Ttj0Tjx2PvkPuhOoArMvj62Z+wF0Fo5s2M71MRO JjO95jmHe0sB2PW0xgbK3gQmAEF60dY/piWwVCS5/0YZTdM9tzMlNDVKo0pW62nuMGir DMlwVMFw4ONwsABzDZJLXNppH80q/t3bOPKc8jXaKJ5Ay3wbl1zjc3TUxgrDhFszTU0g 2qxDvYmHEJ9RW0B3J9DdXwWiglWGWiP7Wr65gBxu4y05sn6WwvCSPaeI69Iy5fQxxDFU cC/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=B+ryCUU0puDGQhIH+TbWcNHAFPYorxVi00O+x6x06Jk=; b=bI7bS1fCEHhk0b299NMqnDA4LDZv2JZC5/5w/J9WkiJ+m3zHYEICJhf1KeHHWn0r5N LXiaIP9DOOLByBaWE47R08talukOuIq4wdM2BQIyaqDEw2pt/+sG8Z+fHy0FdrUu0VwV Z5FUJviMcWkj5GoFt3jw3YgAnULEdynb+ET1GVRljxw+x+9appOWDYNG3Q17ngn7TbZp QbF7hgNxKedVRYmXoOL8tlKLJApacA9X3011j1W0TQd3io9BmT1jf9OqMmjR0fxXTLQA H+YG0fCj9vWLHEbfJFgFZQr481Q24+4cCRLDqa4DLJzm7DX7+fpVF9Drpo/A3JN5lSqf AaDQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5300Xw51vat47ecL8PTLrAkwnP+wOj70lFot3E+nIVp0lW2suiQJ l0/lHkaJGdHkrqyz5W1uAw4= X-Google-Smtp-Source: ABdhPJyDtmr2gzlErSTyZ8AvLUbOFil8mpM2v9LDbm07BniQB5UGK8eg8ETXrR16Na0XBFTllFPyHw== X-Received: by 2002:a7b:c11a:: with SMTP id w26mr1387514wmi.78.1605256286178; Fri, 13 Nov 2020 00:31:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:f70d:: with SMTP id r13ls4276281wrp.1.gmail; Fri, 13 Nov 2020 00:31:25 -0800 (PST) X-Received: by 2002:adf:d4c6:: with SMTP id w6mr2009715wrk.71.1605256285209; Fri, 13 Nov 2020 00:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256285; cv=none; d=google.com; s=arc-20160816; b=XP5+OGhhvkaXkcOjDNAGHegRZgW3Zoyh1VfzwzcRO3SX928S3Shdn8+RPa+TuoyK8s ckeGtltooab7myZTYoHp7XmRE+XBNMagDU9Bq9yitznI7a7+Ib4zRlYLIZQuiKvAy2f9 0a5v6JGqlNgI5bCOOK89gK5fMiHiRRCYq3sbP3ZhmQ/ZwHOREDPxEI2wgmp4in1ErdGy XuE96wdUbIRi9BZDrAtM2HIya/4CcTcNHKNUzzuCRaEIyeQemlQXaiesD2tveftKcP4V aNvrg+TP3jyS4aIy3L9ITGI/xIbdxteRHlA8TMl14ynpvVJVAeR1hMj9qbywlXNHbalF AklA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=XYJvVo3ty/MNRHJIfnnGaGtxeTdyVW4zLGsuWda4qyw=; b=Za4EpgYtVF3K7vWgLn54KmkJljENBxsys7ggGvJ7a8oCNi/N04f+optSgI26entQ0/ lSeKxE8oBvqUVbId/xE8zatpATNAkNYWBxW1hs9kHrhm1phXzwj8zn0cjYW33tPhHo1W 5qReAwqNnTwvOynkVBj2GPu1Jm2fVBBQNzqZoYVhOIIGxqF/VlMah5uEKNos7KyrASCL GFDTgN5b59Df2LEsTXf9iAqr73NsSHBSbC/rBn+Qm8YP/JhmeTKqqFmPbZQspTtRASzh /YCyHKe/rfqz0RqoXyz8uBRc5hLK3s+mHcAFmmizAlBStsPRUr9+LgYkNXbtK/Q2uyK5 x+xA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id i3si247472wra.1.2020.11.13.00.31.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:25 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWs90QCVz1qs1F; Fri, 13 Nov 2020 09:31:25 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWs907XYz1tD9Y; Fri, 13 Nov 2020 09:31:25 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id P8lE9QaV-0Xl; Fri, 13 Nov 2020 09:31:24 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:24 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id ECFC74540286; Fri, 13 Nov 2020 09:31:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id b85tUa1dV3pw; Fri, 13 Nov 2020 09:31:21 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id F29BD4540960; Fri, 13 Nov 2020 09:31:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 06/10] Drop REQ_INSTALL_DRYRUN Date: Fri, 13 Nov 2020 09:31:04 +0100 Message-Id: <20201113083108.12567-7-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This becomes obsolete because the dry-run option becomes an option in the request install (swupdate_request) structure. Signed-off-by: Stefano Babic --- core/network_thread.c | 1 - doc/source/swupdate-ipc.rst | 2 +- include/network_ipc.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index a3c10a0..6757cc4 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -345,7 +345,6 @@ void *network_thread (void *data) break; case REQ_INSTALL: - case REQ_INSTALL_DRYRUN: TRACE("Incoming network request: processing..."); if (instp->status == IDLE) { instp->fd = ctrlconnfd; diff --git a/doc/source/swupdate-ipc.rst b/doc/source/swupdate-ipc.rst index d9390c9..a3ccb13 100644 --- a/doc/source/swupdate-ipc.rst +++ b/doc/source/swupdate-ipc.rst @@ -42,7 +42,7 @@ The exchanged packets are described in network_ipc.h Where the fields have the meaning: - magic : a magic number as simple proof of the packet -- type : one of REQ_INSTALL, REQ_INSTALL_DRYRUN, ACK, NACK, +- type : one of REQ_INSTALL, ACK, NACK, GET_STATUS, POST_UPDATE, SWUPDATE_SUBPROCESS, SET_AES_KEY - msgdata : a buffer used by the client to send the image or by SWUpdate to report back notifications and status. diff --git a/include/network_ipc.h b/include/network_ipc.h index 9558183..2e6f75d 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -33,7 +33,6 @@ typedef enum { GET_STATUS, POST_UPDATE, SWUPDATE_SUBPROCESS, - REQ_INSTALL_DRYRUN, SET_AES_KEY, SET_UPDATE_STATE, /* set bootloader ustate */ REQ_INSTALL_EXT From patchwork Fri Nov 13 08:31:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23e; helo=mail-lj1-x23e.google.com; envelope-from=swupdate+bncbcxploxj6ikrbyeixh6qkgqec7qubgi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=tUyYRmij; dkim-atps=neutral Received: from mail-lj1-x23e.google.com (mail-lj1-x23e.google.com [IPv6:2a00:1450:4864:20::23e]) (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 4CXWsJ23wYz9sTv for ; Fri, 13 Nov 2020 19:31:31 +1100 (AEDT) Received: by mail-lj1-x23e.google.com with SMTP id o19sf3555870ljg.17 for ; Fri, 13 Nov 2020 00:31:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256288; cv=pass; d=google.com; s=arc-20160816; b=ydsqVIQBeSQiqjjMM1ocnkru48aTNzxjv2I/v9W8KUcMTw0Luql4iXmdy8x72i+RTD +fjkdKniRqYiArv+gypE88P6usgJwbg02vGhpMRIC24jBtHpgzh8JPVhG9WKPkCrFFbQ 8ui8Ts8JJd+hy64VgaftHIpdbjN60IBLO1KcqO/LwIj5kXTbWKkbeSyRdnRbWI9da1AW m7fOE/22VMfkuVy4UWUfJfymDE7eBdV5fTaN1wCIXmV8E3YJnzqDCxuYr8g8rRLUC7zQ 3rr14YzbRozAPlMJsGOHVH+ENhWyj2xv0Re9vILPrFW30ljisc9tZ28CxVnsBxtXIceW ILOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=ghYbw44wAE9XvPRpcosLMU0MlI1bs0ENl2YcZdw6icQ=; b=Fd57KGRdqJdLhSEmLJayCEsHQMLqhJ0aDV7m6n7bHUMRGbnP2ohHktaxxroiPPFrNH lnceVwn6TZk8qeKk6lF4gi3hCAO6NpcNhczUE+vBZF9YtfxkFWGCN7l+Mtmkz+XuTlPE zBjWusT84/Hbb7s8QYkznwQnolXflUojgF7pk/LZj4WNaCdWKstRV3K8VQOEwe7kaMeV t8Fw/XhmC/vIkafTPAaaahv8WrPEgVbPF+/jQZFOXQ4dg+jmMgeNCOf+oi9TlR3HeSWt HrFzGYNgdnpelQtTbBepkJsv1HG6x+6bl+hvMKTqxritO+oxDYrRU7ZIPmuqoa0MYP5i KqIg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ghYbw44wAE9XvPRpcosLMU0MlI1bs0ENl2YcZdw6icQ=; b=tUyYRmijlC0OO4VmSbWGByEy3oatYATN4dbUE6QsYoYNN/AGi/lBjQ6aYjv+mclmqR 0ZvjKApsTZXtcyelNRS+O3WD7Rwl5ek4GN1R6auhqbTZXRJeoUtAVKmRxjvqoUjcFK7t ndx2Vs6T7kkPImNJci2DfQvGK5vEVZ3yxELDQoW6EhuW4bg3BnFMYE8S8gSSSzk1pDwR 96XVU18wR3fYow5rQTmaoyg5V2hflTln3oRVOyJJ4lT4Cz61xAYZ0MQGwS2XHkWBavzV vBUuLKx+N8kZrIUc2jYfe3+kbkZLw3HAj4yyJZGk4MMy1r36GeHN+kOODrAqnyDvRJAr 9v2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ghYbw44wAE9XvPRpcosLMU0MlI1bs0ENl2YcZdw6icQ=; b=Ijw2IZhep+BU0wUxlie9PCzvtbua+zNwsq9tsLi7CS7CKejxM2+PKBp5nAuBHtpqF1 TWu3is+1+zEi1ikpgwmCUIGCYn3ZlQenCuU2/JtVTqHFazzeM/j/P1hG9SNFQ8iiqM9o BeuucAosFzz5/uIHQtf5xt6iZ69h0+CsreePzHHHC5n/Lx/2oGmZzsB2KkIis5X37KCs OziU9ILyA05WW2SzWUgoJwYHesRyJYpKwqC4Xoh8QpOg1Pual78md0Yje6OJaS+Iy2Ug /3bYgVglu6jakK5GDLxO9IjnAot0xsdE+Ud9MicTMW8fygmW/XcPvNt2LRkCxWjodhKm ThwQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531v9xeWXOjoG1efm9GtTWPAPgaSSAcOmHNApuJhCz1z9vebfb81 GQVD63zqe5ff7bsUQlPUkms= X-Google-Smtp-Source: ABdhPJzoMQ4z2Juvq/9TajTdmuSbnLBH+Negu5PlqI36vEI+vDBCT5Ogkvjy1Mh5r7D+0XwE9yDFEA== X-Received: by 2002:ac2:490f:: with SMTP id n15mr472816lfi.158.1605256288756; Fri, 13 Nov 2020 00:31:28 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:998f:: with SMTP id w15ls1080634lji.4.gmail; Fri, 13 Nov 2020 00:31:27 -0800 (PST) X-Received: by 2002:a2e:391e:: with SMTP id g30mr676224lja.48.1605256287204; Fri, 13 Nov 2020 00:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256287; cv=none; d=google.com; s=arc-20160816; b=yfPOdZPn5UUITMhyY2ysvyLbiIynuPpkVzpTQz7UZkXB0V/7hXgK5zXibaieJFjcKv 1mMiOr+VkUaOUsJly0wSW770fVrgrTEaz4Tlufj18S05D8vOt0Lu8EDQmmmHK6DuGzCH iiohXv181WsFBinoIwvQP6ysxq+aDPJGA0yJvDxz4cbxWWpjoUQdFij67GlhinWnzUD1 p3A0mjmePbnX/kSXrjlZ92GP26i6w6+i6JHTOaRz5OlTuVc5razlmSgnPyHAVNloIqbJ 3ktVIgfgEngPUOSXhqvCUnSM63EQAN6YmHtDUk3DBU5Hguwj3ZvFmv9VJme84RhtG935 Q32w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=+QMtRZkic2jB4XB5Xg4T1IHiCHIezzuUVTLiB+RZ5To=; b=SuMpO7cMzrrtLaXsMe4sGBF2Ir+OO7tFpQ/5Moo5IPgHAKC3JWroPs8idXiRYVViWT hkjvTMaH4+4h7Nx0gJnei2QdBCl2I3hp4maBBqZ6SOozazi80p+iV/3HOxqJwUUTRRdi hfRcpS1Pku6AlulPjTtMK80hKZcLzDWL3txoghFQMg1sO7Za6ne+Ao3GNPG5LBC0FWnt LnMs+Ut91o0lcUUYi36Mh+zDAFgrrs6IjXjGe85NbQL7a4WQPRmNnFBzKHeHXuOkxxGn 6hIIWKKwUi3rwQt8plgQB/pLnWrNKgwUz3fKNx8aJxkggV+lM44sffe22Byu1/doEgKc cYFw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id z23si243982ljm.6.2020.11.13.00.31.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:27 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWsB4Z5jz1rwb1; Fri, 13 Nov 2020 09:31:26 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWsB4Rdgz1tD9Y; Fri, 13 Nov 2020 09:31:26 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id h3eCXpYPcNo2; Fri, 13 Nov 2020 09:31:25 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:25 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id A1E984540286; Fri, 13 Nov 2020 09:31:25 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tf62mzW_3b-4; Fri, 13 Nov 2020 09:31:23 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 0A70E4540962; Fri, 13 Nov 2020 09:31:12 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 07/10] IPC: let decide selections at runtime Date: Fri, 13 Nov 2020 09:31:05 +0100 Message-Id: <20201113083108.12567-8-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , It is useful to change the selection type at runtime if more as one section inside sw-description can be installed. This activates a selection sent via IPC to be used for the next update. The default configuration is cached and will be active at next update if the request does not contain any valid selection. Signed-off-by: Stefano Babic --- core/stream_interface.c | 19 ++++++++++++++++++- core/swupdate.c | 8 +++++++- include/swupdate.h | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index e7298d9..89ae52e 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -476,6 +476,7 @@ void *network_initializer(void *data) { int ret; struct swupdate_cfg *software = data; + struct swupdate_request *req; /* No installation in progress */ memset(&inst, 0, sizeof(inst)); @@ -497,14 +498,30 @@ void *network_initializer(void *data) pthread_mutex_unlock(&stream_mutex); notify(START, RECOVERY_NO_ERROR, INFOLEVEL, "Software Update started !"); + req = &inst.req; + /* * Check if the dry run flag is overwritten */ - if (inst.req.dry_run) + if (req->dry_run) software->globals.dry_run = 1; else software->globals.dry_run = 0; + /* + * Find the selection to be installed + */ + if ((strnlen(req->software_set, sizeof(req->software_set)) > 0) && + (strnlen(req->running_mode, sizeof(req->running_mode)) > 0)) { + strlcpy(software->software_set, req->software_set, sizeof(software->software_set) - 1); + strlcpy(software->running_mode, req->running_mode, sizeof(software->running_mode) - 1); + } else { + strlcpy(software->software_set, software->globals.default_software_set, + sizeof(software->software_set) - 1); + strlcpy(software->running_mode, software->globals.default_running_mode, + sizeof(software->running_mode) - 1); + } + /* * Check if the stream should be saved */ diff --git a/core/swupdate.c b/core/swupdate.c index 8bbc89e..49b0461 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -414,8 +414,14 @@ static int parse_image_selector(const char *selector, struct swupdate_cfg *sw) *pos = '\0'; + /* + * the runtime copy in swcfg can be overloaded by IPC, + * so maintain a copy to restore it after an update + */ + strlcpy(sw->globals.default_software_set, selector, sizeof(sw->globals.default_software_set)); strlcpy(sw->software_set, selector, sizeof(sw->software_set)); /* pos + 1 will either be NULL or valid text */ + strlcpy(sw->globals.default_running_mode, pos + 1, sizeof(sw->globals.default_running_mode)); strlcpy(sw->running_mode, pos + 1, sizeof(sw->running_mode)); if (strlen(sw->software_set) == 0 || strlen(sw->running_mode) == 0) @@ -986,7 +992,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } fprintf(stderr, "software set: %s mode: %s\n", - swcfg.software_set, swcfg.running_mode); + swcfg.globals.default_software_set, swcfg.globals.default_running_mode); } /* Read sw-versions */ diff --git a/include/swupdate.h b/include/swupdate.h index 29b756d..4ae0b43 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -135,6 +135,8 @@ struct swupdate_global_cfg { char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; char preupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; + char default_software_set[SWUPDATE_GENERAL_STRING_SIZE]; + char default_running_mode[SWUPDATE_GENERAL_STRING_SIZE]; char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; char current_version[SWUPDATE_GENERAL_STRING_SIZE]; int cert_purpose; From patchwork Fri Nov 13 08:31:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::437; helo=mail-wr1-x437.google.com; envelope-from=swupdate+bncbcxploxj6ikrbyeixh6qkgqec7qubgi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=RWf6hf3y; dkim-atps=neutral Received: from mail-wr1-x437.google.com (mail-wr1-x437.google.com [IPv6:2a00:1450:4864:20::437]) (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 4CXWsG6wm4z9sSn for ; Fri, 13 Nov 2020 19:31:30 +1100 (AEDT) Received: by mail-wr1-x437.google.com with SMTP id x16sf3388875wrg.7 for ; Fri, 13 Nov 2020 00:31:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256288; cv=pass; d=google.com; s=arc-20160816; b=XbBMJrwAiT9TB4uHsjz3EEXTkUHH5R9IB5Y+7X3oli6mqe3DH5e/8PocgysvBGHzHM +aaIfnrK+AB2NlbeVy1wAYXheOwKw3MSWY6IvVqXb9SESip0sEH//+XYKRF9xQxAcZ1I DBSIl0oAbynaggPyDunBBQFmbjJM9+d5W7n9mbJgbHR9WJA2V084P+6GIRn72Mk11hy4 wdSHBlRaL0BDxrfcRt2Kt3CA5Cw1EqcZFi5Z+BQDltfy5s7ZoSoBo6zAeoNgQorLOACc XodfjvCDXLJydHdW1GouC2L98lxQNqOZCs1+b8hRIR6XuMk1Ty9HEdLHCfG3Q5lOgBXU OzfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=/4YTe34eefYnTckJV3lf5kEkFAXyiPbsc5+0PkNAcyQ=; b=LZi2arXupd706RjDGf0pPOFO1gBF3omD5ghcAZNmdkbO+/vXQGUdQOjWJ5dR984eLk HSnFYgLbUh8Po0QH4aC3CIR/n1O9dgNvNDAKWrgsv7irHzW93mQdP6tIj4jRhfl4Fc4S pWcHG+daq4jVE+1Xhti07txwOyiVUir41wWuXWkbkH+1xJ90GAa8dGbeQtSUUfEsDNT6 HFQnopioagPyExXJmOI5fHClrru6CVXQ5rpIHKoX0/2pWX+bfOoq0l8EywK3TT1TSJhQ dLfjrJXNs++MlVaqyr27tyvvEFNUijFSBLKUO0CdAzTDzUCMSPffXUGTq1hZkmHg9KWY j74w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=/4YTe34eefYnTckJV3lf5kEkFAXyiPbsc5+0PkNAcyQ=; b=RWf6hf3yJx2R3fi+Auhy0GnqN4ba6RsqI9o/YgKxk5F+st2xevWjk8gZtE5+w7Z3E8 PcGht11tc7OsYbR9v9fGqEJauIqhkP0HTg8BazslUmQ+sBdgW2PLTiwb7nRY1ikL+ydF BRUuQPJhMBzyLIcESW2nA1VnKqzcrJeHyf9apTPXwgS4NDLCrUljAt3hlvcPWKeRt7M1 ur5T7dCKfwmAaoEKXrmWM6U5Uhr+AYlVVsfrd4RKNWzSyDart7jXX8wmzmCXBCeNJ49p IFMJw5x2JzWN853BOXodZHXALGCU/VABXXtUndphNKh7eEpRbKkjQGKTXSPg0CyGmlAC UZyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=/4YTe34eefYnTckJV3lf5kEkFAXyiPbsc5+0PkNAcyQ=; b=sdj7Zloo9UiXhucsVmap8eGS9WQO8qnjXnGP5yiN+Q5qmyRyyk5fEvtWojnAJ9JPDP rYgZPrmJY26hlc7sGna3h3xdUiHJlUqwv7cuaiSoFVsk3TnsXT3reHvi6uofGN29BYG1 KAPmQpL/jPqphxZ3Rdsc9skduKg20njj7CZNMypGI4x1I2wHHAOGr51orYAWmPX0nMyd bhie32clf37d+GuONcU9peAXogv+ACqjMDgDQ0qjwfDH97acvlwvtjefJccUK31Hg56/ JFsQbyA10OCWXSeg52JXi+s4UoshCRPb6Puic57kKZJa9Yao30Sya6kbHWEaDLq+HVuQ 9fsQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530whMA/K64Wn//Seg0D9F/9AUapuG62my0OZMH6nmc0qBohYatM Oto5wti/f/kUdAodu9iLOhs= X-Google-Smtp-Source: ABdhPJxO/TwsSO9iqSv2QPWn+RPaJZo4y2I2sfMbHQ5Py2dpN7HSggiVu52DW/LgSxfqW+XCxPQOqA== X-Received: by 2002:adf:e512:: with SMTP id j18mr2036008wrm.390.1605256288471; Fri, 13 Nov 2020 00:31:28 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:2348:: with SMTP id j69ls2689248wmj.0.gmail; Fri, 13 Nov 2020 00:31:27 -0800 (PST) X-Received: by 2002:a7b:c2ef:: with SMTP id e15mr1381059wmk.180.1605256287397; Fri, 13 Nov 2020 00:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256287; cv=none; d=google.com; s=arc-20160816; b=s+9XUq+dyLQFERCHCiSi/SyLFH86PG/FdIlxwtpMBFAxSKXic9dlyEPxC6SLO3h9ye Mbdnf3gYyru0A2n132A+0tWioqir1D8Q+VKQNbuk2a/uxtZx8v6BpeJrA4HDXQ9PeNFO Kv/mN/k3rVWS8/TRPtGPz8oqrbUqql4Lqw0ACtR4XC70I26XMQNjqf5KGIpVt23/TJzy 0swX5XBumBob4mo/OK8nFbiKExquS9H8ncggszH0Wx6GB67X7PTADFFgiHZDOvWUHCnQ EWUJ/ycazZUckd4lOQgQgb+eQyRVrn1JvbgFHA0Zj6ULUpvuFSm6L5SzaB8mZneRzmjo GNog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=W75AdjWGMESmg5XOTzb7LOUkQMvunT6pwDrzCMXek7I=; b=at8ykmJ6aIAKNfgEfpwsI2B6Xtodp9DiQH00x81kgRvCgE+staOTwcEJZcipR36cyW LSlmzjbfpfdlE/LIEIsdmb4rbbTwn1FYVkY0JTGUYZwxA9ix+6eA/31aeHW6WmKoTUST vLkxjh7LMA3GMTyyaGXjWLqFD0Pp7SDIy/ApNVzOYp+l/SWCF2Ye8KoSgPHTUU8Nl/zu NBwa2tqOlb5orN4t5j0PrriX6M2o6LxqabWmvS2hX+qYtIFqLWP0WY2DgN0JfAbFXAcX mbHRUIZji6XuILHzSh+hHUSarz8qjvdPfaCWF3W8H/TttIY17jffOAi2uWCbCJbjF5i9 NqVg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id t1si236997wmi.0.2020.11.13.00.31.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:27 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWsC1dNRz1qs3H; Fri, 13 Nov 2020 09:31:27 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWsC1X0Vz1tD9Y; Fri, 13 Nov 2020 09:31:27 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id moqzICeNl0OB; Fri, 13 Nov 2020 09:31:26 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:26 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 40BA445405D7; Fri, 13 Nov 2020 09:31:26 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id H4bSmHgLIghO; Fri, 13 Nov 2020 09:31:24 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 164F34540973; Fri, 13 Nov 2020 09:31:12 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 08/10] doc: update documentation for IPC Date: Fri, 13 Nov 2020 09:31:06 +0100 Message-Id: <20201113083108.12567-9-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- doc/source/swupdate-ipc.rst | 52 ++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/doc/source/swupdate-ipc.rst b/doc/source/swupdate-ipc.rst index a3ccb13..98f54d0 100644 --- a/doc/source/swupdate-ipc.rst +++ b/doc/source/swupdate-ipc.rst @@ -58,6 +58,13 @@ will be ignored until a new REQ_INSTALL will be received. .. image:: images/API.png +It is recommended to use the client library to communicate with SWUpdate. On the lower +level with direct socket communication, it cannot be guaranteed that the structures +will remain compatible in future. The client library was affected by this issue, too, and it is +changed to accept an opaque interface that will survive to API changes. Compatibility +layers could be added on bedarf in future due to API changes. + + Client Library ============== @@ -71,7 +78,7 @@ The library consists of one function and several call-backs. :: int swupdate_async_start(writedata wr_func, getstatus status_func, - terminated end_func) + terminated end_func, void *req, ssize_t size) typedef int (*writedata)(char **buf, int *size); typedef int (*getstatus)(ipc_message *msg); typedef int (*terminated)(RECOVERY_STATUS status); @@ -89,6 +96,49 @@ of the upgrade. Example about using this library is in the examples/client directory. +The `req` structure is casted to void to ensure API compatibility. Am user +should instantiate it as `struct swupdate_request`. This contains fields that can control +the update process: + +:: + + struct swupdate_request { + unsigned int apiversion; + sourcetype source; + bool dry_run; + size_t len; + char info[512]; + char software_set[256]; + char running_mode[256]; + }; + +A user should first call `swupdate_prepare_req()` + +:: + void swupdate_prepare_req(struct swupdate_request *req); + +This fills the request sturcture with default values. After that, the user can fill the +other fields as: + + - *sourcetype* : one of SOURCE_UNKNOWN, SOURCE_WEBSERVER, + SOURCE_SURICATTA, SOURCE_DOWNLOADER, SOURCE_LOCAL + - *dry_run* : true if the update must run without installing on the hardware + - *info, len* : a variable length data that can be forwarded to the progress + interface. The installer in SWUpdate does not evaluate it. + - *software_set* and *running_mode* : this allows to set the `selection` fot the update. + +Functions to set AES keys +------------------------- + +The key for decryption can be set with command line parameter (see `-K`), but it is possible +to set it via IPC. In this way, each update could have a different key. + +:: + + int swupdate_set_aes(char *key, char *ivt) + +The key is for AES-256. The length for key and ivt are then defined by the algorithm amd they are passed as ASCII string, so the length *must* be 64 bytes for key and 32 bytes for IVT. + Functions to control SWUpdate ----------------------------- From patchwork Fri Nov 13 08:31:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::239; helo=mail-lj1-x239.google.com; envelope-from=swupdate+bncbcxploxj6ikrbyuixh6qkgqev3tqcuq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=iI4aZr9J; dkim-atps=neutral Received: from mail-lj1-x239.google.com (mail-lj1-x239.google.com [IPv6:2a00:1450:4864:20::239]) (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 4CXWsL3FC4z9sSn for ; Fri, 13 Nov 2020 19:31:34 +1100 (AEDT) Received: by mail-lj1-x239.google.com with SMTP id w1sf3554128ljm.6 for ; Fri, 13 Nov 2020 00:31:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256291; cv=pass; d=google.com; s=arc-20160816; b=vbdkiZ5Z2inDI/mM48YjG2ZpLV136n5oQro71n3N7jRcGqoRjQMjhzzH0HeR/NDcQN ktTqD6l2S8RjFSbAdddh9p5IJehM/OA0iyUCdqkbEE0NAmA/bc8t98bTb+2ZLHxc4mDC nk9gRLTPEe+G7fBGvjgTeql8h7vf7Pgn1yQWxbpeJcX7Q25x7raoC2dGXwTHqGfXVhxd LhUedfvFB8aoS6xdRjK57FQ88/lY+9kOyfa3lBdquowNBeSQ2lHLPw1ImSPBi2b6cIsK zIzhbIpcOhL1FlQYwgTQW+Si8P7XQ/esOnrKaf/Lem4tp2GjlpLb9WgvfWMe3+rHLJSh PpPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=C3eDuVa/ZhSEa+EFcYCePLmFU/x5h6Dyv1dXMpXbK8U=; b=f5GcOU7k4htsW31GHiwvBSXB3uw7PevVEyFjQp5JVNgfUwJvsrWiHpFHkW4EwC3K69 M8/Ilhk2aWN+osGblwIwBV5u3bXS1+ElhiNKVSt3f7/HnwCGWCDa3LUEkMNjB06ou9aZ dR/koc0m0hwGVNW1R/Tr6O2XQ675Gtmx4fWbuwqrA5t+v6XhsU5if/7SABxShhmdB6bP 5cNvq/Ovf+F/Cm6p7fhhPQ16cpGwIr1tOCanZ48HJSLVUTAavo3V/G4Q98euySYaXjIZ fJw25N11ekVDzVc9hxmXhAYW7V43ML8+zwzcVvb0VCS6lbCqHWAaMidM/JlnIBm6EIPB U8SQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=C3eDuVa/ZhSEa+EFcYCePLmFU/x5h6Dyv1dXMpXbK8U=; b=iI4aZr9JxvoYqwNOmuFtnAza0F8sns1dxqXSmmj/mz2eoD093l5pFf/AJgJDpyVz+N JvdckThx0ChtvleAC/5peTROUUaQAld+CMIuMkYxlRx82luq5lHw8a8Lj+bKa2NECHFS X40IGNF1yxCcjYZ/8/pLi3orALSYzzkeiCTwQK4Ex71JHbP+hzfj9nko0bh1+NZGUlEG TmKyagqE5AtsTou02uF5QhnqiQIk/HaOS7ZMtTN4Dm6+UPfQo/jddohxvYYmyXIbIPCt i827aH6Y3tkzBR/pdios2SUFA1IzSK/7qeLrIf3cuVpFpErRP9IJ60HJaZLAQjiBhW5A HtcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=C3eDuVa/ZhSEa+EFcYCePLmFU/x5h6Dyv1dXMpXbK8U=; b=PporGLDyaa3dc/4QzSJPcFnYmhfr6nWhnQIZwDAQ26Mam4PscCUPayQVYrtw21knmh wwi8sHm5NLlXysDDCXBGU0LLnAfRbkaUVBf3xntmKPjEPoFF+yTWD7rkkCqgTxeXFOVc YWFUQZ1S/2KvXUHXuF/eHpHXVFCQHzZu6jBCOzZ9ei/7MCcIQrOEft9gCLqmkt9JMVUG ulu8La3sRA6wfUX3SJlBaGOYWvBuGwGHd899TRU2AQSKOwHg2o/jyRD8yfNW57vuby9x lnfGqKHkITQ+QMqn1XlN/6VPa1bCyaP3UIjogqMg8aEVlGg3DWS1esW6TUdIf/3sV/8P hH7g== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533qyoftZWLD2L68uN0Z+Qml2JblsckPfUoECcCtdYE0Pt1FwrLk CBs75HLfL/0WHUZ/+6iisks= X-Google-Smtp-Source: ABdhPJxSMIiK4OMB/YkBdjUr18QyxwUM7OQCHZ5LeJZDNgV+pcmUsgRcwxQDvKiQpgybqd+LBRKdKA== X-Received: by 2002:a19:cb93:: with SMTP id b141mr455812lfg.519.1605256291288; Fri, 13 Nov 2020 00:31:31 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:6b0b:: with SMTP id d11ls4007343lfa.1.gmail; Fri, 13 Nov 2020 00:31:30 -0800 (PST) X-Received: by 2002:a19:7f55:: with SMTP id a82mr510382lfd.603.1605256290189; Fri, 13 Nov 2020 00:31:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256290; cv=none; d=google.com; s=arc-20160816; b=WEME4yNdKwn4oOIRgRHUGsq3+i2uxJIn5iYJsQOkQTtri2a6OWTlWfI6uwHX8yMlou PhpEgsNCAnuMF4CLvabBeLAVRDiNMxndpnh7RPFXE5OL2Ihdh9/8yAnrDoJthhnZ1IfG m2Zan4rxveVZ2f8MFXedSAi/2mPuLRZnDt0N4L3CNDMispBhA3MNS3yvofVOEJGhT+Je 91k2rGntmmCQWkBrk93kiwC5mSPG4Tt4WXfm0kEMo8RhRyz2MbLVrqDSfWUu9QWUSP5a oGq9OAi2UPfnsj4asLxnZ8zzUx/FUS70KE8ZVX12F6WBkJ+4pjTFuYEWY9zrtcE1omBf Ir+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=G+yqwqlrsTMiRrxqkpDBbhotRpLl0ug3u8BV6PmMupw=; b=EMf/wG/TOzCA/x94UCvMt0ff4zTqV6BjQV++pbtQ/Z/5eHhu5fgv2Zt7VZYMhjl6Iz 2dTqR7bppiiLqM1dxB+sHSA33FC3OISJY5093/h6d4+xMXOELDXB4IOLBi1dJJxb+khL LkYW9hQOwZ2xUOZz7ujyxNvfGQd8KYPdkbkZTra2ut35O5ONxy1o+vlkrOTpnkj2Y/q5 V86CTK4bKzhp203Sxga3OVRfXnnU8aFadVnBfPx/kgh/flW66j2XZ+uSa2qHL8bNhUjo 64Pb9LUqwCoJyso/eh0qJNK1Y0ROmPYB6hNeh6A9L+7q9wmKQlcLw5iRq6L7K9AjmXsi qbbw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id s15si266501ljo.2.2020.11.13.00.31.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:30 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWsF4jN5z1qs3M; Fri, 13 Nov 2020 09:31:29 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWsF4Q5mz1tD9Y; Fri, 13 Nov 2020 09:31:29 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id fZO9M6nZnlN5; Fri, 13 Nov 2020 09:31:28 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:28 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 5DEC44540286; Fri, 13 Nov 2020 09:31:28 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mfZQ1iZISXBN; Fri, 13 Nov 2020 09:31:25 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 2310E4540986; Fri, 13 Nov 2020 09:31:12 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 09/10] Blacklist for selection Date: Fri, 13 Nov 2020 09:31:07 +0100 Message-Id: <20201113083108.12567-10-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , If selection can be set via IPC, it could be possible to activate a selection that can damage the board. For example, the IPC selects to install into the running rootfs instead of the stand-by copy. Implement a blacklist for selection to block dangerous modes. The parameter --exclude , is added and it can be issued multiple times. Signed-off-by: Stefano Babic --- core/network_thread.c | 55 +++++++++++++++++++++++++++++++++-------- core/swupdate.c | 6 ++++- doc/source/swupdate.rst | 7 ++++++ include/swupdate.h | 1 + 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index 6757cc4..f40b99b 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -56,6 +56,36 @@ static unsigned long nrmsgs = 0; static pthread_mutex_t msglock = PTHREAD_MUTEX_INITIALIZER; +static bool is_selection_allowed(const char *software_set, char *running_mode, + struct dict const *excludedlist) +{ + char *swset = NULL; + struct dict_list *sets; + struct dict_list_elem *selection; + bool allowed = true; + + if (!strlen(software_set)) + return true; + if (ENOMEM_ASPRINTF == + asprintf(&swset, "%s,%s", software_set, running_mode)) { + ERROR("OOM generating selection string"); + return false; + } + sets = dict_get_list((struct dict *)excludedlist, "excluded"); + if (sets && swset) { + LIST_FOREACH(selection, sets, next) { + if (!strcmp(swset, selection->value)) { + allowed = false; + ERROR("Selection %s not allowed, rejected !", + swset); + } + } + free(swset); + } + + return allowed; +} + static void clean_msg(char *msg, char drop) { char *lfpos; @@ -349,17 +379,22 @@ void *network_thread (void *data) if (instp->status == IDLE) { instp->fd = ctrlconnfd; instp->req = msg.data.instmsg.req; + if (is_selection_allowed(instp->req.software_set, + instp->req.running_mode, + &instp->software->excluded_set)) { + /* + * Prepare answer + */ + msg.type = ACK; + + /* Drop all old notification from last run */ + cleanum_msg_list(); + + /* Wake-up the installer */ + pthread_cond_signal(&stream_wkup); + } else + msg.type = NACK; - /* - * Prepare answer - */ - msg.type = ACK; - - /* Drop all old notification from last run */ - cleanum_msg_list(); - - /* Wake-up the installer */ - pthread_cond_signal(&stream_wkup); } else { msg.type = NACK; sprintf(msg.data.msg, "Installation in progress"); diff --git a/core/swupdate.c b/core/swupdate.c index 49b0461..e966aca 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -76,6 +76,7 @@ static struct option long_options[] = { {"loglevel", required_argument, NULL, 'l'}, {"syslog", no_argument, NULL, 'L' }, {"select", required_argument, NULL, 'e'}, + {"excluded-select", required_argument, NULL, 'q'}, {"output", required_argument, NULL, 'o'}, {"dry-run", no_argument, NULL, 'n'}, {"no-downgrading", required_argument, NULL, 'N'}, @@ -661,7 +662,7 @@ int main(int argc, char **argv) #endif memset(main_options, 0, sizeof(main_options)); memset(image_url, 0, sizeof(image_url)); - strcpy(main_options, "vhni:e:l:Lcf:p:P:o:N:R:M"); + strcpy(main_options, "vhni:e:q:l:Lcf:p:P:o:N:R:M"); #ifdef CONFIG_MTD strcat(main_options, "b:"); #endif @@ -858,6 +859,9 @@ int main(int argc, char **argv) if (opt_to_hwrev(optarg, &swcfg.hw) < 0) exit(EXIT_FAILURE); break; + case 'q': + dict_insert_value(&swcfg.excluded_set, "excluded", optarg); + break; #ifdef CONFIG_SURICATTA case 'u': if (asprintf(&suricattaoptions,"%s %s", argv[0], optarg) == diff --git a/doc/source/swupdate.rst b/doc/source/swupdate.rst index 306f2ac..fadc62b 100644 --- a/doc/source/swupdate.rst +++ b/doc/source/swupdate.rst @@ -442,6 +442,13 @@ Command line parameters | | | -e "stable, copy1" ==> install on copy1 | | | | -e "stable, copy2" ==> install on copy2 | +-------------+----------+--------------------------------------------+ +| --excluded | string | ``sel`` is in the format ,.| +| | | It sets a blacklist of selections that | +| | | cannot be used for an update. | +| | | Selections can be activated not only with | +| | | -e, but also via IPC. | +| | | Multiple --excluded are allowed | ++-------------+----------+--------------------------------------------+ | -h | - | Run usage with help. | +-------------+----------+--------------------------------------------+ | -k | string | Available if CONFIG_SIGNED is set. | diff --git a/include/swupdate.h b/include/swupdate.h index 4ae0b43..506d28d 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -158,6 +158,7 @@ struct swupdate_cfg { struct imglist scripts; struct imglist bootscripts; struct dict bootloader; + struct dict excluded_set; struct proclist extprocs; void *dgst; /* Structure for signed images */ struct swupdate_global_cfg globals; From patchwork Fri Nov 13 08:31:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::138; helo=mail-lf1-x138.google.com; envelope-from=swupdate+bncbcxploxj6ikrby4ixh6qkgqe2krrpwq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=rG94NYYM; dkim-atps=neutral Received: from mail-lf1-x138.google.com (mail-lf1-x138.google.com [IPv6:2a00:1450:4864:20::138]) (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 4CXWsN2vyxz9sSn for ; Fri, 13 Nov 2020 19:31:35 +1100 (AEDT) Received: by mail-lf1-x138.google.com with SMTP id e3sf3167839lfd.19 for ; Fri, 13 Nov 2020 00:31:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605256292; cv=pass; d=google.com; s=arc-20160816; b=mKEhQRL3auvwTwwvN/vjNCIypwATlKuVLthy7Lk6SqQ48axRSxwbOd/uEJ/+YdDs9Y 0bjeHWwzXf0ifAF9+6EjlMrtI9WAsiWZByLK8nzU3VrEgtjlsKvzxHTlVQoWBF0T0oel Ne5oiHPQnEYYlMhgPya//3mbyCbZrO9yQok+9nnOtoqkWDlGFFDFHUmQNf7qX4zeoeo+ Cl294gCB8De/WT/TQRdFx6jlVt23gY09hnJ79S6QwuQXnr7wc4zL7esCTfRc6oQ0ulrz Bo7Uq68fj6jtohFHv+70vWQ+nVqKtY46tdgScel35gW7pqy/F4nAe7x1u5f5sgV8Y+eL qcQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=j7PfhvpQ2V6/Qp/yBwmxIrHVSBpnz/n/FLAdvq+QGl4=; b=b1sV7CxogC6bR+s8/rPi94X/kG+gniUt5ifFFjq7xS2Arm84zzwoeImxmwWZ6VYlDB bOxAi6cOM1juUjXA1BwPPKupGaqfog8jgiKv7R+vJ2bGznlEsZpLgGwuX0noDTCz46nY JUx4wmSvBSFU6wKtBnVgDx3QVBvalmeTgrbo0j1jhmbEUwKZe+qlZ3EfnTdyLQyHLph3 q/7HUUwJae1ar787ZvB2gwLDz8ANyZHq+7itinBvbXX4A1tnMB0cz74O4M5oNtvMoDg8 kvV2Cnp9sGMfxTopDEDcWXenqMhSOo4hsUyvjQSYybCVlMI26I7Tijt5CP7eSLxU1D8S W9BQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=j7PfhvpQ2V6/Qp/yBwmxIrHVSBpnz/n/FLAdvq+QGl4=; b=rG94NYYMHo0pZ5kIdKMlpQY8V53tO52HimUyMmEwqtMXqWxMgUq5XJShhmORm1njqD azm6pKu/t4wIw+Ss4NEZqoDeKZ2tEoddyod0Fgd3wLRSmNw+IsJjmj5YSxM4hzRhkrsn TBAf9V06WGedvwz84F+DHwgvnk3E3wBMMILgp+cVN69x5/fGL1XKcyLmujxG2wKtI0Cy ud9wnW3fzZV8aakSMMbIOENnbgIVGchf9gF+1A/QrY+DNPq6d3fk0S3v2k7sGZKa85RC zTWJSGySqV93x3j9RiEmZIMJBncKF3Mc379v2OQLD74DCagPP7Duuz59JlrLTtyWF4R+ hfWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=j7PfhvpQ2V6/Qp/yBwmxIrHVSBpnz/n/FLAdvq+QGl4=; b=jrd8Ghah5Anlzt5ljuHTquIVTA8Igj2j2BLfo/jAUv6GSp6Vv+WI0puGClS7oSN8ZS hd291ggPOjk/3F9jlL20aKB9x+amyeUNOKcKCM+YLU7jPDqE70/FOvk2hpYw829VpA27 PPUwdCWKqMzc3frJUZcVjSHZ68/QfAlWpDXZ1EIPQRYcArwl3j4tGEc/kXqE9LvFc8oS CoNHaZkjQf13MjIA5Zq79HU4Zgr5nEPFG/f9pSSkpoE/U4N96oTASACOWXZ8+yZ8EVzY Pa8/+36ZuU3p5kymloF/bOVBZAlBJTZPzrdeeViSwAdOonwHiw2otKWLHE+L2fTELNdW ZF2g== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5303+sDAygFFcXCPJ/e1oDLw9S7ylQUkRRa8mcwnj95gcwwBXvFt 5WlG+EJWjffj9hXMxNluPXc= X-Google-Smtp-Source: ABdhPJyCuGR39pBVLB+jVFtXdvLMVy2ZoRsygWPmckC4JreUZ01WnOEnmVIl9ugjIYbaoO4l+awgkA== X-Received: by 2002:a05:651c:547:: with SMTP id q7mr612950ljp.390.1605256292047; Fri, 13 Nov 2020 00:31:32 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:b0c1:: with SMTP id g1ls664729ljl.5.gmail; Fri, 13 Nov 2020 00:31:30 -0800 (PST) X-Received: by 2002:a2e:9446:: with SMTP id o6mr570421ljh.203.1605256290771; Fri, 13 Nov 2020 00:31:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605256290; cv=none; d=google.com; s=arc-20160816; b=Z8a8eW8O7AQWretD8ByV7k+keev+iAEE123931JCilSgxI1yVQdkWziKqv7tswrOMc qo5e3zRtJbj+0lyMkh9M4OKKituERHXC8d1m/SgKQ2JTAI4jEQNmn5BSdcms2Z1zyAXe vQmWYkFjdJb5vQDfuWm8lHiSk8TE2vFJxWZjl0YP3cWu13zNKrP+HbDJIsfwVSmXUH7b v09DbexNyJPqW31Ep6iBnG5DsT64qvyq51uyFi/k965/RudFUqjRioP2xU33KdxGla27 15P2+1fcQUVyozMVJoeB2J00PjAV6Mk458BTA0XEu649gN0zHWC/Irst7OTzudyeXz2S oVgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=lAzJ/CqmecH1mHu3ymKLCL+lXTxaUt+KYuEaVekbm/A=; b=qYUb7r3YuR2XTb1q480tgenzRII0pigOH4qldIQhv1eriDfpZmq+WqzEAa5GMFleI1 bg642zp4vQ1sXjL8+P/3+Oxn8a1KkTeQ9DWTVEtmZecjEe5d8SWviOhBXN/oT6g1NdIW K1UDIKjOKumqrgkjfbFH23z/ki6xrlXNFAOLT0/L9u/ArW51NzAwqbnB5+Olm7L/b9X3 VpQtCXABsYrfDeS/Cw1VkavwVgSLqTN1WaZTjqgFrEeQR31UcPN87sV7PF9Bsf/S8ycw 30e4HEbr6kx5A0M0lzZn3gBhpfAkbtjXE72ciI9/cSDeXV6am2q69ymCTyS+yXhZcvDx iItg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id j2si213932lfe.9.2020.11.13.00.31.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 00:31:30 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXWsG1kCxz1rwZx; Fri, 13 Nov 2020 09:31:30 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXWsG1Zkxz1tD9Y; Fri, 13 Nov 2020 09:31:30 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id IOO7I5tN8uYu; Fri, 13 Nov 2020 09:31:29 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 09:31:29 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 3A62A45405D7; Fri, 13 Nov 2020 09:31:29 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id VFiJ2KbukUaw; Fri, 13 Nov 2020 09:31:26 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 2DF3645409A9; Fri, 13 Nov 2020 09:31:12 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 10/10] swupdate-client: supports selection to install Date: Fri, 13 Nov 2020 09:31:08 +0100 Message-Id: <20201113083108.12567-11-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113083108.12567-1-sbabic@denx.de> References: <20201113083108.12567-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This allows to set which part of sw-description should be parsed. Signed-off-by: Stefano Babic --- tools/swupdate-client.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/swupdate-client.c b/tools/swupdate-client.c index 0dc19a2..f6bff6b 100644 --- a/tools/swupdate-client.c +++ b/tools/swupdate-client.c @@ -40,6 +40,8 @@ static void usage(void) { " Available OPTIONS\n" " -h : print help and exit\n" " -d : ask the server to only perform a dry run\n" + " -e, --select , : Select software images set and source\n" + " Ex.: stable,main\n" " -q : go quite, resets verbosity\n" " -v : go verbose, essentially print upgrade status messages from server\n" " -p : ask the server to run post-update commands if upgrade succeeds\n" @@ -52,6 +54,7 @@ int verbose = 1; bool dry_run = false; bool run_postupdate = false; int end_status = EXIT_SUCCESS; +char *software_set = NULL, *running_mode = NULL; pthread_mutex_t mymutex; @@ -132,6 +135,10 @@ static int send_file(const char* filename) { struct swupdate_request req; swupdate_prepare_req(&req); req.dry_run = dry_run; + if (software_set && strlen(software_set)) { + strncpy(req.software_set, software_set, sizeof(req.software_set) - 1); + strncpy(req.running_mode, running_mode, sizeof(req.running_mode) - 1); + } rc = swupdate_async_start(readimage, printstatus, end, &req, sizeof(req)); @@ -161,11 +168,12 @@ static int send_file(const char* filename) { */ int main(int argc, char *argv[]) { int c; + char *pos; pthread_mutex_init(&mymutex, NULL); /* parse command line options */ - while ((c = getopt(argc, argv, "dhqvp")) != EOF) { + while ((c = getopt(argc, argv, "dhqvpe:")) != EOF) { switch (c) { case 'd': dry_run = true; @@ -179,6 +187,16 @@ int main(int argc, char *argv[]) { case 'v': verbose++; break; + case 'e': + pos = strchr(optarg, ','); + if (pos == NULL) { + fprintf(stderr, "Wrong selection %s\n", optarg); + exit (EXIT_FAILURE); + } + *pos++ = '\0'; + software_set = optarg; + running_mode = pos; + break; case 'p': run_postupdate = true; break;