* [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
@ 2025-11-14 10:57 Robin Jarry
2025-11-14 16:05 ` Stephen Hemminger
2025-11-14 16:08 ` Stephen Hemminger
0 siblings, 2 replies; 8+ messages in thread
From: Robin Jarry @ 2025-11-14 10:57 UTC (permalink / raw)
To: dev, Stephen Hemminger; +Cc: Christophe Fontaine, stable
From: Christophe Fontaine <cfontain@redhat.com>
As specified in RFC 4291 section 2.5.1, link local addresses must be
generated based on a modified EUI-64 interface identifier:
> Modified EUI-64 format interface identifiers are formed by inverting
> the "u" bit (universal/local bit in IEEE EUI-64 terminology) when
> forming the interface identifier from IEEE EUI-64 identifiers.
This translates to 'mac->addr_bytes[0] ^= 0x02'.
Fixes: 3d6d85f58c1c ("net: add utilities for well known IPv6 address types")
Cc: stable@dpdk.org
Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
---
app/test/test_net_ip6.c | 2 +-
lib/net/rte_ip6.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/test/test_net_ip6.c b/app/test/test_net_ip6.c
index cfc550940306..e4642c9a39d9 100644
--- a/app/test/test_net_ip6.c
+++ b/app/test/test_net_ip6.c
@@ -160,7 +160,7 @@ test_ipv6_llocal_from_ethernet(void)
{
const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c, 0x08, 0x44}};
const struct rte_ipv6_addr local_ip =
- RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
+ RTE_IPV6(0xfe80, 0, 0, 0, 0x067b, 0xcbff, 0xfe5c, 0x0844);
struct rte_ipv6_addr ip;
rte_ipv6_llocal_from_ethernet(&ip, &local_mac);
diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h
index 98bcac3f4dff..93e858b803a9 100644
--- a/lib/net/rte_ip6.h
+++ b/lib/net/rte_ip6.h
@@ -393,7 +393,7 @@ rte_ipv6_mc_scope(const struct rte_ipv6_addr *ip)
/*
* Generate a link-local IPv6 address from an Ethernet address as specified in
- * RFC 2464, section 5.
+ * RFC 4291, section 2.5.1.
*
* @param[out] ip
* The link-local IPv6 address to generate.
@@ -406,7 +406,7 @@ rte_ipv6_llocal_from_ethernet(struct rte_ipv6_addr *ip, const struct rte_ether_a
ip->a[0] = 0xfe;
ip->a[1] = 0x80;
memset(&ip->a[2], 0, 6);
- ip->a[8] = mac->addr_bytes[0];
+ ip->a[8] = mac->addr_bytes[0] ^ 0x02;
ip->a[9] = mac->addr_bytes[1];
ip->a[10] = mac->addr_bytes[2];
ip->a[11] = 0xff;
--
2.51.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 10:57 [PATCH dpdk] net: ipv6 link local compliance with rfc 4291 Robin Jarry
@ 2025-11-14 16:05 ` Stephen Hemminger
2025-11-14 16:08 ` Robin Jarry
2025-11-14 16:14 ` Morten Brørup
2025-11-14 16:08 ` Stephen Hemminger
1 sibling, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2025-11-14 16:05 UTC (permalink / raw)
To: Robin Jarry; +Cc: dev, Christophe Fontaine, stable
On Fri, 14 Nov 2025 11:57:53 +0100
Robin Jarry <rjarry@redhat.com> wrote:
> diff --git a/app/test/test_net_ip6.c b/app/test/test_net_ip6.c
> index cfc550940306..e4642c9a39d9 100644
> --- a/app/test/test_net_ip6.c
> +++ b/app/test/test_net_ip6.c
> @@ -160,7 +160,7 @@ test_ipv6_llocal_from_ethernet(void)
> {
> const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c, 0x08, 0x44}};
> const struct rte_ipv6_addr local_ip =
> - RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
> + RTE_IPV6(0xfe80, 0, 0, 0, 0x067b, 0xcbff, 0xfe5c, 0x0844);
> struct rte_ipv6_addr ip;
Reading the kernel source there is also special handling to include device
id into link local address. This is to handle corner case where multiple network
cards have same hardware MAC address.
Perhaps DPDK should roll port id into link local address?
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 16:05 ` Stephen Hemminger
@ 2025-11-14 16:08 ` Robin Jarry
2025-11-14 16:14 ` Morten Brørup
1 sibling, 0 replies; 8+ messages in thread
From: Robin Jarry @ 2025-11-14 16:08 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Christophe Fontaine, stable
Stephen Hemminger, Nov 14, 2025 at 17:05:
> On Fri, 14 Nov 2025 11:57:53 +0100
> Robin Jarry <rjarry@redhat.com> wrote:
>
>> diff --git a/app/test/test_net_ip6.c b/app/test/test_net_ip6.c
>> index cfc550940306..e4642c9a39d9 100644
>> --- a/app/test/test_net_ip6.c
>> +++ b/app/test/test_net_ip6.c
>> @@ -160,7 +160,7 @@ test_ipv6_llocal_from_ethernet(void)
>> {
>> const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c, 0x08, 0x44}};
>> const struct rte_ipv6_addr local_ip =
>> - RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
>> + RTE_IPV6(0xfe80, 0, 0, 0, 0x067b, 0xcbff, 0xfe5c, 0x0844);
>> struct rte_ipv6_addr ip;
>
> Reading the kernel source there is also special handling to include device
> id into link local address. This is to handle corner case where multiple network
> cards have same hardware MAC address.
>
> Perhaps DPDK should roll port id into link local address?
We discussed about this but it would break the API since you would need
to pass an additional parameter to this function.
And also, I couldn't find anything in the RFC that describes what the
kernel does with device IDs. Nothing mentions if the device id should be
big or little endian, etc.
I don't mind changing the API though but it seems very opinionated.
--
Robin
> Contest void where prohibited by law.
^ permalink raw reply [flat|nested] 8+ messages in thread* RE: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 16:05 ` Stephen Hemminger
2025-11-14 16:08 ` Robin Jarry
@ 2025-11-14 16:14 ` Morten Brørup
2025-11-14 16:46 ` Robin Jarry
2025-11-14 16:48 ` Stephen Hemminger
1 sibling, 2 replies; 8+ messages in thread
From: Morten Brørup @ 2025-11-14 16:14 UTC (permalink / raw)
To: Stephen Hemminger, Robin Jarry; +Cc: dev, Christophe Fontaine, stable
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, 14 November 2025 17.06
>
> On Fri, 14 Nov 2025 11:57:53 +0100
> Robin Jarry <rjarry@redhat.com> wrote:
>
> > diff --git a/app/test/test_net_ip6.c b/app/test/test_net_ip6.c
> > index cfc550940306..e4642c9a39d9 100644
> > --- a/app/test/test_net_ip6.c
> > +++ b/app/test/test_net_ip6.c
> > @@ -160,7 +160,7 @@ test_ipv6_llocal_from_ethernet(void)
> > {
> > const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c,
> 0x08, 0x44}};
> > const struct rte_ipv6_addr local_ip =
> > - RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
> > + RTE_IPV6(0xfe80, 0, 0, 0, 0x067b, 0xcbff, 0xfe5c, 0x0844);
> > struct rte_ipv6_addr ip;
>
> Reading the kernel source there is also special handling to include
> device
> id into link local address. This is to handle corner case where
> multiple network
> cards have same hardware MAC address.
Multiple physical NICs should never have the same MAC address.
Lots of stuff will break if they do.
E.g. a network switch will forward packets to the NIC that most recently sent packets, so its MAC address was learned in the MAC address table in the switch.
What is the use case justifying this tweak in the kernel?
>
> Perhaps DPDK should roll port id into link local address?
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 16:14 ` Morten Brørup
@ 2025-11-14 16:46 ` Robin Jarry
2025-11-14 17:03 ` Stephen Hemminger
2025-11-14 16:48 ` Stephen Hemminger
1 sibling, 1 reply; 8+ messages in thread
From: Robin Jarry @ 2025-11-14 16:46 UTC (permalink / raw)
To: Morten Brørup, Stephen Hemminger; +Cc: dev, Christophe Fontaine, stable
Morten Brørup, Nov 14, 2025 at 17:14:
>> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
>> Reading the kernel source there is also special handling to include
>> device
>> id into link local address. This is to handle corner case where
>> multiple network
>> cards have same hardware MAC address.
>
> Multiple physical NICs should never have the same MAC address.
> Lots of stuff will break if they do.
> E.g. a network switch will forward packets to the NIC that most recently sent packets, so its MAC address was learned in the MAC address table in the switch.
>
> What is the use case justifying this tweak in the kernel?
Some drivers expose multiple ports sharing the same mac address.
This very is specific to certain hardware vendors. The comment here
refers to a change from 2005. I couldn't find the root commit/email.
https://github.com/jeffmahoney/linux-pre-git/commit/44993d3bb812f
> 2005/01/17 13:13:52-08:00 hch
> [IPV6]: Fix EUI64 generation on S/390.
>
> - put a dev_id field in struct net_device, so that it uses space that
> would be wasted by padding otherwise.
> - if this fields is non-null let ipv6_generate_eui64 use the algorithm
> from the QETH code to generate an EUI that's different for each
> OS instance. See code comments for details.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
I don't think DPDK should care about this.
--
Robin
> Do not use while operating a motor vehicle or heavy machinery.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 16:46 ` Robin Jarry
@ 2025-11-14 17:03 ` Stephen Hemminger
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2025-11-14 17:03 UTC (permalink / raw)
To: Robin Jarry; +Cc: Morten Brørup, dev, Christophe Fontaine, stable
On Fri, 14 Nov 2025 17:46:42 +0100
"Robin Jarry" <rjarry@redhat.com> wrote:
> Morten Brørup, Nov 14, 2025 at 17:14:
> >> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> >> Reading the kernel source there is also special handling to include
> >> device
> >> id into link local address. This is to handle corner case where
> >> multiple network
> >> cards have same hardware MAC address.
> >
> > Multiple physical NICs should never have the same MAC address.
> > Lots of stuff will break if they do.
> > E.g. a network switch will forward packets to the NIC that most recently sent packets, so its MAC address was learned in the MAC address table in the switch.
> >
> > What is the use case justifying this tweak in the kernel?
>
> Some drivers expose multiple ports sharing the same mac address.
>
> This very is specific to certain hardware vendors. The comment here
> refers to a change from 2005. I couldn't find the root commit/email.
Yes, this code is in first git commit 2.6.12 from 2005 it is possible
(but not worth the effort) to find it in earlier repos.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 16:14 ` Morten Brørup
2025-11-14 16:46 ` Robin Jarry
@ 2025-11-14 16:48 ` Stephen Hemminger
1 sibling, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2025-11-14 16:48 UTC (permalink / raw)
To: Morten Brørup; +Cc: Robin Jarry, dev, Christophe Fontaine, stable
On Fri, 14 Nov 2025 17:14:32 +0100
Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Friday, 14 November 2025 17.06
> >
> > On Fri, 14 Nov 2025 11:57:53 +0100
> > Robin Jarry <rjarry@redhat.com> wrote:
> >
> > > diff --git a/app/test/test_net_ip6.c b/app/test/test_net_ip6.c
> > > index cfc550940306..e4642c9a39d9 100644
> > > --- a/app/test/test_net_ip6.c
> > > +++ b/app/test/test_net_ip6.c
> > > @@ -160,7 +160,7 @@ test_ipv6_llocal_from_ethernet(void)
> > > {
> > > const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c,
> > 0x08, 0x44}};
> > > const struct rte_ipv6_addr local_ip =
> > > - RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
> > > + RTE_IPV6(0xfe80, 0, 0, 0, 0x067b, 0xcbff, 0xfe5c, 0x0844);
> > > struct rte_ipv6_addr ip;
> >
> > Reading the kernel source there is also special handling to include
> > device
> > id into link local address. This is to handle corner case where
> > multiple network
> > cards have same hardware MAC address.
>
> Multiple physical NICs should never have the same MAC address.
> Lots of stuff will break if they do.
> E.g. a network switch will forward packets to the NIC that most recently sent packets, so its MAC address was learned in the MAC address table in the switch.
>
> What is the use case justifying this tweak in the kernel?
>
> >
> > Perhaps DPDK should roll port id into link local address?
It is allowed for multiple NIC's to have the same MAC but they
can't be on same network namespace.
Code in Linux is working around special case here:
static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
{
if (dev->addr_len != ETH_ALEN)
return -1;
/*
* The zSeries OSA network cards can be shared among various
* OS instances, but the OSA cards have only one MAC address.
* This leads to duplicate address conflicts in conjunction
* with IPv6 if more than one instance uses the same card.
*
* The driver for these cards can deliver a unique 16-bit
* identifier for each instance sharing the same card. It is
* placed instead of 0xFFFE in the interface identifier. The
* "u" bit of the interface identifier is not inverted in this
* case. Hence the resulting interface identifier has local
* scope according to RFC2373.
*/
addrconf_addr_eui48_base(eui, dev->dev_addr);
if (dev->dev_id) {
eui[3] = (dev->dev_id >> 8) & 0xFF;
eui[4] = dev->dev_id & 0xFF;
} else {
eui[0] ^= 2;
}
return 0;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH dpdk] net: ipv6 link local compliance with rfc 4291
2025-11-14 10:57 [PATCH dpdk] net: ipv6 link local compliance with rfc 4291 Robin Jarry
2025-11-14 16:05 ` Stephen Hemminger
@ 2025-11-14 16:08 ` Stephen Hemminger
1 sibling, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2025-11-14 16:08 UTC (permalink / raw)
To: Robin Jarry; +Cc: dev, Christophe Fontaine, stable
On Fri, 14 Nov 2025 11:57:53 +0100
Robin Jarry <rjarry@redhat.com> wrote:
> @@ -406,7 +406,7 @@ rte_ipv6_llocal_from_ethernet(struct rte_ipv6_addr *ip, const struct rte_ether_a
> ip->a[0] = 0xfe;
> ip->a[1] = 0x80;
> memset(&ip->a[2], 0, 6);
> - ip->a[8] = mac->addr_bytes[0];
> + ip->a[8] = mac->addr_bytes[0] ^ 0x02;
Could use RTE_ETHER_LOCAL_ADMIN_ADDR instead of magic constant 2,
but seems a little wordy to do that.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-11-14 17:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-14 10:57 [PATCH dpdk] net: ipv6 link local compliance with rfc 4291 Robin Jarry
2025-11-14 16:05 ` Stephen Hemminger
2025-11-14 16:08 ` Robin Jarry
2025-11-14 16:14 ` Morten Brørup
2025-11-14 16:46 ` Robin Jarry
2025-11-14 17:03 ` Stephen Hemminger
2025-11-14 16:48 ` Stephen Hemminger
2025-11-14 16:08 ` Stephen Hemminger
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).