[PATCH dpdk v2 03/16] net: add structure for ipv6 addresses
Robin Jarry
rjarry at redhat.com
Fri Oct 4 13:59:02 CEST 2024
Stephen Hemminger, Oct 04, 2024 at 01:18:
> On Tue, 1 Oct 2024 10:17:15 +0200
> Robin Jarry <rjarry at redhat.com> wrote:
>
>> There is currently no structure defined for IPv6 addresses. Introduce
>> one that is simply a uint8_t array of 16 elements without any union. The
>> idea is to ensure this structure alignment is 1 so that it can be mapped
>> directly on unaligned packet memory.
>>
>> Signed-off-by: Robin Jarry <rjarry at redhat.com>
>> ---
>> lib/net/rte_ip6.h | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h
>> index 5ad1dd25db08..52c41088681e 100644
>> --- a/lib/net/rte_ip6.h
>> +++ b/lib/net/rte_ip6.h
>> @@ -35,6 +35,16 @@
>> extern "C" {
>> #endif
>>
>> +#define RTE_IPV6_ADDR_SIZE 16
>> +#define RTE_IPV6_MAX_DEPTH 128
>> +
>> +/**
>> + * IPv6 Address
>> + */
>> +struct rte_ipv6_addr {
>> + unsigned char a[RTE_IPV6_ADDR_SIZE];
>> +};
>> +
>
> Why is RTE_IPV6_MAX_DEPTH here, it is not really a property
> of the address itself.
It is used in the next commits. I will move it where it belongs.
> Not sure if using a union (like struct in6_addr does) might be better
> to encourage compiler alignment and allow simpler faster comparison.
I didn't use a union to ensure the type is 1 byte aligned. This is the
very reason why I didn't re-use in6_addr which would have been more
elegant (and shorter).
More information about the dev
mailing list