Skip to content

sys/luid: add luid_netdev_get_eui48() & luid_netdev_get_eui64() #14778

Merged
maribu merged 3 commits intoRIOT-OS:masterfrom
benpicco:sys/luid_netdev
Aug 21, 2020
Merged

sys/luid: add luid_netdev_get_eui48() & luid_netdev_get_eui64() #14778
maribu merged 3 commits intoRIOT-OS:masterfrom
benpicco:sys/luid_netdev

Conversation

@benpicco
Copy link
Contributor

@benpicco benpicco commented Aug 18, 2020

Contribution description

Add functions to generate an EUI based on the netdev ID.
This will always return the same EUI for the same netdev, so it is stable across netdev resets.

Testing procedure

As a demonstration, the at86rf215 driver has been converted to the new function.
This will be replaced by calls to netdev_eui64_get() once #14634 is merged.

It shows that the two interfaces still get distinct MAC addresses

2020-08-18 10:39:31,996 # Iface  7  HWaddr: 3A:A7  Channel: 26  Page: 0  NID: 0x23  PHY: O-QPSK 
2020-08-18 10:39:31,997 #           
2020-08-18 10:39:31,998 #           Long HWaddr: 22:68:31:23:59:F5:D3:3A 
2020-08-18 10:39:32,000 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-08-18 10:39:32,013 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:102  MTU:1280  HL:64  RTR  
2020-08-18 10:39:32,014 #           6LO  IPHC  
2020-08-18 10:39:32,015 #           Source address length: 8
2020-08-18 10:39:32,016 #           Link type: wireless
2020-08-18 10:39:32,028 #           inet6 addr: fe80::2068:3123:59f5:d33a  scope: link  VAL
2020-08-18 10:39:32,029 #           inet6 group: ff02::2
2020-08-18 10:39:32,030 #           inet6 group: ff02::1
2020-08-18 10:39:32,031 #           inet6 group: ff02::1:fff5:d33a
2020-08-18 10:39:32,032 #           
2020-08-18 10:39:32,033 #           Statistics for Layer 2
2020-08-18 10:39:32,044 #             RX packets 0  bytes 0
2020-08-18 10:39:32,045 #             TX packets 2 (Multicast: 2)  bytes 86
2020-08-18 10:39:32,046 #             TX succeeded 2 errors 0
2020-08-18 10:39:32,047 #           Statistics for IPv6
2020-08-18 10:39:32,047 #             RX packets 0  bytes 0
2020-08-18 10:39:32,061 #             TX packets 2 (Multicast: 2)  bytes 128
2020-08-18 10:39:32,062 #             TX succeeded 2 errors 0
2020-08-18 10:39:32,062 # 
2020-08-18 10:39:32,063 # Iface  6  HWaddr: 3A:A6  Channel: 0  Page: 2  NID: 0x23  PHY: O-QPSK 
2020-08-18 10:39:32,064 #           
2020-08-18 10:39:32,077 #           Long HWaddr: 22:68:31:23:59:F5:D3:3B 
2020-08-18 10:39:32,079 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-08-18 10:39:32,092 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:102  MTU:1280  HL:64  RTR  
2020-08-18 10:39:32,093 #           6LO  IPHC  
2020-08-18 10:39:32,094 #           Source address length: 8
2020-08-18 10:39:32,095 #           Link type: wireless
2020-08-18 10:39:32,096 #           inet6 addr: fe80::2068:3123:59f5:d33b  scope: link  VAL
2020-08-18 10:39:32,108 #           inet6 group: ff02::2
2020-08-18 10:39:32,109 #           inet6 group: ff02::1
2020-08-18 10:39:32,110 #           inet6 group: ff02::1:fff5:d33b
2020-08-18 10:39:32,110 #           
2020-08-18 10:39:32,111 #           Statistics for Layer 2
2020-08-18 10:39:32,112 #             RX packets 0  bytes 0
2020-08-18 10:39:32,125 #             TX packets 2 (Multicast: 2)  bytes 86
2020-08-18 10:39:32,126 #             TX succeeded 2 errors 0
2020-08-18 10:39:32,127 #           Statistics for IPv6
2020-08-18 10:39:32,127 #             RX packets 0  bytes 0
2020-08-18 10:39:32,140 #             TX packets 2 (Multicast: 2)  bytes 128
2020-08-18 10:39:32,141 #             TX succeeded 2 errors 0

They are also stable across resets

2020-08-18 10:43:53,870 #  ifconfig 6 set state reset
2020-08-18 10:43:53,886 # success: set state of interface 6 to RESET

2020-08-18 10:43:56,253 #  ifconfig 6
2020-08-18 10:43:56,336 # Iface  6  HWaddr: 3A:A6  Channel: 0  Page: 2  NID: 0x23  PHY: O-QPSK 
2020-08-18 10:43:56,336 #           
2020-08-18 10:43:56,338 #           Long HWaddr: 22:68:31:23:59:F5:D3:3B 
2020-08-18 10:43:56,351 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-08-18 10:43:56,353 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:102  MTU:1280  HL:64  RTR  
2020-08-18 10:43:56,353 #           6LO  IPHC  
2020-08-18 10:43:56,366 #           Source address length: 8
2020-08-18 10:43:56,367 #           Link type: wireless
2020-08-18 10:43:56,368 #           inet6 addr: fe80::2068:3123:59f5:d33b  scope: link  VAL
2020-08-18 10:43:56,369 #           inet6 group: ff02::2
2020-08-18 10:43:56,381 #           inet6 group: ff02::1
2020-08-18 10:43:56,382 #           inet6 group: ff02::1:fff5:d33b
2020-08-18 10:43:56,383 #           
2020-08-18 10:43:56,384 #           Statistics for Layer 2
2020-08-18 10:43:56,385 #             RX packets 0  bytes 0
2020-08-18 10:43:56,386 #             TX packets 10 (Multicast: 10)  bytes 430
2020-08-18 10:43:56,398 #             TX succeeded 10 errors 0
2020-08-18 10:43:56,399 #           Statistics for IPv6
2020-08-18 10:43:56,400 #             RX packets 0  bytes 0
2020-08-18 10:43:56,401 #             TX packets 10 (Multicast: 10)  bytes 640
2020-08-18 10:43:56,413 #             TX succeeded 10 errors 0

Issues/PRs references

Will be used by #14634, but can also be used independently.
alternative to #14363

@benpicco benpicco added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 18, 2020
@benpicco benpicco force-pushed the sys/luid_netdev branch 2 times, most recently from 3ec0862 to eb34875 Compare August 18, 2020 09:24
@maribu
Copy link
Member

maribu commented Aug 18, 2020

OK, while I agree on having this (so that the same LUID is generated reagrdless of the number of calls to luid_get() prior to the initialization of netdevs), we should avoid calling to it in the reset procedure. We should make double sure that during reset the previously configured L2 address is applied to the device again. Note that the network stack has an in memory copy of the L2 address anyway, as frames need to be prepared with a source address. Just using this in memory copy to restore the L2 address after a device sleep ist what we should do, even though this PR fixes the issue in cases the L2 address is not applied manually.

Add functions to generate an EUI based on the netdev ID.
This will always return the same EUI for the same netdev, so it is
stable across netdev resets.
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comment. I'm still less than happy that we have to cast the address to eui64_t. We should either use that type for the address in the netdev_ieee802154_t, or let the luid_get API accept uint8_t arrays.

@maribu maribu added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Aug 21, 2020
@maribu
Copy link
Member

maribu commented Aug 21, 2020

I trust the record of your testing in the PR description

@maribu maribu added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Aug 21, 2020
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@maribu
Copy link
Member

maribu commented Aug 21, 2020

Last CI run was 6 hours ago, that should be recent enough.

@maribu maribu merged commit 92ae260 into RIOT-OS:master Aug 21, 2020
@benpicco benpicco deleted the sys/luid_netdev branch August 21, 2020 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants