From b67f598e23c892894e48fdec49b9d48bc0d743b7 Mon Sep 17 00:00:00 2001 From: Ferruh Yigit Date: Thu, 24 Jun 2021 14:32:16 +0100 Subject: [PATCH] kni: update link only on change 'rte_kni_update_link()' updates virtual KNI interface link using kernel sysfs interface. If the requested link status is same as interface link status, do not update the link status but return with success. Signed-off-by: Ferruh Yigit --- lib/kni/rte_kni.c | 5 ++++- lib/kni/version.map | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index eb24b0d0ae..d3e236005e 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -811,6 +811,9 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) } old_linkup = (old_carrier[0] == '1'); + if (old_linkup == (int)linkup) + goto out; + new_carrier = linkup ? "1" : "0"; ret = write(fd, new_carrier, 1); if (ret < 1) { @@ -818,7 +821,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) close(fd); return -1; } - +out: close(fd); return old_linkup; } diff --git a/lib/kni/version.map b/lib/kni/version.map index a93da95f36..bb810a7f2f 100644 --- a/lib/kni/version.map +++ b/lib/kni/version.map @@ -19,5 +19,6 @@ DPDK_21 { EXPERIMENTAL { global: + # updated in v21.08 rte_kni_update_link; }; -- 2.20.1