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 6255EA0547; Fri, 11 Nov 2022 18:38:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55D0B4014F; Fri, 11 Nov 2022 18:38:13 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id C144E40141 for ; Fri, 11 Nov 2022 18:38:12 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id v28so5431230pfi.12 for ; Fri, 11 Nov 2022 09:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ovnuR42wQogB88fSFr2XQ0H8n/PSPvARrO8i+iKkA2c=; b=2TFtKFUKRGeNDOf1mF1QH4a9AMzCz5yPocre9xcgIdi9s6wijziG/WJt09ZzqriYC2 zW9CzQcMfcmYKroBim7YLgmrcw1uwBT6tX//rjyN93fS5ANjydXqHn01R3jkgdBplg80 KgNsIqNDdf4lHzcDzada6EqEbhg/0ni6XHRrGi09DSm+ke/dhq1pcr38Vb1QbPKPZyzn x56Z9YJcQFjYjYrkUE8yF1muf3znC2oDqx6IsbkDYsBE2S75SxnIcaFUUosAQ5w9acLp uAesCQtfL7dCl36SHFN5W9ndLugM2b8n01n9KpoIwpx4PhGXXQUBJFMbcIGNl8r9w3uS kq2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ovnuR42wQogB88fSFr2XQ0H8n/PSPvARrO8i+iKkA2c=; b=k3JSYPkyJQ1bZkobyanv3aILs0T2tCsVB9Pq7MU54Y9ZF1NdWMEKBE0iFD/RZiMq06 uUfJ2Lnmp+kzBaVBVqH/T0Yfb+ueHMkwbHq+XyCNkr8WnrWg7McV/dyb5JzYa/YrwBEl OnsxDiULhrP4FzdRUiDq2daMwgmofdG3PNoFNptGu3x73+3Ewdi6SwvRQ37sI0Utn259 hBKGvIc+6a3dCk1F71X4iL0MkMu2wRPKsDpyh2FP6gjqwPBzzhEWp/sFzlUiOkhBl+4b YdAtp5UIB1HiV9jMzyHKxLcrv1KEom5ADSAm45+3+PqoyA81InB6QQvhopwk4bvb9MKi KBjg== X-Gm-Message-State: ANoB5pmkzz8n9/BY7BHcczYUqCTEx/uD+CkJvCmrYSWnoAH2mxg5qtbM JhqH2fj5KkuRf0PdY2vkczyFhQ== X-Google-Smtp-Source: AA0mqf6uomrTm/s0dBQDuaqY3IMJUpl5K8zQ56C+DQS1GaB1elJdkz+v+uWTaCdnWNY9XikcBpEiXg== X-Received: by 2002:a05:6a00:3011:b0:563:5e0a:97e8 with SMTP id ay17-20020a056a00301100b005635e0a97e8mr3617465pfb.75.1668188292029; Fri, 11 Nov 2022 09:38:12 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id h16-20020a635310000000b0046f56534d9fsm1607613pgb.21.2022.11.11.09.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 09:38:11 -0800 (PST) Date: Fri, 11 Nov 2022 09:38:09 -0800 From: Stephen Hemminger To: Bing Zhao Cc: Slava Ovsiienko , Matan Azrad , "dev@dpdk.org" , Raslan Darawsheh , "stable@dpdk.org" Subject: Re: [PATCH] common/mlx5: fix the sysfs port name translation Message-ID: <20221111093809.38358203@hermes.local> In-Reply-To: References: <20221110155726.649190-1-bingz@nvidia.com> <20221110082154.118781cd@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, 11 Nov 2022 05:41:05 +0000 Bing Zhao wrote: > Hi Stephen, > > > -----Original Message----- > > From: Stephen Hemminger > > Sent: Friday, November 11, 2022 12:22 AM > > To: Bing Zhao > > Cc: Slava Ovsiienko ; Matan Azrad > > ; dev@dpdk.org; Raslan Darawsheh > > ; stable@dpdk.org > > Subject: Re: [PATCH] common/mlx5: fix the sysfs port name > > translation > > > > External email: Use caution opening links or attachments > > > > > > On Thu, 10 Nov 2022 17:57:26 +0200 > > Bing Zhao wrote: > > > > > 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. > > > > Why not fix the DPDK driver to strip off the new line when the port > > name is read? The code in mlx5_os.c should do it there. > > Thanks for your comments. Yes, IF_NAMESIZE is large enough to read all the characters including the newline into the buffer. > After fgets(), the strlen() or strchr() can be used to remove the tailing newline character. > > > BR. Bing Another alternative would be to use getline() which doesn't have annoying length restrictions to deal with.