Skip to content

feat(welcome): add prefix field for CIDR subnet mask#47

Open
VasilevNStas wants to merge 1 commit into
APN-Network:masterfrom
VasilevNStas:15-feat/welcome-prefix
Open

feat(welcome): add prefix field for CIDR subnet mask#47
VasilevNStas wants to merge 1 commit into
APN-Network:masterfrom
VasilevNStas:15-feat/welcome-prefix

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Description

Adds a prefix field to the Welcome message carrying the CIDR subnet mask for the tunnel IP, enabling correct TUN interface configuration without hardcoded assumptions.

Problem

Welcome.ip (field 2) delivers the tunnel address as 4 raw bytes but omits the prefix length. Configuring a TUN interface requires both the address and the network boundary (e.g. ip addr add 10.0.0.5/24 dev tun0). Without this field every implementation hardcodes the subnet out-of-band; a mismatch silently produces wrong routing tables.

Fix

New field uint32 prefix = 9:

  • Valid range: 1–32 (CIDR prefix length)
  • Zero: unpopulated / malformed — clients MUST disconnect
  • Wire-compatible addition (new field, old clients ignore it)

The ip comment is also updated to cross-reference prefix.

Migration

Nodes must populate prefix alongside ip on every successful Auth. Clients that receive prefix == 0 should treat the Welcome as malformed and disconnect.

Closes #15

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 plz review
@davvd plz review

@davvd

davvd commented Jul 4, 2026

Copy link
Copy Markdown
Member

@VasilevNStas we have merge conflicts here, please resolve them and we'll merge

The Welcome message delivers the tunnel IP but omits the prefix
length, forcing every client to hardcode the subnet out-of-band.
A mismatch between implementations silently produces wrong
routing tables.

Add uint32 prefix = 11 carrying the CIDR prefix length (1-32).
Field 9 was taken by ip6 (PR APN-Network#62). Zero means unpopulated —
clients MUST treat it as malformed and disconnect.
Wire-compatible addition.
@VasilevNStas
VasilevNStas force-pushed the 15-feat/welcome-prefix branch from 701904f to 5426629 Compare July 4, 2026 17:58
@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@davvd conflicts resolved — rebased on latest master. field number changed from 9 to 11 (9 was taken by ip6 from #62).

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.

Welcome.ip omits prefix length, making TUN interface configuration incomplete

2 participants