From patchwork Wed Nov 11 12:03:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398189 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::13b; helo=mail-lf1-x13b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbh5gv76qkgqem47mgay@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=ZzWg+V/W; dkim-atps=neutral Received: from mail-lf1-x13b.google.com (mail-lf1-x13b.google.com [IPv6:2a00:1450:4864:20::13b]) (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 4CWNg82s4Fz9sSs for ; Wed, 11 Nov 2020 23:03:47 +1100 (AEDT) Received: by mail-lf1-x13b.google.com with SMTP id e3sf412770lfd.19 for ; Wed, 11 Nov 2020 04:03:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096224; cv=pass; d=google.com; s=arc-20160816; b=PTkm4W5UyWWUSKObzU33l65bbhxUfZrJrl3AuN8xT1wO0yduOaziRjB0+EVsJtfbbP ORY7GN7adJXbprNfSxcgAn5TcR7M1tAHuh7FYLQ2US622/H92RbfyjkLX80PaSd+KdBn PZ3eOwWUH1vKzjEGLc1TGT3B+u12sHvghnMi7YrpifXv+BI7ZFJKevtMpE8DSlSmI9Pz aHIJNrhphVGf5Ax34qvXwyFwxDbQqdw0pJbYZoRZlmLgOTcyHkvtzivz1U1d9xoDZMus TuBWMwLV82jkC/QISulykHqByetJVIQ+TptEohVN05FccInnohTe9M2QrRnPTsjlcU34 ArrA== 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=04R02mD6AnruQ2zD3GHch0m/sMbrVnsrE91d57x9ZO4=; b=C/GHiywSZhDgcovMga8qK5xwH9Qdg9rfATqIuN2Q4hMrJ7oOuUQTOu/KCM+a/xnipN yiSsjtQwlmP6J7R3zGoSm10ngGWhNOr4nAXykcwV53JzMfivbkNxxAHkWCGyDfCVeXGG 1RaPDaSYeOALTDVl8LqPe301LNLZmcdjp6dqiob/Yi/+Thz9hszTxJpA/4+r1M4GmNgL FHY9muOBWmsYDlM0KFvAKOkMHsPb8MpaIDK2folE85qtKNGDbl88mOLGC6UGd57jtpHh 4fE84nXOo3Qo1VjU5ddeVT/P5vxeMJzun+pQuS5EYC8928xOmdAZkcDcSLb2quieNn/g RatA== 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=04R02mD6AnruQ2zD3GHch0m/sMbrVnsrE91d57x9ZO4=; b=ZzWg+V/WH1tZbzu0PcewVsZHDx0+smKSqgco19V1Ne/O6RyqIvQkpuxYOUgfar3uMs kmrqW6Iybnsw6snMcv18vmZmLxI8POuCFm06NIzvcgx12BW43ngWeC+tC20FS2S5vL06 xJunX3lk8nvCSz65op3KLiwes9T/JGpiXeD6UiQllEjyiZrIQK2vZ+Ds3sCbRaBrfKmg Pqfxhi7WDQcHVidpWjJUMqLkgWReC+30NySg+H7Afmo9vd/VQo0/+W9SoQ33W5v1/S79 nI54ckiR7P6hxxhLqcydyfhckvcpPwoLVnohH6PqNR43sY+n1j5LfCLEDSqJHLb5DYxD jfhw== 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=04R02mD6AnruQ2zD3GHch0m/sMbrVnsrE91d57x9ZO4=; b=TdjDcHeS+XrbhLcuGsKqeyFRYBGt3ycGf4cdwFZDQhLuNH3qjAsR/9og+7JZ4r1ZJz UyQ08i2b8FJgV6/FyYatAG1/sML+s/ziTKJRCBbVr5cFLizXYvvL8MQLZ4UItCbncDip whs9Lm5a1sPgglE/QyN6UWuXnEF1B20Q+yvTgUjeIVOd2oa7iDDt6k/U1gqgk1yUfdw8 ZOwE3CQj7wLg5/UsAtzb9IVF7GIf3RPwQfpBSh3LP4XEQlHJRfH6Z9uj4wVu2O1XAK6b fB2C7dlHLFzcNpNOBHSSCMHkFw50nZxr36B3MRWo/1Iqu2o8Cr5QdNaDEfdgvhS8fgqH xZ4A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533zZC10/gP3ZrQ5nb6e6kN0cXHz9MCd8GqmXCQ8+CsBanFqwAro g0N/p4aUkz3/PbKo2U3+eN4= X-Google-Smtp-Source: ABdhPJxw1L2TscyAwH8B7V2MdBLuDMYwbB4bPBLvCQb574R48fsDJZAQCNhucdiaH6FlrOnE4PiCEQ== X-Received: by 2002:a05:651c:30d:: with SMTP id a13mr6674940ljp.386.1605096224009; Wed, 11 Nov 2020 04:03:44 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:d0e:: with SMTP id 14ls2482512lfn.0.gmail; Wed, 11 Nov 2020 04:03:42 -0800 (PST) X-Received: by 2002:a05:6512:6c3:: with SMTP id u3mr10229207lff.9.1605096222749; Wed, 11 Nov 2020 04:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096222; cv=none; d=google.com; s=arc-20160816; b=Hq+hr8RVGJmN3Bq6ZLM+Ou+i02adGPvWIkXQzKTy43YCv8P0HNnfQ8D6/wH8ZsY/pD q1zzjhrg7zyd+qoaRPdk1UHzdJA08TUld+ACHGxJ9QxbEA24pCCJpryyzegokivq6eIj hjtt+pSY52fJEi6ec0ElytHU9nJ/zCaieEUbv38poMkBmO150o1sU8ZbwWrj/CP1EK1u L+VLCwmUthYxuehYVhKZ85kQYrDANiTxUs8/0LPLVIXyKXtuBwDN2toitobYFF7i/LQb KWs7yR+mFvgQRIHq9sn9JxKpv//yDWJ+JvRPx0RSDDlHmc1YLvpGOxOvo2O1phBe4YAa 5LAg== 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=IKNJHnTOhHlN2WwXitva0QHbONbJ49YuJxCmV7LI/c0=; b=qiLA4+hnHMJ0VlTCN0Og4oMHpYiuvTc1HytF00ZYTpUeTjGIVE21s3yK9wbnfYxDuu CoiJqdLqbpKBxWOOAejYIThBRJUpCD7JmDH6aOvL4Hp7ha8M2auIDLqU1Dtv0+gLfsHW nR35hibVMj4xawhAF1VpmWNI1hgPTmRlzw/q/pY//Hlpx0af5R0i3b7gRLhaeRtEMwyZ u2oyJpww5AiAJAcdZ7Wk2Y9n92OOo6RSXCiMJ0uPMCxgiZx5ULA7RuVqlRHZutUgXLps VEwI+kVldiO2xO7eRF25y2wVF+tPIllMvjSU1NcPYKMApbLo3jeu8KJgp/GJCNnOj+Cw 4nQw== 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 f9si65314lfl.3.2020.11.11.04.03.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:42 -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 4CWNg21zzNz1qs3Y; Wed, 11 Nov 2020 13:03:42 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNg21n6Zz1qwTp; Wed, 11 Nov 2020 13:03:42 +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 P29Bn8xgwsz4; Wed, 11 Nov 2020 13:03:41 +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; Wed, 11 Nov 2020 13:03:41 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 0610D4542727; Wed, 11 Nov 2020 13:03:40 +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 ca6DyEpyPvTI; Wed, 11 Nov 2020 13:03:34 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 6D1284542743; Wed, 11 Nov 2020 13:03:30 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/6] IPC: simplify API using a single structure Date: Wed, 11 Nov 2020 13:03:22 +0100 Message-Id: <20201111120327.607444-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-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 a847cc8..27340bd 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 Wed Nov 11 12:03:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398190 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::238; helo=mail-lj1-x238.google.com; envelope-from=swupdate+bncbcxploxj6ikrbingv76qkgqezllc33y@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=kl9Hglkg; dkim-atps=neutral Received: from mail-lj1-x238.google.com (mail-lj1-x238.google.com [IPv6:2a00:1450:4864:20::238]) (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 4CWNg96XN1z9sSf for ; Wed, 11 Nov 2020 23:03:49 +1100 (AEDT) Received: by mail-lj1-x238.google.com with SMTP id s22sf733229ljs.10 for ; Wed, 11 Nov 2020 04:03:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096226; cv=pass; d=google.com; s=arc-20160816; b=ziWrfy95mNOunV1/Dgs/4ZigbkwOOjEkz495RsAEkSa/qRJb+jPLhlxoQSxCDgtjPY hj2sQcOKAEw4L4ToXbVHr3MMPcmADQ9zjJQkP46XuB+A3LBQlWpXdpQJLPiWiWihGzir eyWSKCnK7f3CknQd67qMj99/jwWUKuJBw6hXr5SVqUgSvDXA4wCIKA9MA5CHYPDHkvd+ 0NNuIdSjXa3t5g+Of7wjZ9b48mDyv1DPZjhHAYDWx+vtiOVRLqxoYorTJZ39y5RcLnT/ xxuYge1jNoZAK4PSLU2HuJo4gdVjC0JcATxLUcx5RWN1KAWpRJDYSzbt0jPchxhRzgML NmpQ== 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=O8wFfol2H0ociidb0uaxs9RXOx5pxMSfgxC4WfGnOv4=; b=z0ByCAwhQfE/FOc7ez00kljpQTU8aYGV44Bl7D9j9XCrJeZlFss7/6tRYpgtC7SY9B yMs0KM2ms4h6PWbWfqY/osITbcKGqfX6L54mdGMREeKcGAn+OeAA7wcu/Nr6fxg2UOpe yQ3Qu1U0mwapgoMNtzB/Ir1u7LFMPeMytd8GhS8w5atbEbAAV/VPlGHVDI139l7DGB+j 6yFGkvg0AFfU0iaaoYCyJDLKZqS7R76rsk0/lvsUhX0qoaOBZPH7ub4wGkF92gaZPXLQ jQIjSN2zFjhMPKmg8BSl9RM2b753KBu0H7LIHctthl6RsuBZWwjDzdN2TIrWQ5+qaIU9 mitA== 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=O8wFfol2H0ociidb0uaxs9RXOx5pxMSfgxC4WfGnOv4=; b=kl9Hglkgk3qkVVvmoFreMLE4J/eClZg4lNhwpoPUB9im40BPbBg8oKUdOxGeJNg74o g7gseqx4Z9aGSBQH3CfJfoTRxq3xyzJ79zGNBJuNV/OE2ltcj0eo/j9CyXcdpfV+kFAM 4xDJTHCDQjjxUcw+9ujsxQrv9pyt6uEVIz4+5wJE+A0dTQzErxqg22GfP3MZ8cp+5X9v 0lLBWWRZKaRAPYYJvhBgEfVLX+Er/GafHKrc97U7IdgsP6E82cVzHzGiysnmNndUupBK CWEPH6edr6aFw85ZCyM3KbroYSjPcRP4ygcaZgEkevV2SdmKNEgeWfY+DCGec3EN1nce aClQ== 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=O8wFfol2H0ociidb0uaxs9RXOx5pxMSfgxC4WfGnOv4=; b=gTUz497RgWEdoQkWTCwsJaAj3scins9q7t7lou8IzoS2Y4Kp2aQzJAYt9zUTn0RuQS ZwgFtUNaArOQhhu6FIb1xd7Us+zrcfonzqYNvfTOTCvgw7hgZR0zOCIulmkZXpi9io1V EijHxxUDJO2SE/tDsWeeCZsZwI0WGIljDlBONrrPwuAC4MnwnW49z/t1ySMKFxERuooT oXuPq52DgAw1Sxqy0lKpQnJ3Z8PwqcrsU81hJPz6aKjLC8JRBiiAyv/rGsWMvR+h9yWD elr/jgz827JK7bx3qJ6QKnNVEu3zLY65oXCKQsWOxI3jAnwaDXnQKT30AVZMITEKHQE/ tAJw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530vKscMZzUhCLd1yGhh1eqq6e0ZIhaMKrdz0ED4BKwRiQsUdSUj H3HZJ3+VV8+VRdqDM8ipq0E= X-Google-Smtp-Source: ABdhPJzMpkgCsH6LfzUuNZALD3ULMPTnKMJeopCm2VVB8Pf3ifY1hPat0LmQG6AsWg4zHW425+RcsQ== X-Received: by 2002:a2e:9510:: with SMTP id f16mr9355975ljh.408.1605096225847; Wed, 11 Nov 2020 04:03:45 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:480e:: with SMTP id v14ls2490555lfa.2.gmail; Wed, 11 Nov 2020 04:03:44 -0800 (PST) X-Received: by 2002:a19:a419:: with SMTP id q25mr6852912lfc.410.1605096224629; Wed, 11 Nov 2020 04:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096224; cv=none; d=google.com; s=arc-20160816; b=UOw1No8ABtuy9sFsnka0cPTs//m9u5NEW/oWJIjBTsyzKx9JQj8yv7d5byGGbEbIaU Yt6rkaUNGZViyJt4jOZhGuvzjfjuQN8F+3P4kRgHARmSjse9FlPEGXiPoCH4x0cu34AN N1rbk/Z7+KX8T/SC0aVIVBE4EFOm2mmfDiBQdqnx+73B/AsVx+eqUJv/P+ZJHgs0CWq1 1sJEblPPk76mRNeB7Jdt0afRakweAqXMgiMlonAsusEM5n2vzBScfYrTZIKRwKSfrfFn oCcitVsstPuYb3iheEyY1/9e1n4+7WgfmYsEdYwwHE4O4pfTP9Z+GgOS3htFtJp2sW57 RW8w== 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=aPM4sUDHdPv9yZnAR/CFhCWr7nG2jLhGgFm80kdKD0RaKgR+doEm3WESg+68y/cWK6 rBpCTs1jw9lQgTETNnzHj/POUnVZlTaLElAoA+yC9sAajgbonFasabn1/JKJAICGa6RM 0LUp53eEcDK7ovD0QksuNgFmDYv5tem6UylronUlmHugdoeUC/gu4tuPmehbNtTN3s1j 7TTjYJrDQmwDaK3fMXx3fGNjJr37GiLvlhh0NJxnhH49PRco4zMuu4gXxjR5BXUmByqb ZXXpShG9a7Btn8/sRBKm1QxlR33k/y9wYAlONMbSzUSsbrhZ98pUyNDO6kfS5emBUcEn 9uEA== 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 m18si71935lfr.11.2020.11.11.04.03.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:44 -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 4CWNg419V9z1qs3d; Wed, 11 Nov 2020 13:03:44 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNg40yyzz1qwTp; Wed, 11 Nov 2020 13:03:44 +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 j-Pbsl6kJbgv; Wed, 11 Nov 2020 13:03:43 +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; Wed, 11 Nov 2020 13:03:43 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 38DA645427E5; Wed, 11 Nov 2020 13:03:42 +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 yB6mcfDycnL1; Wed, 11 Nov 2020 13:03:36 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id F16B2454277B; Wed, 11 Nov 2020 13:03:30 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/6] IPC: drop unused parameter and change name Date: Wed, 11 Nov 2020 13:03:23 +0100 Message-Id: <20201111120327.607444-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-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 Wed Nov 11 12:03:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398191 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::439; helo=mail-wr1-x439.google.com; envelope-from=swupdate+bncbcxploxj6ikrbjngv76qkgqe74el3rq@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=kkx9nvMc; dkim-atps=neutral Received: from mail-wr1-x439.google.com (mail-wr1-x439.google.com [IPv6:2a00:1450:4864:20::439]) (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 4CWNgF13Tgz9sSf for ; Wed, 11 Nov 2020 23:03:52 +1100 (AEDT) Received: by mail-wr1-x439.google.com with SMTP id h29sf415093wrb.13 for ; Wed, 11 Nov 2020 04:03:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096229; cv=pass; d=google.com; s=arc-20160816; b=gER/b5ukOWSArEzXUu3IioxeeOUzHSCF7OaaqoM+/dvq5mhnQ4EBzSyNrbjlF2HVhw ET/GPuA/BmFdlxRzmzKRl6FZ+p7q4X3QiB5o5TIhGzcgAFKwgn53PKAVXQAxNlCPEQx0 FqXOunpZtG+QF8bLriq20yrC1WghZCBVPFi70XRhHBmjMDYqftAM2+c6VG6WPtyC5o1L ykDyyC8pkORlJsOIhYbrhE5agofanOfqJWjiF0ib1h0+jMxzcu6eMpfvw7p0dstWSsLR tSYgkOdcBWMwyl+2CckOn64WqcRyz0k8r2H/BBKNIJhV4ICVXG/3q7qIiqyygZRMjBlZ gYZw== 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=fR8ZZ039+OkWm7bdyGQoS3lQOpSLj3j/MOYyPx4EcPA=; b=P1tNJ/HIO8q1C6VOxCfHEKkRfo6lVbMyCQZ60z64FmkPmj0S/rB8NKxIPxYtBUxWLj 2NLAT7Pv5GBGxnP1pbTpnG2yg6lfEw6y5lIRNXf6/trxgNgAeOJpuEdgO1CtohiSb8w+ olFNyJQWNv3RLgZDS6ZKyhOKxSq/20VJLoHkQBb9e8IIAyu11WSaNtzAUSGf9fZaPnqk LGjSCG2aXnHEZy0Lcnfmbg3/gLsjHtiucPm5EbR+07s35VjElfC0cdSVSR6pAcIimWhN lHX+0bUw1j6ZN4XDfudz4n3CRQiE1gNtXhLRzNXbDUuK6Kgz2jttYTSz0PpHBPVrafle q3Zw== 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=fR8ZZ039+OkWm7bdyGQoS3lQOpSLj3j/MOYyPx4EcPA=; b=kkx9nvMcidhv4JLbhaUU37Q4AW5PQgC7UsvdT1GpN+fXEuH6hoaft/7OKNxLt988Ra PmrkOo6IIAUWQSwVXwn41LM6f7Diwbh71t+Zd7JHCmNLKFVxVsw2sWAOuFWbA01rSBmj tJYB1wAo5FRqxGME91hpUvxHl22tmlS+9dVRcehRfVdZDmAlT8QW8flJfY3cImaBBhVF SFfVWCwj+l6RZWCIPU7WLxhj8UKgxecIQo2N4MiafxYb0ex3uZ3MwFhPZWlaJCDBMgSx 2d3OryY5miTW4zMncBLdHFbiSzvVgqM+1jfmqsDkMnvyFbSwiyg9ERTapkSbz9jXWXuV KdxQ== 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=fR8ZZ039+OkWm7bdyGQoS3lQOpSLj3j/MOYyPx4EcPA=; b=suBOwbbMVxe/HVyleAM5m1e9f4FpXoEeaY44nkh1DdU/aLAKdFtZkqHP/T4XhVdG+L FXoo5l4k9wyoSV/MSibrPKF/hjjoGtgsZrEruGzx7q9sPQ8rH6EpRcUFRtkSEmgT01F4 KPtZaxQzZAjTqUFsOlYgaYDvBI1i1JsFcPWGnsrCEDk5Nd67+Nqofok5jxwkFp8zCrat d7iniKustz1fTY0hph+X99rVLTn/U/phMgk99HBvgrhD6lAEUn3RIBuoKcmGX0uE8MOL g6a89K3wOsVExjg1sIPfv03ewNZxoxAvitJ0Loy2ptyznDzW5jCfhiLa95/Z5Nx3twWY 3oTg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531MpYGTKaC5/NHjW7eUjtyNnAY+QPFZD8A9CrU3DPr01QM/Biqm +T8sLC1uaEEgmUqdZ3WoQKk= X-Google-Smtp-Source: ABdhPJxMc/8vpAr5kYtilNLWHnXD1vec1JhQa4/gA6KqsbwjiPBP8AFzKiRpPoahjxp8+QdqmYsx6g== X-Received: by 2002:a1c:7303:: with SMTP id d3mr3998340wmb.152.1605096229612; Wed, 11 Nov 2020 04:03:49 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:f70d:: with SMTP id r13ls2474561wrp.1.gmail; Wed, 11 Nov 2020 04:03:48 -0800 (PST) X-Received: by 2002:adf:efc2:: with SMTP id i2mr7124752wrp.383.1605096228227; Wed, 11 Nov 2020 04:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096228; cv=none; d=google.com; s=arc-20160816; b=CHIFN/RrjjiYMvmuFauT07KjYmiL9JFz/uA/d0pU6uklreF5VXXCYn3/GcUn7BXlGN qlRoZ6s7gdvFYDsn4O2gWZVJR2VNimdUqsY6+oBY4iJTNAJ0Q+b8ZNX1/liIuhH3OSsn xgo6VteL39MypJ7nn1XI3dfJ89A14blkO/PMguxk+fouAWVNd/UGcjSqrXyhex6up3Jz fsUjiFloS79G1M9dXX5cptAYAYKbaVWLdwlbYQmiVieI+/WM6o9OQT9ZpcFm3sFLg1WJ 75CgwgQu+2kKiAe73ch3+N3E72mFxJBGpZNBR7OW4vwtSr6/K4iMwwDeJ2wA0Qif9tHy 5gEg== 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=gDrYoUZ3gG+gtzwdpc+Hl0ITJ65Ue7bjj0+UqfzHTgs=; b=yl18P6YLaj3JUtFWZH48y7DZHlky0JnbR0PS5btDT0hrxx7v8vy34O6sTcBGCoaQj0 uk5sDfjl7CwDtKVpHZ7kGKOlDQTSUb19Gbj/7Lil0gfM15FFmRcb7sKSg8YTocJu0BQO oZcUss883UlziiclZYztnw1MgZ8IGeWSX3zfVOf+loRh5VZmcKyYh1BJEAOvIWo1xCsp YtEYY5mkSA4LtJ2F2CZOxEvR7bRczOJQeizQh+bMpkFQ7Q4nsqKnspA84qBzLM/XY25U ++YG+u3/xHRfaHVfNtSZ8B0Uf9sXbJc3Xgh2dJeJpLZFlkuEwMIJyzPo5tnuzRdCaOCK +LzA== 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 r21si44979wra.4.2020.11.11.04.03.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:48 -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 4CWNg76pb4z1rwZx; Wed, 11 Nov 2020 13:03:47 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNg76YkLz1qyY9; Wed, 11 Nov 2020 13:03:47 +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 uIeTadoX-fjg; Wed, 11 Nov 2020 13:03:46 +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; Wed, 11 Nov 2020 13:03:46 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 529B045427E5; Wed, 11 Nov 2020 13:03:45 +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 CzWD4nxi6Zy8; Wed, 11 Nov 2020 13:03:41 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id A7F074542788; Wed, 11 Nov 2020 13:03:31 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/6] IPC: rework install IPC for future extensions Date: Wed, 11 Nov 2020 13:03:24 +0100 Message-Id: <20201111120327.607444-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-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: , 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 27340bd..c2ba2c0 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 Wed Nov 11 12:03:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398192 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::13d; helo=mail-lf1-x13d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbj5gv76qkgqetqkmdxq@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=baHQ2scJ; dkim-atps=neutral Received: from mail-lf1-x13d.google.com (mail-lf1-x13d.google.com [IPv6:2a00:1450:4864:20::13d]) (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 4CWNgJ0xtxz9sSf for ; Wed, 11 Nov 2020 23:03:55 +1100 (AEDT) Received: by mail-lf1-x13d.google.com with SMTP id a1sf417570lfb.12 for ; Wed, 11 Nov 2020 04:03:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096232; cv=pass; d=google.com; s=arc-20160816; b=NK2u04AV5UXdjTPBlUxaKyI9+bbvIlQy00eoZX0urI6bXdhDA6DbRpMhQrSPDO6QAU rtzFeYMT3vVNDutbhgBnXeot4HgRjr9QuW3+Pq84G08AMeTyhsTtt0QkLjfNxe9h8PjE QtPAyNlLREArJG2muUqJ4x4mC8jCUZZGrCmunGDgqRB5T9z8qVl+rIu7u/IH8OFgyTAx KiC3GYL8xCnACg7o7LO7h1e50qtIieQonPZBUdpzp+nukS0x/y0YdPchBn5+i+EhKmVD 5RSVEJlX1s4xr8c1crImmS34M4rgnHF+9nVmG6Mlqg3AwY2rofQdqzNEJe6eyg0l5NXX pnag== 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=i/NDTtDBpvq1wYeuLV7lZxzwAWJHVoyout2IDukdx2s=; b=yWw+x+FgNO1BKC17l8FN//q2FKwgQBu8kgdNpXWdM8h2+Qcdwow3vIDGItIi26mWVK deLRNTPADY5hCb8oNG4lrHXvBwQM6VIYio3k/kEMwZpbBHg8EismNdgaX6awgaLYxH2p tofLpJFEpiNV8j4LChNMCW9fxSV/Bql4bttuXjvARO2O7FYVIBFxSJYmxlwmojb1vqpL hbbnXr/5SJUD6AmWNqZ3b4yLgXHV+gZ1WgRUxiPmw37LeyRohuLJAG4W85vp2+hswyo1 D9wbG863yNgun14drGdjCG0upBH/uIIg0EiUvQskmYtopmAtvVSj7zExO8lwx1ubmcK+ yV4g== 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=i/NDTtDBpvq1wYeuLV7lZxzwAWJHVoyout2IDukdx2s=; b=baHQ2scJAi7ENjEAeqtOnPGm0BirnmCfLb1rqveOsdvfOpanZYbiO/7Z0Lt3dUf4dj 5zFRgyWIy5QLl8rfz1Mq2ED5+iaXvUfyYAhGUSZrJ7+sr/+IneDOA77SwPjXfQSPMMrJ XPu2jFwm2F84uG88gK37CARjS/+lxDM7W+xzxIhTPkhIEaC+4ExJYMciMHmooUqhzHC1 viUj9ssmcGERXNwbE6CctdcbvvnPvBLxpzrWSYWNHRHnAUrlFWWhKskH0MlAT8eIEkj1 X5ZEbMnbW4HCshS3uYUy4DncIKoZ8VJgviH2dl4DBEq3RDl5d1MN86aP2dwoy54A27br SFSA== 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=i/NDTtDBpvq1wYeuLV7lZxzwAWJHVoyout2IDukdx2s=; b=V15CvpdK0nST6Prr6DWwrzvUK3XljPzLgkqOWoBE8HBrKT2KJlTZ6VunQX1HFPEGiy l8tKZONSBlL4q28p9OnuepWujz+EimbVwdbYPn24DO99mKYcsbxeSOA96in38iRroktz CqVo+s5V5+AjZ7niDu3qWacrZ3LH0BaicraWzTwnXhQq+EFRHbp7QADwx2jperQSseZ/ EF87+NNEe0qniY+Wcac2HT9NxiayzseizWdCxAaLMpv99f/5SV193FGUZfaVMxh+uIv6 sFKq4Kzc3Q6j1XxuFzYMpwCBwhtdxPqSVpLWYiHH413YTFqwYKknVLX2Zfwp10Lkpw+m hMIQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531tmwODaFH+St6U7WAo9EZU2VkTlIVJh+oTeniaWpqPvrxiIs8c LEJN3A3OIjeHMUY2umQvdSo= X-Google-Smtp-Source: ABdhPJyQ9q6WNcRLBPX6k9c2wRJPWKy40t4ntMWhnC47h+4lChwjVq+qyJyMjQ3YDFrnDyBXah2nzA== X-Received: by 2002:a19:241:: with SMTP id 62mr10286596lfc.165.1605096231895; Wed, 11 Nov 2020 04:03:51 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:d0e:: with SMTP id 14ls2482716lfn.0.gmail; Wed, 11 Nov 2020 04:03:50 -0800 (PST) X-Received: by 2002:a19:54f:: with SMTP id 76mr10262034lff.202.1605096230573; Wed, 11 Nov 2020 04:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096230; cv=none; d=google.com; s=arc-20160816; b=DvQbo6uwRDZaIQG328MyLu1sGnhhTdFXAWqf/JHdwoEDDY613MOfKwKHABKsy5ssve sVyLnqDYjRUExxVrXnJNty9c6nsszHB4aYaNrsd+OkwhzN7t32kqiLzemF6FT1mPmjlu /r2IYBIDpZndVG1v+nsAqJwQkZN+sKnf7IBg0iDChWkAzQSS6E1KLYfvusQpGYRYgdvH +aSpb3ApDcUe+BhiRJcpb7fu8x4DaSEwj54hy5BEiTeu27jP2dHGdBnWZF0l/llkqk1E bznxxg4jwkv0qfAHYItguOr2DPYE37MKInBMq8hEABpt69/SDRWl+Wzo7NoLxkMLJLFt RZLw== 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=0rkw2BpGd1h3jwV1tdQI76zkZSXK/IYawyFQtYEbn/I=; b=MseZWBMWnZTq6BD3WyKLiUsaWEBEfnxA9ohhPxIDM2szwKwBDLULH/h/rnlGXtGupq i2TnSmhluOZ75dcshkuHEs9kPdbnDo8oMrNIJL8ypNha0SQC2GvKxCTPxrm6/btYMK/o ST+tt7GZ3dmF0ccTOQSz0gXGRx+JVIt2+TeWoBWVZCL3CiJTn9zsKy68whpB+dvJxjJn nP/or/XlBtgYb/YiWkTPsCJt6jt8NHr9xueeizWowS8pQgFCN5lWd5WBVHwwpMV700Wb lgVFhXQUcWpp+Fq6xR6Hs+/wu6pCq5wFNgAwCSTcUvAjcjihy7tLtPeEp7JlJHPSk59v YQag== 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 v24si71267lfo.5.2020.11.11.04.03.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:50 -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 4CWNgB0NPQz1rwb8; Wed, 11 Nov 2020 13:03:50 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNgB08T9z1qwTp; Wed, 11 Nov 2020 13:03:50 +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 UCcqzOQPBuXT; Wed, 11 Nov 2020 13:03:49 +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; Wed, 11 Nov 2020 13:03:49 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id A311D4542742; Wed, 11 Nov 2020 13:03:47 +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 eiQXVK-RwfLI; Wed, 11 Nov 2020 13:03:42 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 65B9845427AA; Wed, 11 Nov 2020 13:03:32 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 4/6] IPC: drop source parameter Date: Wed, 11 Nov 2020 13:03:25 +0100 Message-Id: <20201111120327.607444-5-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-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 c2ba2c0..0c5ff23 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 Wed Nov 11 12:03:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398193 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::33b; helo=mail-wm1-x33b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbj5gv76qkgqetqkmdxq@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=X82U5Qzc; dkim-atps=neutral Received: from mail-wm1-x33b.google.com (mail-wm1-x33b.google.com [IPv6:2a00:1450:4864:20::33b]) (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 4CWNgJ1d7tz9sSs for ; Wed, 11 Nov 2020 23:03:56 +1100 (AEDT) Received: by mail-wm1-x33b.google.com with SMTP id h2sf827429wmm.0 for ; Wed, 11 Nov 2020 04:03:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096232; cv=pass; d=google.com; s=arc-20160816; b=wNWiCFulCrdr+XYmZXNvq3Nt8pWc5yGe9qGJ87CYrKV33w7UurVQlMwOohFS130PEF cL5NlVV4bEL88mmh1TcHDBSQhYGUy3ugv2kNlOT6E7JXQtjqdpSMoE3FYpvAFmlPCKEO Gp9APyev6uXaV+NxLC934VV5ACfUi8ag8AcUpYnmQ+UqLD8CWL8RlzMVpkaal+zzkf+7 mSEC0yS4UEdvO9SxXJQinlp22L9RQWDlAyjUwAS3CmzZGf+93J3LB/ixF0Ad72SIKO08 Ens7JcSnoX1eF1+YRbmz6rleydYYSpZ1V+Q/sJDltf+OqF598VaDNifjWlEr599tGCjR gtvw== 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=7et86/V3jeNle7WHOytq+vYITWWvOEgGliZwISLURZw=; b=u1QJnBTpJ5XzbUhv2LcLwQlJEHkywWgoTXtJzF/XR6jy39uHwB+JzyGZjjwntBatTS rxuM6GN4Wtb5Zzw2Ilt8oN76Ukzi9Rl4InZjdzHUc5bitSpZ9Ws2A+/f8wr4yrQTK+ZI jpBqQhry8Gjy98z3sP7YHfN7uP/+wo5Hdo5oHC+i+PDtGptYVINCMn8Cbp84s6NtmSzu xrZ8T3vbPRrrS4vxliTqHzWVCyyE9uTh89QDWr7xkr/tRFwCNWZEZJadATVGUCfHbwS+ ob57tJ1SHV+JxrT4+ZefO1MV+kFm1OYbvD6EjtwuIvqX1lW0rNoq0BLTigmDpV2MfcRN 9tCg== 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=7et86/V3jeNle7WHOytq+vYITWWvOEgGliZwISLURZw=; b=X82U5QzcIq9ImiO1lAsIKcwxFTteI8DLs5CuUde0tKyRSjF6D/V71QMdleswRP0g3r ox+Rw/8SDgRTTpayeIt1sd7f61/JxoZLZd8fUEJ8xcpEy5m+QLIEK+yIqHguG/ovUjrw GSddWC1KlTIHAWILsZwfqhzOMdAKQ0QFUroWX9MnIUok287Yjc5qxQeLTA4OsRHwkQeQ m3TlP8VcU1zLHYy7NFR32tYuIKfL1kmJoQdbc7IOylbmh/SUl7ZQwmVRYPTUxgjAr7F+ o6lI9dIov1UHiBs1fGo/ycVa2kZaZNV+uxQsJFJMH2X+TpiJjw5Kmioz9+PvXOak1NAF 9LgA== 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=7et86/V3jeNle7WHOytq+vYITWWvOEgGliZwISLURZw=; b=JelSHccIhM8bMyD8zgBOBpuDr2AgxcgjXEgAQ97Q6whjt/aLGJo5FVzeDV2jgTeKJp Lt2gKaISGHFXTt4cfsBlWhHmpAEvXIfHQtHw9WuSxLUguAQxw33VhT+dEsXsQew9afwB H8MX/UKTo97TOyKt1jQBRvLAjz5QGDP8US6miuPNVmUJ7NK6LOmuatb/c7EaImc1oaaA sNbO5mA1QBTS/OH1JAvZ1Vk6oKZBJvjKWLFcE2QQgm8cYQSx4sdBo6W+HFyovhPuiV/1 fGOq+6G7UY4FBjq0xNcdqjdbIc9BFdNhScDpEQHBj76JeB16UxYR2BcM8pRzRyJjxMU4 QsLw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533+DJTDnZids/8nZW2G0d9lAUYSJymgOwa6Ap6oiF0L8nk5RhJq CwSJ8DD2AaoK8mygEQX0kgU= X-Google-Smtp-Source: ABdhPJx1ODupIEXp8ISPLrlcchduxjaN9KLOn1Vt4W0d5uie4pKV3qV6fED1+yAoWQ6yzGRTzf6jmA== X-Received: by 2002:a1c:bc08:: with SMTP id m8mr3948369wmf.137.1605096232478; Wed, 11 Nov 2020 04:03:52 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a7b:c354:: with SMTP id l20ls1134930wmj.0.canary-gmail; Wed, 11 Nov 2020 04:03:51 -0800 (PST) X-Received: by 2002:a1c:2643:: with SMTP id m64mr3849336wmm.28.1605096231236; Wed, 11 Nov 2020 04:03:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096231; cv=none; d=google.com; s=arc-20160816; b=XL1b1ZT7y6vhJrFXzvOnWRolA0vrzMpLzI1U4oRIzywX7vVINe6kuIyoztVqhmqTLQ h6IaYWrRZ1UnsoeIariZhPuS5+jos26j+KT54ENZW+LXX+agQVTbYwi4GMfx59VJqdBF 74k11S54p10pkR7XIq0r5ymiwoSnToMUiBYtadWbUW/yR96MGv2Ebq72rX3VHJh+GrmE LbAoMoxAo88lhb9AlGvyVsrNwNKdyU3TMuyV+13DZ8SMX7hYsj60xlz6ZFRqH+QUWoGK XbIwVfNMfvNFqCF8lXxosbZi718Bmb+9bex7UVXqu1zFergheSdCyt0G5PdubqOIhKB4 807w== 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=mUpaiYbluAeUwQhCbx8vSE0US2n1a7YihhG6QZNpBTruWFP8mhn5Ht9zcAM3qWpntv f4ojzWemLwzfFI2N81It66yT/U/MaxhTtmALvpXidcENTouoJYB72TirXNvf8ORSWlna Kd/VABCLSSoycYIoPwlqAtJTT/e5RgOnzq92HC4rm+8vD7y+d0WCH+/e4GInF+g0xBjZ NQDx1inRwtlsDDY7vRMahDTBj+kJTh/jU3jLo1jIf5HFLs2KLlu6VDbDQiYlqV5dVav0 GJXfd7uKWzXgwsgJuIszqflN8mA/JigNzLTUcOye7zIz8+OHh97OwrTvsX9+1yclkuHo NBBA== 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 v10si60637wrr.3.2020.11.11.04.03.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:51 -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 4CWNgC01lQz1rwZx; Wed, 11 Nov 2020 13:03:51 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNgB70dKz1qwTp; Wed, 11 Nov 2020 13:03:50 +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 oO62SaQXlzGr; Wed, 11 Nov 2020 13:03:50 +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; Wed, 11 Nov 2020 13:03:50 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 4A71945427AA; Wed, 11 Nov 2020 13:03:49 +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 iPlDNj5T5mne; Wed, 11 Nov 2020 13:03:45 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id DE29D45427AB; Wed, 11 Nov 2020 13:03:32 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 5/6] Drop REQ_INSTALL_DRYRUN Date: Wed, 11 Nov 2020 13:03:26 +0100 Message-Id: <20201111120327.607444-6-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-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 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 Wed Nov 11 12:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398194 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+bncbcxploxj6ikrbk5gv76qkgqe6oqyw7a@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=GZt9rGRK; 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 4CWNgN20Zdz9sSf for ; Wed, 11 Nov 2020 23:03:59 +1100 (AEDT) Received: by mail-lj1-x239.google.com with SMTP id r19sf735554ljj.9 for ; Wed, 11 Nov 2020 04:03:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096235; cv=pass; d=google.com; s=arc-20160816; b=BSR0DeqH/px7Sr8xVynMsVzneoJeiLThUsibHeL+ODqjHiWMKUgMrAXRGBmElE30jw i3p3IfzP8RPVrOTwH/bzpxmS2n1TxnDMSQ5WC34zmth1PH8u625rz+OH4Ykk02u2jw24 qHwN0fmTf1FKhzuPrCiBzdpBTRN10EqKYiyBHEgjSViweoap9Ins9yolUICE/yScE0UT STbmzoKW61RTAFybcWU5+1eeyCPwDcWTpTAZRHn+c9G7fSIdba6JbrBzQiAtCroBEXw0 3cdfs8PekRoDwkaTCf6/3lL6mQYpH7/fwpmaUIru3dO1fyMV1xkN0cs9Lq4Y8FyuX4J6 u90w== 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=HZjrbgTN2TVddIRowmCDKm5wR3nESqO5319a6WYUSvs=; b=boKGo9w5qxAG3Szum3gz5VcnuvT0H1GW2bYL7yQj+rxKyJ8tQsJpfIbZd6ryiFEmpe HKDUW+D5saVR8rGJ6b/XTKw9fPgfOO52KW/fQwXOjEzi5LVTmFP5/NZdbnQeEMbJc2bZ I45po3Sr5izn8WGkMIzIbVvvZOQbLDIISKs1o9dWCSZzv5QFhePj00HCahcvvrdq0Z8e zEjgROK12wiN0F2mNMt6p4i+IaI7rkdHamBYSUuGS28oItmdkvdQmIRoU/SqdaasBnny hdcU3rOKjLtW7cESFbvcERt+BEbpiQDawd59M1lYXisVKvjOTe0HVVjJhfHC9Xnsg14r PWBQ== 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=HZjrbgTN2TVddIRowmCDKm5wR3nESqO5319a6WYUSvs=; b=GZt9rGRKJ34naUX22rWxFzJJJNj2vJid/C1alhNhdg5HGJJSvEBT7XT0CLHG8m4UA2 DfPedscRiTDQmYhjPDf5YsscHcWbhk9Jk34H8RHCbSzS4T5vrWYaXFiw7z/zGr43x9KG kmNFOCbyQa+gIf61m1ldcT3D0okNJilSHOtDyop+fI91M7GgnRQr5sHawe0hrj1/jRGe eDaJn8icdlg4FV829eBQwSPG5I4VCphBdZygDfrJeJq3K4XhO/JbOoN57/psWn5jBweW bYzp2FT46W3Nem6ylUWMxiQQnz8GtSKqzlavuJucpJ8+YWpbEobirSMzH7809YgZUqqp VZtw== 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=HZjrbgTN2TVddIRowmCDKm5wR3nESqO5319a6WYUSvs=; b=t54VvS0WhS3U4ww8ZorKR8iwALZUyTZ3T65clu8smIgkSEKwQ2M+OBJYzA5RPi0YFo ZC07a83X7xgSHGntqWRFyFAzQ4PbN0+eUXr4MuF1sANQb+ZM0b4OoALVIA1u1KrFWni3 bxUSyo+xjx3dDERzTcrmcWeujT5D9ceu7uDwYhvUeeqBNTpDcmOKYGL/3+NrQkXSezZw GsCEwHyOrRK/uFLA3WNGaFvSoxjrz7RheY1nMphrWzt3NRJHcm+UTLKuit6DxDCv5HFY TE/morUyF7LdhPasMLh+LB5RXhmaKEjBnuaUJ2vqcrbgW1PSLlaJpF1El77tZVRcM14I XWMQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533WEIUronG24c9eR7eTm4KGq7JBXq2ezEtkPaUec8nQ83RZTzAJ VBw8Cirqnx0W0HW9MX6c04c= X-Google-Smtp-Source: ABdhPJzolJ0+mcrxYXIN2KSMsS9aw2z+XB1tw20B8qUJiDmiWt4Tz4JlPlVFLmYnuwBJvQfkz2lJzw== X-Received: by 2002:ac2:5141:: with SMTP id q1mr5233823lfd.157.1605096235691; Wed, 11 Nov 2020 04:03:55 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:480e:: with SMTP id v14ls2490829lfa.2.gmail; Wed, 11 Nov 2020 04:03:54 -0800 (PST) X-Received: by 2002:a19:c791:: with SMTP id x139mr4360695lff.513.1605096234617; Wed, 11 Nov 2020 04:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096234; cv=none; d=google.com; s=arc-20160816; b=S49eHP9CE5lkRO2s/8x5fWax6kcNhpcLhPK86MpLPH34ArDN2Zha1MzBiX9/CTxuy3 1XmfZDdKF9gOJHCX6xZ7g194sRfzpMWCTXy9ikZyKjYMvpr3LuXDYmKWz7NJKbKGm+ZR KPyzcvQWVhvTNPM0TBq3hZAiAgz+r33HZ13mnSkRilgCIL2Ctxrh7lGjW+xs7csYqVFn iaIVGIuE2lXKVmz8aTcWMshwIL+tvIFM8YjAaf3jbeUAUohQTDgK1HjaujOKwAsE/MWa oNg0xk57CMoDIVQvujv1nn9UD5RvZ8pXt0x+C5QmnjA7Sk/SyexyrdSjL75IqQfsB3ga IqkA== 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=TnMlWY/Gcyv+P7znerfpvQQZ5B83yGeFf9t7Cj3CyXA=; b=a92A2yX888YqNSFhshgc/DLYM4lDLoiLKuRjE5fnGopsN0khD9bqhWFPn0LTsYUdKE k/IZcJFg3TZAaWLkjhO8wkgQ6a1XXlP+hkqun4fYq2cjPGv3k1xlZtkuBqq68HWPAdTK OshOunM3gSTks7nM7kOXgPv+pdniXvlOXXC/fnO9DnB4jTizGgQ6JyAMtoYn3ovyWBEv sCOsul7wnvyZ5+pb+Zq0DtgxrjVEiMGaeaQYDzvb2OSktmc0/vAKazSuZ2kbclH8rwQ0 S5HODj3pH/R//QXe682rJ7WwAoP+AVRPBp2XZl6/VMB8ALSswp2aG6vDLupXEvfoshZr bSHA== 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 v2si23582ljd.5.2020.11.11.04.03.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:54 -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 4CWNgG167zz1qs3Y; Wed, 11 Nov 2020 13:03:54 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNgG0rPTz1qy6d; Wed, 11 Nov 2020 13:03:54 +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 ausWfYL2XS87; Wed, 11 Nov 2020 13:03:53 +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; Wed, 11 Nov 2020 13:03:53 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id ECA3845427AA; Wed, 11 Nov 2020 13:03:51 +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 veVl1plbY1Qf; Wed, 11 Nov 2020 13:03:48 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 8EA8B45427AD; Wed, 11 Nov 2020 13:03:33 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 6/6] IPC: let decide selections at runtime Date: Wed, 11 Nov 2020 13:03:27 +0100 Message-Id: <20201111120327.607444-7-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-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: , 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 5e5fbaf..ba5d129 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;