[PATCH] common/mlx5: fix the sysfs port name translation

Stephen Hemminger stephen at networkplumber.org
Fri Nov 11 18:38:09 CET 2022


On Fri, 11 Nov 2022 05:41:05 +0000
Bing Zhao <bingz at nvidia.com> wrote:

> Hi Stephen,
> 
> > -----Original Message-----
> > From: Stephen Hemminger <stephen at networkplumber.org>
> > Sent: Friday, November 11, 2022 12:22 AM
> > To: Bing Zhao <bingz at nvidia.com>
> > Cc: Slava Ovsiienko <viacheslavo at nvidia.com>; Matan Azrad
> > <matan at nvidia.com>; dev at dpdk.org; Raslan Darawsheh
> > <rasland at nvidia.com>; stable at 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 <bingz at nvidia.com> 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.


More information about the stable mailing list