[PATCH v2] net/tap: fix add qdisc failed when create tap

Yan Lu 973788536 at qq.com
Wed May 21 03:33:13 CEST 2025


From: luyan <luyan at 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.

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

Signed-off-by: Yan Lu <luyan at cmss.chinamobile.com>
---
 .mailmap                     | 1 +
 drivers/net/tap/tap_tcmsgs.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.mailmap b/.mailmap
index d8439b79ce..32fd2b8180 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1737,6 +1737,7 @@ Yanglong Wu <yanglong.wu at intel.com>
 Yang Ming <ming.1.yang at nokia-sbell.com>
 Yang Zhang <zy107165 at alibaba-inc.com>
 Yanjie Xu <yanjie.xu at intel.com>
+Yan Lu <luyan at cmss.chinamobile.com>
 Yan Xia <yanx.xia at intel.com>
 Yao-Po Wang <blue119 at gmail.com>
 Yao Zhao <yao.zhao at windriver.com>
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;
-- 
2.45.2.windows.1



More information about the dev mailing list