Page MenuHomeFreeBSD

libc: Import OpenBSD's inet_net_{ntop,pton}
Needs ReviewPublic

Authored by ivy on Fri, Sep 19, 8:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 13, 6:45 PM
Unknown Object (File)
Sun, Oct 12, 6:38 PM
Unknown Object (File)
Fri, Oct 10, 10:35 PM
Unknown Object (File)
Thu, Oct 9, 6:57 PM
Unknown Object (File)
Wed, Oct 8, 8:57 PM
Unknown Object (File)
Wed, Oct 8, 7:58 PM
Unknown Object (File)
Fri, Oct 3, 5:09 PM
Unknown Object (File)
Fri, Oct 3, 3:27 AM
Subscribers

Details

Summary

Our versions of these functions (originally taken from BIND) simply
don't work correctly for AF_INET6. These were removed from BIND itself
quite a while ago, but OpenBSD has made quite a few fixes in the mean
time, so import their code.

Add tests for both functions.

MFC after: 1 week
Obtained from: OpenBSD (lib/libc/net)
Reported by: Nico Sonack <nsonack@herrhotzenplotz.de>
PR: 289198

Diff Detail

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

Event Timeline

ivy requested review of this revision.Fri, Sep 19, 8:12 PM

inet_net_test: add a test for an overlong prefix

the comment says we want to test this, and we do, so actually test it.

add tests for invalid input

Oh, that's a lot to review :) Thanks a lot for creating the tests. Quick question: do the tests pass on the previous implementation?

do the tests pass on the previous implementation?

no. as the reporter mentioned in the PR, our current implementation is completely broken -- it almost never produces valid output. i'm not sure how no one noticed that, but i assume these functions just aren't very widely used (i'd never even heard of them until i looked at the PR).

fix a few nits in inet_net_test, and while here, add the full license text to the header (for legal reasons, my new preference for files i create)

This change touches inet_net_ntop_ipv4(). I think this deserves careful review.

Nothing uses these functions, they are non-standard and never worked properly. Even BIND (which is where we got them) didn't use them.

lib/libc/inet/inet_net_ntop.c
73

This is wrong.

lib/libc/inet/inet_net_pton.c
177

If these are currently broken and do not work we should just not support net classes.

lib/libc/inet/inet_net_pton.c
177

this change is not related to network classes, which don't exist in IPv6 at all. as far as i'm aware our current implementation supports classes okay.