Keeping VPN interface status up-to-date in netifd/ubus/luci

I'm trying to improve Zerotier support and faced some issues while working on netifd protocol handler.
Looks like the correct procedure to notify the system about interface status, including current IP address is following:

  • proto_init_update
  • proto_add_ipv4_address
  • proto_send_update

The problem I see here is that proto_add_ipv4_address function re-assigns IP address to the interface when interface status data reaches netifd.
Since Zerotier already assigns IP address to the interface, I'm rather looking for a way to update interface status with all the info (addresses, routes etc.) which is already assigned to the interface without extracting it with ip command and assigning again.

Currently I'm doing it in this way:

1 Like

Have similar questions for nebula netifd support. I checked the source and it's not evident to me how to create a fully compliant netifd protocol.

Conceptually, netifd must be the owner and authoritative source of layer 4 address settings. Protocols that configure IP addresses without involving netifd are not compliant and will lead to undefined behavior such as missing/stale status data, netifd clearing/reverting IP settings on config reload etc.

If the supervised protocol process does not support exposing effective address info without simultaneously configuring it then yes, the only way is extracting the settings and reapplying them through netifd.

I've improved IP addresses extraction from existing interface using JSON output from ip command.
You may use it for Nebula as well, if you want.

I'm not completely sure it extract all possible variables from output ($ptp for IPv4 and $preferred/$valid/$offlink/$class for IPv6)

IPv4 options:

IPv6 options:

1 Like