DPDK patches and discussions
 help / color / mirror / Atom feed
* Risk of rte_ether_addr_copy() causing bugs
@ 2024-11-04 12:11 Morten Brørup
  2024-11-04 16:15 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Morten Brørup @ 2024-11-04 12:11 UTC (permalink / raw)
  To: dev

Unlike memcpy() and other copy functions, rte_ether_addr_copy() takes the destination as the second parameter.

Not following well established conventions adds a high risk of causing bugs in the applications/libraries/drivers; it is likely that developers expect copy() functions to take parameters in the usual memcpy() order, and pass the parameters to rte_ether_addr_copy() in that order instead of the reverse order expected by rte_ether_addr_copy().

How can we fix this?

One way would be to introduce a new copy function and mark the old function deprecated (due to risk of bugs).
Does the community support such a change?
And what would be a good name for the new function?

Any other ideas for fixing it?


Med venlig hilsen / Kind regards,
-Morten Brørup


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Risk of rte_ether_addr_copy() causing bugs
  2024-11-04 12:11 Risk of rte_ether_addr_copy() causing bugs Morten Brørup
@ 2024-11-04 16:15 ` Stephen Hemminger
  2024-11-04 16:19   ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2024-11-04 16:15 UTC (permalink / raw)
  To: Morten Brørup; +Cc: dev

On Mon, 4 Nov 2024 13:11:02 +0100
Morten Brørup <mb@smartsharesystems.com> wrote:

> Unlike memcpy() and other copy functions, rte_ether_addr_copy() takes the destination as the second parameter.
> 
> Not following well established conventions adds a high risk of causing bugs in the applications/libraries/drivers; it is likely that developers expect copy() functions to take parameters in the usual memcpy() order, and pass the parameters to rte_ether_addr_copy() in that order instead of the reverse order expected by rte_ether_addr_copy().
> 
> How can we fix this?
> 
> One way would be to introduce a new copy function and mark the old function deprecated (due to risk of bugs).
> Does the community support such a change?
> And what would be a good name for the new function?
> 
> Any other ideas for fixing it?
> 
> 
> Med venlig hilsen / Kind regards,
> -Morten Brørup
> 

Yes the order of arts is confusing.

For reference the Linux kernel has ether_addr_copy(dst, src)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Risk of rte_ether_addr_copy() causing bugs
  2024-11-04 16:15 ` Stephen Hemminger
@ 2024-11-04 16:19   ` Bruce Richardson
  0 siblings, 0 replies; 3+ messages in thread
From: Bruce Richardson @ 2024-11-04 16:19 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Morten Brørup, dev

On Mon, Nov 04, 2024 at 08:15:00AM -0800, Stephen Hemminger wrote:
> On Mon, 4 Nov 2024 13:11:02 +0100
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > Unlike memcpy() and other copy functions, rte_ether_addr_copy() takes the destination as the second parameter.
> > 
> > Not following well established conventions adds a high risk of causing bugs in the applications/libraries/drivers; it is likely that developers expect copy() functions to take parameters in the usual memcpy() order, and pass the parameters to rte_ether_addr_copy() in that order instead of the reverse order expected by rte_ether_addr_copy().
> > 
> > How can we fix this?
> > 
> > One way would be to introduce a new copy function and mark the old function deprecated (due to risk of bugs).
> > Does the community support such a change?
> > And what would be a good name for the new function?
> > 

Include "memcpy" in the name instead of copy, to make the order of args
clear? "rte_eth_addr_memcpy"?

Other thought is to do a macro version of the function, which would mean
that the name is capitalized.

/Bruce



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-04 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-04 12:11 Risk of rte_ether_addr_copy() causing bugs Morten Brørup
2024-11-04 16:15 ` Stephen Hemminger
2024-11-04 16:19   ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).