DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>
To: Robin Jarry <rjarry@redhat.com>,
	Vladimir Medvedkin <medvedkinv@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: "Morten Brørup" <mb@smartsharesystems.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"Richardson, Bruce" <bruce.richardson@intel.com>,
	"Marchand, David" <david.marchand@redhat.com>,
	"Thomas Monjalon" <thomas@monjalon.net>,
	"Konstantin Ananyev" <konstantin.ananyev@huawei.com>
Subject: RE: rte_fib network order bug
Date: Tue, 3 Dec 2024 14:37:18 +0000	[thread overview]
Message-ID: <SJ0PR11MB57720C83D3C323E87C001FFC96362@SJ0PR11MB5772.namprd11.prod.outlook.com> (raw)
In-Reply-To: <D5SUAHQG4BFP.IRLD8VYLD2U7@redhat.com>

Hi Robin,

I like the second approach with one more suggestion. It would be nice to have 2 different flags - an existing flag (RTE_FIB_F_LOOKUP_NETWORK_ORDER) for the data plane bswap, and a new one for the control plane operations (smth like RTE_FIB/RIB_F_CP_NETWORK_ORDER).
Also for user convenience RTE_FIB_F_NETWORK_ORDER may be introduced as (RTE_FIB_F_LOOKUP_NETWORK_ORDER| RTE_FIB_F_CP_NETWORK_ORDER)

> There would need to be an additional RTE_IPV4_BE() macro to declare IPv4 addresses in network order.
This may be useful as well

Thanks!

-----Original Message-----
From: Robin Jarry <rjarry@redhat.com> 
Sent: Friday, November 22, 2024 4:15 PM
To: Vladimir Medvedkin <medvedkinv@gmail.com>; Stephen Hemminger <stephen@networkplumber.org>
Cc: Morten Brørup <mb@smartsharesystems.com>; Medvedkin, Vladimir <vladimir.medvedkin@intel.com>; dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>; Marchand, David <david.marchand@redhat.com>; Thomas Monjalon <thomas@monjalon.net>; Konstantin Ananyev <konstantin.ananyev@huawei.com>
Subject: Re: rte_fib network order bug

Vladimir Medvedkin, Nov 17, 2024 at 16:04:
> [Robin]
>> I had not understood that it was *only* the lookups that were network 
>> order
>
> [Morten]
>> When I saw the byte order flag the first time, it was not clear to me 
>> either that it only affected lookups - I too thought it covered the 
>> entire API of the library. This needs to be emphasized in the 
>> description of the flag. And the flag's name should contain LOOKUP 
>> [Morten] > And/or rename RTE_FIB_F_NETWORK_ORDER to 
>> RTE_FIB_F_NETWORK_ORDER_LOOKUP or similar.
>
> There is a clear comment for this flag that it has effects on lookup. 
> Repeating the statement with an exclamation mark seems too much. 
> Moreover, at first this flag was named "RTE_FIB_FLAG_LOOKUP_BE" and it 
> was suggested for renaming here:
> https://inbox.dpdk.org/dev/D4SWPKOPRD5Z.87YIET3Y4AW@redhat.com/

This is my bad then. I had misunderstood what this flag was for. 
I should have been more careful. You had clearly stated that it was only affecting the lookup.

> So, feel free to submit patches adding this feature to the control 
> plane API, but let's consider:

I can commit to working on that topic if we can get a consensus. In my opinion there are two different approaches:

1) Change all IPv4 routing *APIs* to only use network order addresses =====================================================================

This would make them consistent with all networking stacks (linux, vpp, bsd, etc.) and would avoid confusion from users (like me) who naively used these libraries with addresses generated with inet_pton() or addresses taken verbatim from IPv4 packet headers.

More importantly, it would make them consistent on big-endian and little-endian architectures. Currently, the same code could work (without any byte swap) on aarch4, but would not work on x86_64.

It would also make them consistent with their IPv6 counterparts which do not require any byteswap.

This would be a drastic and breaking change but I think this would be the better solution in the long run.

To ensure that potential users of these libraries will not miss this change, the uint32_t parameters should be changed to a rte_ipv4_addr structure that follows the same idea than rte_ipv6_addr.

We could also simply use rte_be32_t types everywhere but it would expose potential users of these APIs with bugs that could not be found at compilation.

Internally, all these routing libraries would continue using host order integers, the changes I am suggesting only affect the public API.

2) Implement network order via opt-in flags ===========================================

This would allow the same thing as solution 1) but would keep the default behaviour which I find confusing and inconsistent with IPv6 and with all IPv4 networking stacks that I know.

The other concern I have with that second solution is that the public APIs would continue using uint32_t parameters which would be only correct when the network-order mode is not enabled.

On the other hand, it does not break any API for users that do not use the flags.

There would need to be an additional RTE_IPV4_BE() macro to declare IPv4 addresses in network order.

Any thoughts?


      reply	other threads:[~2024-12-03 14:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12  9:31 Robin Jarry
2024-11-13 10:42 ` Medvedkin, Vladimir
2024-11-13 13:27   ` Robin Jarry
2024-11-13 19:39     ` Medvedkin, Vladimir
2024-11-14  7:43       ` Morten Brørup
2024-11-14 10:18         ` Robin Jarry
2024-11-14 14:35           ` Morten Brørup
2024-11-15 13:01             ` Robin Jarry
2024-11-15 13:52               ` Morten Brørup
2024-11-15 14:07                 ` Bruce Richardson
2024-11-15 14:28                 ` Robin Jarry
2024-11-15 16:20                   ` Stephen Hemminger
2024-11-17 15:04                     ` Vladimir Medvedkin
2024-11-22 15:35                       ` Thomas Monjalon
2024-11-22 16:14                       ` Robin Jarry
2024-12-03 14:37                         ` Medvedkin, Vladimir [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR11MB57720C83D3C323E87C001FFC96362@SJ0PR11MB5772.namprd11.prod.outlook.com \
    --to=vladimir.medvedkin@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=medvedkinv@gmail.com \
    --cc=rjarry@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).