Thread (5 messages) 5 messages, 3 authors, 2019-02-05

Re: [PATCH] kni: fix rte_kni_update_link

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2019-02-05 22:46:01

On Thu, 24 Jan 2019 23:47:49 +0300
Igor Ryzhov [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 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?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help