From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id 00BF091 for ; Thu, 24 Jan 2019 21:47:55 +0100 (CET) Received: by mail-lf1-f67.google.com with SMTP id e26so5357332lfc.2 for ; Thu, 24 Jan 2019 12:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfware-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zRA/uimJUzKtxbXeCLq5m550GyNhirhXYpiZn5Yf3UY=; b=AOalBDYK/NwxgF8C4zKzrNeuNkYwFo1mJr4vYK3Ho49f/Eiqv6WkCkQxYEjPf6wfNz zCyYwyGi4vH1WYyDIezFnBUw9/SVp9XUNfTyZpqEum8bq76Wd5RKfe4ex+cV3ysHq1// hK3E3y6ow/P/rjezzJ0uHa8DYJ9daoNDLfO+J2xoLcr5lWi96EZ/mNVxbwejFfL7PUCY h4WcNTHbA6snA3eJq+MEzj82ye2+Vfa62nMj95lDY6Ejld/2R4cpLmxd4nd1boOXRFIg 5BNyXhdpPCyxm/xH51gAj8GqvQG2aJMOmvubRG+8rW86WEVRkq19AHKjsQU3YdjCMM2G /nkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zRA/uimJUzKtxbXeCLq5m550GyNhirhXYpiZn5Yf3UY=; b=Xx0q3VACzyVyE08Z1oGKw+N4P/SYUtYj7Fm7hHny2X449ZxK87lHtm9TYCuBgcDsBk vgATvppQ2QcBUXHt5f9WLEQmqG1QwYM+b+x+NwNAC7dF3mJOVwhsC0sfg/7SfTynmNFY uNOXL9XpO+dqU3huK5mln87lXbmXC21+XswIKIXNJMZua5wCjZIUEfuUPeSkuoHTyJJi Fvic5usAymbFlTbcyopUjeWC9Rq5zt1AJdBKfjJugNKiGBqiUjxWEu9v36hvsS3Y45oW /kRx36QobRynTlafryqOVS2ZjqsKUTuByd5Ec1Lncx1MLHI088mFg2AK+gcW+K7VY7FZ 7bkw== X-Gm-Message-State: AJcUukda92xhJYgKn0RHvrjuXPPZgrrvybExkrWAXy0GTljqrzEW1s0n TedUiejprFZHgNhYFIa04zkMgQ== X-Google-Smtp-Source: ALg8bN7zruMLIsprKZyqNEt2sK7lpsI7QTte+GZbw6GddWtFwT1HDE4Kbs8ohj6YYB8J6EWmN1pzvA== X-Received: by 2002:a19:d619:: with SMTP id n25mr5934156lfg.91.1548362875263; Thu, 24 Jan 2019 12:47:55 -0800 (PST) Received: from localhost.localdomain ([77.105.187.48]) by smtp.gmail.com with ESMTPSA id v11-v6sm1168476ljc.57.2019.01.24.12.47.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 12:47:54 -0800 (PST) From: Igor Ryzhov To: dev@dpdk.org Cc: stable@dpdk.org Date: Thu, 24 Jan 2019 23:47:49 +0300 Message-Id: <20190124204749.49912-1-iryzhov@nfware.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] kni: fix rte_kni_update_link X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2019 20:47:56 -0000 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) { -- 2.20.1