From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29C0642814 for ; Wed, 29 Mar 2023 03:04:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24A27410EE; Wed, 29 Mar 2023 03:04:59 +0200 (CEST) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id 3515842686 for ; Wed, 29 Mar 2023 03:04:57 +0200 (CEST) Received: by mail-wr1-f41.google.com with SMTP id t4so8782986wra.7 for ; Tue, 28 Mar 2023 18:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680051897; x=1682643897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vXhEd8VeMOSQotdWIbGgo4f8N1aEp73AKvy6Bzj8OkM=; b=f+2WzE2QDlEMceCxMpozwmIz2ZWoUhUuC20DoqRaRQ2ACpgTCV67xaH9C6OOAJN4hX 4Ncr3n4/AGncRd2LoJIGTuhuVX9VVpEXQqnVGQmCxG0T1OMKvZmhVt00q6dQjh2ChByY upSH1ioLYSanGIHJZwdqdloSr3fp6GQEkUmgCmttI5JHOA3X+Ce5a9AuWCTCFp65OzzC t58x5QccDXF5mhxBnVzuJ3CPdlmyTo39bUktaUzggI8yjxVkRyrptK0H+RW3SZjvOtNS FAUSixVEa9BbMuJM3P48PmOKKwX6uxD6+LNY3jpV7DceEN1jyru+88elfvjDLYr9PM05 lJwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680051897; x=1682643897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vXhEd8VeMOSQotdWIbGgo4f8N1aEp73AKvy6Bzj8OkM=; b=Py9AeGSFmwQVVec6zUHWjD/zHYMV/vW1uPp+nV99Ia9SI6fjM5g1rii1XAB2p71YgZ EeBcoaGyYgD0pjWYx4MJn1NggJ7xAnpx0dHaLf3XPsMMY8oemW7VjKtYo/ZIXw0vliDg 8rro3OAkfvkDiISkQHtXHPsyiq37QFgAX12Jr90uDXPaBPpstnpEJx8KgCSgyx+Iuw1Y lNcpKEolIFsEFrAhefcsI+PW4PU36/bITespCktOgqZPAFzP2WB7DDGv9Tok+kt4Xx2y FJCz6H9mloSQdwZl3LNVA6gGZYik1e+PrEjinfPi8PGajd/X+X6QTBl/tYKEPe6GR+iG DfEA== X-Gm-Message-State: AAQBX9c1OU4kNcW7ozW2WuFcW1DWgi3zTGZrLrsrfpwqzzr6IGYWwDhZ azdK2EB0WaTCGVmMcCwJJpqQfbmOvCk= X-Google-Smtp-Source: AKy350bc1DLj/jbwLhgaAXF5pBW5L9gVOHWKUAn6REQ5bk4s+p8M6xSZehLP0B+x3J65qEsouuC8iA== X-Received: by 2002:adf:ee08:0:b0:2dc:f6bc:5bd3 with SMTP id y8-20020adfee08000000b002dcf6bc5bd3mr332333wrn.16.1680051896834; Tue, 28 Mar 2023 18:04:56 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c7107ce17fsm28905746wrs.3.2023.03.28.18.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 18:04:56 -0700 (PDT) From: luca.boccassi@gmail.com To: Bing Zhao Cc: Matan Azrad , dpdk stable Subject: patch 'net/mlx5: fix sysfs port name translation' has been queued to stable release 20.11.8 Date: Wed, 29 Mar 2023 02:04:40 +0100 Message-Id: <20230329010446.563852-4-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230329010446.563852-1-luca.boccassi@gmail.com> References: <20230322004155.2333903-19-luca.boccassi@gmail.com> <20230329010446.563852-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/31/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/062d5d30d0e823c0482673a00f77b0f49d22d725 Thanks. Luca Boccassi --- >From 062d5d30d0e823c0482673a00f77b0f49d22d725 Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Thu, 23 Mar 2023 12:54:14 +0200 Subject: [PATCH] net/mlx5: fix sysfs port name translation [ upstream commit f8a226ed65fa1c6e085fb0d5a91bab7fb5034aec ] With some OFED or upstream kernel of mlx5, the port name fetched from "/sys/class/net/[DEV]/phys_port_name" may have a tailing "\n" as the EOL. The sscanf() will return the scanned items number with this EOL. In such case, the "equal to" condition is considered as false and the function mlx5_translate_port_name() will recognize the port type wrongly with UNKNOWN result. The tailing carriage return character should be removed before calling the mlx5_translate_port_name(), this was already done in the NL message handling. In the meanwhile, the possible incorrect line feed character is also taken into consideration. Fixes: 654810b56828 ("common/mlx5: share Netlink commands") Fixes: 420bbdae89f2 ("net/mlx5: fix host physical function representor naming") Signed-off-by: Bing Zhao Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index b15fc7e5e0..92320616b5 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1074,7 +1074,8 @@ int mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) { char ifname[IF_NAMESIZE]; - char port_name[IF_NAMESIZE]; + char *port_name = NULL; + size_t port_name_size = 0; FILE *file; struct mlx5_switch_info data = { .master = 0, @@ -1087,6 +1088,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) bool port_switch_id_set = false; bool device_dir = false; char c; + ssize_t line_size; if (!if_indextoname(ifindex, ifname)) { rte_errno = errno; @@ -1102,8 +1104,21 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) file = fopen(phys_port_name, "rb"); if (file != NULL) { - if (fgets(port_name, IF_NAMESIZE, file) != NULL) + char *tail_nl; + + line_size = getline(&port_name, &port_name_size, file); + if (line_size < 0) { + fclose(file); + rte_errno = errno; + return -rte_errno; + } else if (line_size > 0) { + /* Remove tailing newline character. */ + tail_nl = strchr(port_name, '\n'); + if (tail_nl) + *tail_nl = '\0'; mlx5_translate_port_name(port_name, &data); + } + free(port_name); fclose(file); } file = fopen(phys_switch_id, "rb"); -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-03-29 01:31:22.722916388 +0100 +++ 0004-net-mlx5-fix-sysfs-port-name-translation.patch 2023-03-29 01:31:22.478039404 +0100 @@ -1 +1 @@ -From f8a226ed65fa1c6e085fb0d5a91bab7fb5034aec Mon Sep 17 00:00:00 2001 +From 062d5d30d0e823c0482673a00f77b0f49d22d725 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f8a226ed65fa1c6e085fb0d5a91bab7fb5034aec ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index f1ff6f49f9..55801534d1 100644 +index b15fc7e5e0..92320616b5 100644 @@ -33 +34 @@ -@@ -1035,7 +1035,8 @@ int +@@ -1074,7 +1074,8 @@ int @@ -43 +44 @@ -@@ -1048,6 +1049,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) +@@ -1087,6 +1088,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) @@ -51 +52 @@ -@@ -1063,8 +1065,21 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) +@@ -1102,8 +1104,21 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)