Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slaac: add initial stateless address autoconfiguration (SLAAC) implementation #1039

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bergzand
Copy link
Contributor

@bergzand bergzand commented Feb 5, 2025

This PR adds

  • Functions to derive ipv6 addresses from a Cidr and a LL address
  • An slaac implementation
  • Glue to hook it into the Interface

This works by having a separate module to track the slaac state machine. The Interface module passes the received router advertisements to this module and polls this to query whether router solicitations must be send and whether the addresses and routes on the interface need to be synced with the slaac state.

Compared to the dhcpv4, this module modifies the address and route state on the Interface within the module itself without any outside glue or socket required.

Currently there's no separate feature for slaac and it is pulled in when proto-ipv6 together with medium-ieee802154 or medium-ethernet is enabled. Done this way because I consider SLAAC to be an essential part of IPv6. However, I'm not opposed to adding a separate feature for slaac that depends on proto-ipv6

An example is provided that prints the addresses and routes on the interface every second for testing with router advertisement daemons such as radvd

Example output
Addresses:
  - fe80::1/64
Routes:

Addresses:
  - fe80::1/64
Routes:

Addresses:
  - fe80::1/64
  - 2001:db8::ff:fe00:1/64
Routes:
  - ::/0 via fe80::d83c:a5ff:fe9c:3a40

Addresses:
  - fe80::1/64
  - 2001:db8::ff:fe00:1/64
Routes:
  - ::/0 via fe80::d83c:a5ff:fe9c:3a40

Addresses:
  - fe80::1/64
  - 2001:db8::ff:fe00:1/64
Routes:
  - ::/0 via fe80::d83c:a5ff:fe9c:3a40

Addresses:
  - fe80::1/64
  - 2001:db8::ff:fe00:1/64
Routes:

Addresses:
  - fe80::1/64
  - 2001:db8::ff:fe00:1/64
Routes:

Alternative to #948

I can split out the initial commits of this PR into separate PRs if needed to ease reviewing.

This commit splits the state maintenance from the poll function to a
separate poll_maintenance function.
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 95.77982% with 23 lines in your changes missing coverage. Please review.

Project coverage is 81.38%. Comparing base (3e3afb6) to head (3973877).

Files with missing lines Patch % Lines
src/iface/interface/mod.rs 75.55% 11 Missing ⚠️
src/iface/slaac.rs 97.99% 6 Missing ⚠️
src/iface/interface/ipv6.rs 95.90% 5 Missing ⚠️
src/wire/ipv6.rs 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1039      +/-   ##
==========================================
+ Coverage   80.84%   81.38%   +0.53%     
==========================================
  Files          81       82       +1     
  Lines       28485    29028     +543     
==========================================
+ Hits        23029    23624     +595     
+ Misses       5456     5404      -52     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant