net/tap: fix add qdisc failed when create tap

Message ID tencent_C80031E4649A04EFE84C39ACCC8938FEBA06@qq.com (mailing list archive)
State Awaiting Upstream
Delegated to: Stephen Hemminger
Headers
Series net/tap: fix add qdisc failed when create tap |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing warning Testing issues
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/aws-unit-testing success Unit Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Yan Lu May 12, 2025, 8:22 a.m. UTC
From: luyan <luyan@cmss.chinamobile.com>

The errno variable was assigned a positive value in the previous handling,
but here it is compared against -EEXIST,
When the tap already exists, this would falsely report an error.

Signed-off-by: luyan <luyan@cmss.chinamobile.com>
---
 drivers/net/tap/tap_tcmsgs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Stephen Hemminger May 20, 2025, 3:55 p.m. UTC | #1
On Mon, 12 May 2025 16:22:04 +0800
luyan <973788536@qq.com> wrote:

> From: luyan <luyan@cmss.chinamobile.com>
> 
> The errno variable was assigned a positive value in the previous handling,
> but here it is compared against -EEXIST,
> When the tap already exists, this would falsely report an error.
> 
> Signed-off-by: luyan <luyan@cmss.chinamobile.com>

Patch looks good, but the commit message needs a couple of changes.

* DPDK uses a .mailmap file to keep track of all the contributors.
  You should add your email to that.
* Please use your full legal name in the Signed-off-by: portion.
  Is that your full name?
* Since this fixes a bug, please add a fixes tag like:

Fixes: 6fc6de7e0eaf ("net/tap: update netlink error code management")
  

Patch

diff --git a/drivers/net/tap/tap_tcmsgs.c b/drivers/net/tap/tap_tcmsgs.c
index 1755b57519..caca9445c8 100644
--- a/drivers/net/tap/tap_tcmsgs.c
+++ b/drivers/net/tap/tap_tcmsgs.c
@@ -261,7 +261,7 @@  qdisc_create_multiq(int nlsk_fd, unsigned int ifindex)
 	int err = 0;
 
 	err = qdisc_add_multiq(nlsk_fd, ifindex);
-	if (err < 0 && errno != -EEXIST) {
+	if (err < 0 && errno != EEXIST) {
 		TAP_LOG(ERR, "Could not add multiq qdisc (%d): %s",
 			errno, strerror(errno));
 		return -1;
@@ -287,7 +287,7 @@  qdisc_create_ingress(int nlsk_fd, unsigned int ifindex)
 	int err = 0;
 
 	err = qdisc_add_ingress(nlsk_fd, ifindex);
-	if (err < 0 && errno != -EEXIST) {
+	if (err < 0 && errno != EEXIST) {
 		TAP_LOG(ERR, "Could not add ingress qdisc (%d): %s",
 			errno, strerror(errno));
 		return -1;