Skip to content

Conversation

@christoph-heiss
Copy link
Contributor

@christoph-heiss christoph-heiss commented Apr 11, 2025

Hi!

This is essentially just a rebased version of #259, since that seems to have gone stale for quite a while now.
I've added some small commits on top for some small cleanups, nothing that should change functionality though. so hopefully nothing broke, but I'm still testing it some more currently.

So this should close #259, #249, #122 and #178.

aderumier and others added 24 commits August 22, 2025 13:33
The current code is buggy if an interface only use ipv6.

ipv6 don't have primary and are not ordered, so change can randomly
remove/re-add all ipv6 address

```
auto eno4
iface eno4 inet6 static
        address 2001:db8:a0b:12f0::1/64

info: eno4: netlink: ip addr add 2001:db8:a0b:12f0::1/64 dev eno4

auto eno4
iface eno4 inet6 static
        address 2001:db8:a0b:12f0::1/64
        address 2001:db8:a0b:12f0::2/64

info: eno4: netlink: ip addr add 2001:db8:a0b:12f0::2/64 dev eno4

auto eno4
iface eno4 inet6 static
        address 2001:db8:a0b:12f0::1/64
        address 2001:db8:a0b:12f0::2/64
        address 2001:db8:a0b:12f0::3/64

info: eno4: primary ip changed (from 2001:db8:a0b:12f0::1/64 to 2001:db8:a0b:12f0::2/64) we need to purge all ip addresses and re-add them
info: eno4: netlink: ip addr del 2001:db8:a0b:12f0::2/64 dev eno4
info: eno4: netlink: ip addr del 2001:db8:a0b:12f0::1/64 dev eno4
info: reading '/proc/sys/net/ipv6/conf/eno4/disable_ipv6'
info: eno4: netlink: ip addr add 2001:db8:a0b:12f0::1/64 dev eno4
info: eno4: netlink: ip addr add 2001:db8:a0b:12f0::2/64 dev eno4
info: eno4: netlink: ip addr add 2001:db8:a0b:12f0::3/64 dev eno4
```
we want to get IFA_FLAGS to known if an ip is permanent (0x80),
or dynamic (slaac)
simply sysctl accept_ra=1 && autoconf=1
Currently it's only available in dhcp method.

Set 0 by default (if interface was previously method auto).
we manage them in address now
user can defined both static ips && enable accept_ra 1 in as or auto method

exemple1:
----------
iface eth0 inet auto

iface eth0 inet6 static
	address ....

exemple2:
--------
iface eth0 inet6 static
	address ....
	accept_ra 1
	autoconf 1

We need to process configured addresses,
but we won't purge ipv6 on reload
factorize with adding_get_netlink_cache_accept_ra && _get_netlink_cache_auto
and correctly test if cache exist or not

the netlink cache can have empty value for an interface,
if the interface was not existing when we have populate the cache.
for example, a vlan interface created in pre-up by vlan module.

In this case, we return an empty string
, and fix parsing of empty netlink cache
accept_ra is only to get default gw, autoconf is for generate ip

Also skip only dynamic ipv6 (!ipflag permanent 0x80)
Signed-off-by: Christoph Heiss <[email protected]>
Copy link

@GoetzGoerisch GoetzGoerisch left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants