Page MenuHomeFreeBSD

libc/resolv: Reimplement the sortlist parser
ClosedPublic

Authored by des on Sun, Jun 28, 8:13 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 6, 7:10 PM
Unknown Object (File)
Mon, Jul 6, 3:30 PM
Unknown Object (File)
Mon, Jul 6, 12:26 AM
Unknown Object (File)
Mon, Jul 6, 12:23 AM
Unknown Object (File)
Sun, Jul 5, 11:32 PM
Unknown Object (File)
Sun, Jul 5, 11:27 PM
Unknown Object (File)
Sun, Jul 5, 9:28 PM
Unknown Object (File)
Sun, Jul 5, 9:25 PM
Subscribers

Details

Summary

When we switched from the BIND4 resolver to the BIND9 resolver, the
sortlist parser was inadvertently disabled due to a missing #define, and
nobody seemed to notice. The sorting code remained enabled in the
resolver, but there was no way to set a sort order.

Reimplement the sortlist parser, but correctly, and update the manual
accordingly. The new parser accepts IPv4 and IPv6 addresses with or
without a mask or prefix length, just like the old one, except IPv6
support was a bit wonky in the original code.

Fixes: 5342d17f09a8 ("Update the resolver in libc to BIND9's one.")
Relnotes: yes

Diff Detail

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

Event Timeline

the sortlist parser was inadvertently disabled, and nobody noticed

Presumably because res_init.c didn't include res_config.h? It'd be nice to mention that in the commit log message.

lib/libc/resolv/res_init.c
583
share/man/man5/resolver.5
115
This revision is now accepted and ready to land.Tue, Jun 30, 2:53 PM
des marked an inline comment as done.Tue, Jun 30, 9:31 PM
This revision now requires review to proceed.Tue, Jun 30, 9:52 PM
lib/libc/resolv/res_init.c
632

Is 0 a valid mask?

lib/libc/resolv/res_init.c
632

Yes, you could use

sortlist ::/0 0.0.0/0

to always prioritize IPv6 responses over IPv4 responses (or the reverse). But I have to special-case 0 because I can't left-shift a number by its entire width.

This revision is now accepted and ready to land.Wed, Jul 1, 3:49 PM
This revision was automatically updated to reflect the committed changes.