From patchwork Thu Jan 24 20:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Ryzhov X-Patchwork-Id: 50041 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7056E2BF2; Thu, 24 Jan 2019 21:47:57 +0100 (CET) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id 31F6B91 for ; Thu, 24 Jan 2019 21:47:56 +0100 (CET) Received: by mail-lf1-f68.google.com with SMTP id a16so5348702lfg.3 for ; Thu, 24 Jan 2019 12:47:56 -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=YsKg91tMRjZlQSIL8e0dcXB8j7x233XB/S9czRismnnsYRB6mzWpx66Tp1KAkqKmpC a/l1SfllfVAt4GsDc10LY2Ou8fvD8N+hZ4qaKbaSIOGwFFN8TZPxnUwD7n6yvlC2qvaI h+130437rri9pcBoBPZL8Lck2Fwkt1kXKYDX7dYPzMIZPi+jmck1ajnXsqr/jvKrAXsV Qu2RaDlxruMSJt8lVP+5x366tiap0hPpnGkHYq6tYuJh5o3+Y+p26NgNr8Hr3o24ZHLB zgX+xIsyVbCqGhvGb9XKNQEXfFrx+6OWMZF//D6o4mxAP6ZOXpTG/o6SKN7ZsMLqrIJQ bdCg== X-Gm-Message-State: AJcUukfHH5T22XkH62xZB650D9eZ40oljeYGf3DkcWbVdaVMsyhpJyeD hZpRRSQ7TwKm/x2tq+oPP/7U8O+DcFw= 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 Subject: [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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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) {