drivers/at86rf2xx: Fix L2 addr genration/handling#12600
drivers/at86rf2xx: Fix L2 addr genration/handling#12600benpicco merged 1 commit intoRIOT-OS:masterfrom
Conversation
I added this test case to check if NETOPT is formatted properly. |
|
Note that opaque byte arrays received from luid_get are no longer shuffled arround, so on little endian systems the address will be "the other way round" (plus 4 bits changed). On the plus side, the same CPU ID will now generate the same L2 address regardless of endianess; which makes sense to me. The change of the L2 addresses is pretty bad in OTA updates. But having in mind that a the way they were generated could result in e.g. four at86rf233 transceivers on the same board getting the exact same L2 addresses up to now, the generation of the addresses needed to be fixed. And I saw no value in having the L2 addresses being almost identical except for the colliding bits, so I optimised the byte order conversion of the byte array out. Maybe it is even better if the change in L2 addresses is more visible, than a sneaky change of only the colliding bits. |
Yes, and this is a problem, because now they are not exposed as legal EUI-64s to the upper layers any more (because you don't reorder them on |
|
Didn't we agree that byte arrays do not have a byte order? |
Yes, but it still matters which order you hand it up. The bits you are flipping after |
|
Or to say it differently: by deciding to flip the bits of the last bytes you made your byte array an EUI-64 in little endian-order and the last byte the MSB. This isn't a problem as long as you just interact with the device this way. But when you hand up the long address to another layer it will become a problem, as the EUI-64 is now in the wrong order. See IEEE guidelines of use of EUI, RFC 4291, RFC 4944, RFC 6775, |
|
If there is no byte order in a byte array, it cannot be in the wrong order. So I assume what you are saying is, that I flipped the wrong bits in the address. But I didn't change the bits that were flipped. Here the relevant part of the code in master: /* make sure we mark the address as non-multicast and not globally unique */
addr_long.uint8[0] &= ~(0x01);
addr_long.uint8[0] |= (0x02);
/* set short and long address */
at86rf2xx_set_addr_long(dev, ntohll(addr_long.uint64.u64));With |
Concerning this part of the code you are right, but at the line I commented in #12600 (comment), you hand the EUI-64 in little endian order (as the last byte got its bits flipped it became the MSB) up the stack, but the doc of |
|
Maybe the general confusion could be reduced by fixing the insanity contained inside the at86rf2xx_set_addr_long() function… |
Thought the same and did so! 😆 |
So the old driver generated the L2 address in big endian, converted it to little endian prior to the call to |
Yes... it's stupid.. That much we agree on. |
|
The only thing I wanted from the original state of the PR is that this patch is applied and |
|
I don't really care what happens internally in the device [edit]as long as it works ;-)[/edit], but the network stack expects a long address where the U/L and G/L bits are in the first byte (when read as byte array). This needs to happen, everything else I don't care about ;-). |
|
If I understood you correct, the driver now sets the U/L and G/L bits correctly, right? So no need to shuffle bytes around any more, right? |
|
Sorry, forgot to push. |
miri64
left a comment
There was a problem hiding this comment.
Have you tested pinging with IPv6 to a link-local address? I'm not sure the address is now configured internally.
|
@maribu how much of your test procedure still apply here? |
Do not generate address during reset, but during setup. Otherwise the device will get a new address after every reset. Also: Use common IEEE 802.15.4 setup function for this.
|
I rebased to resolve merge conflicts and updated to use the common |
|
All green |
|
Thanks for the reviews :-) |
Contribution description
luid_get()) trueTesting procedure
at86rf2xxtransceiver can still communicateat86rf2xxtransceivers (of the same type!) attached on the same board now get two different L2 addresses.ifconfigstill provides the same output except for the L2 addressesIssues/PRs references
Fixes #9656