lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211015153053.781b6e57@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date:   Fri, 15 Oct 2021 15:30:53 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Shannon Nelson <snelson@...sando.io>
Cc:     netdev@...r.kernel.org, olteanv@...il.com, andrew@...n.ch,
        idosch@...sch.org, f.fainelli@...il.com, jiri@...dia.com,
        idosch@...dia.com, lars.povlsen@...rochip.com,
        Steen.Hegelund@...rochip.com, UNGLinuxDriver@...rochip.com,
        bjarni.jonasson@...rochip.com,
        linux-arm-kernel@...ts.infradead.org, qiangqing.zhang@....com,
        vkochan@...vell.com, tchornyi@...vell.com, vladimir.oltean@....com,
        claudiu.manoil@....com, alexandre.belloni@...tlin.com
Subject: Re: [RFC net-next 1/6] ethernet: add a helper for assigning port
 addresses

On Fri, 15 Oct 2021 14:36:00 -0700 Shannon Nelson wrote:
> On 10/15/21 12:38 PM, Jakub Kicinski wrote:
> > We have 5 drivers which offset base MAC addr by port id.
> > Create a helper for them.
> >
> > This helper takes care of overflows, which some drivers
> > did not do, please complain if that's going to break
> > anything!

> > +/**
> > + * eth_hw_addr_set_port - Generate and assign Ethernet address to a port
> > + * @dev: pointer to port's net_device structure
> > + * @base_addr: base Ethernet address
> > + * @id: offset to add to the base address
> > + *
> > + * Assign a MAC address to the net_device using a base address and an offset.
> > + * Commonly used by switch drivers which need to compute addresses for all
> > + * their ports. addr_assign_type is not changed.
> > + */
> > +static inline void eth_hw_addr_set_port(struct net_device *dev,
> > +					const u8 *base_addr, u8 id)  
> 
> To me, the words "_set_port" imply that you're going to force "id" into 
> the byte, overwriting what is already there.  Since this instead is 
> adding "id" to the byte, perhaps a better name would include the word 
> "offset", maybe like eth_hw_addr_set_port_offset(), to better imply the 
> actual operation.
> 
> Personally, I think my name suggestion is too long, but it gets my 
> thought across.

I started with eth_hw_addr_set_offset() my thought process was:

  .._set_offset() sounds like it's setting the offset

  dev_addr_mod() uses offset to modify just part of the address
  so we have two similar functions using 'offset' with different 
  meaning

  how about we name it after the most common use? -> .._port()

Thinking again maybe eth_hw_addr_gen()? We "generate" a port address
based on base address and port ID.

I can change if others agree that .._set_offset() is better.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ