Page MenuHomeFreeBSD

inet_cidr_ntop: Produce valid IPv4 mapped addresses
Needs ReviewPublic

Authored by ivy on Oct 30 2025, 9:12 PM.
Tags
None
Referenced Files
F147392851: D53488.id.diff
Tue, Mar 10, 2:47 PM
Unknown Object (File)
Tue, Mar 10, 2:43 AM
Unknown Object (File)
Sat, Mar 7, 9:09 AM
Unknown Object (File)
Wed, Mar 4, 1:02 PM
Unknown Object (File)
Wed, Mar 4, 4:09 AM
Unknown Object (File)
Tue, Mar 3, 5:27 AM
Unknown Object (File)
Tue, Mar 3, 5:26 AM
Unknown Object (File)
Tue, Mar 3, 5:26 AM
Subscribers

Details

Reviewers
des
Group Reviewers
network
Summary

For some inputs with the AF_INET6 family, inet_cidr_ntop() may produce
invalid output like "::ffff:0.0", because it considers the prefix length
when determining how many octets of the IPv4 address to emit.

This behaviour doesn't make sense, because a mapped address always
contains a complete IPv4 address, which must be 4 octets; anything
else is an invalid address.

Fix this by removing the relevant code and simply emitting 4 octets
in all cases.

While here, add some tests for both inet_cidr_ntop and inet_cidr_pton
based on the inet_net_* tests.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68298
Build 65181: arc lint + arc unit