From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 94B5758CB for ; Tue, 5 Feb 2019 23:46:01 +0100 (CET) Received: by mail-pg1-f195.google.com with SMTP id z11so2063518pgu.0 for ; Tue, 05 Feb 2019 14:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SITmvhShMHsK/HwMDCh4lz7nTLUoWxQcp/Ds0dhGA6g=; b=xwkV9mzpmZ3ixaM55FFcMIN1d0V5ZZgkbG7FrqhdI6HRr9mNseLkbVPgqj7SWubwZe x3cR1PlhOC8JQPxVkEVvpWXmgfe3RT7q5yHtxOrdbDQOHb6E3cpDJBqWgJfKLYDfnEbt qcBpTAAoFprHSDwuynRAt8rlUagPNcRT8zjAEw3yGlirMUUyBMSxZSKmlID1KilwqGLi YFMn84JVuRG+cmKJTgCe11QV+WKaRqXZbHe6d67Z2mJeQSMJH73H6Uk3t6hzvfL0yOfT b9+Q1fibH3hEWkKanGWhpQfxoZzXJy7EIFrmsEJAtAwLToCuWiXrB/rxfZPCGQ+UZJM4 YfJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SITmvhShMHsK/HwMDCh4lz7nTLUoWxQcp/Ds0dhGA6g=; b=jMU+XBQhtgQwv5jfruNbr5Gdmg1Vc7PdUxMm1oa5xkwNRya9bXKHHdDzX2487Xc27D b2PNI3LYf52dJ00NuO42FvLMZcx3Eg5XlQFrg15JAxaTXQU+nFQh1q4l3aQxaWS2Tat2 E9hh+zXHwANtIw0ZWKfsz7Nw+wIEYBtsPeciC5CrjXbhwJGSPgeLgBzs7ut4DlaUCyQP VrCQ007NcjbKikwBDqAIvFTfauIb7maL7Zd75w2mP+dN4hDCid35ZLRmrgdxiKmI4aYd vaMqCOs7gGlPFnZ5wwLCDxXVL0kpzh49lDd6r7hFqa3z1MHMqoYj7TjB1wVMkbIfNvMo a+Xg== X-Gm-Message-State: AHQUAuY5EnsZRlqSgRAsPepv5kRD89hby64TRw1HiruX4OH4YsCX7LpF ujLJpwdjneG7v+18NG4Nc1XMSQ== X-Google-Smtp-Source: AHgI3IZYroNQFsY3PWH5Zh8xQOh0R2TA4RlAywklc9kCSf7XX4MtDIbkR1jzhiFh14UwXecT2fAo3g== X-Received: by 2002:a63:c22:: with SMTP id b34mr1794124pgl.398.1549406760429; Tue, 05 Feb 2019 14:46:00 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z9sm12747320pfd.99.2019.02.05.14.46.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 14:46:00 -0800 (PST) Date: Tue, 5 Feb 2019 14:45:50 -0800 From: Stephen Hemminger To: Igor Ryzhov Cc: dev@dpdk.org, stable@dpdk.org Message-ID: <20190205144550.10f76a1b@hermes.lan> In-Reply-To: <20190124204749.49912-1-iryzhov@nfware.com> References: <20190124204749.49912-1-iryzhov@nfware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] kni: fix rte_kni_update_link X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2019 22:46:01 -0000 On Thu, 24 Jan 2019 23:47:49 +0300 Igor Ryzhov wrote: > After read, file offset must be set to 0 before write. > Otherwise, the third byte will be overwritten instead of the first. > > Fixes: c6fd54f28c24 ("kni: add function to set link state on kernel interface") > Cc: stable@dpdk.org > > Signed-off-by: Igor Ryzhov > --- > lib/librte_kni/rte_kni.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c > index 73aeccccf..5899bb14a 100644 > --- a/lib/librte_kni/rte_kni.c > +++ b/lib/librte_kni/rte_kni.c > @@ -746,6 +746,12 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) > } > old_linkup = (old_carrier[0] == '1'); > > + if (lseek(fd, 0, SEEK_SET) == -1) { > + RTE_LOG(ERR, KNI, "Failed to change file position: %s.\n", path); > + close(fd); > + return -1; > + } > + > new_carrier = linkup ? "1" : "0"; > ret = write(fd, new_carrier, 1); > if (ret < 1) { Why not use pwrite() which is atomic?