mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 19:25:56 +03:00
[GH-ISSUE #244] Replace LALRPOP-based resolve.conf parser with a simpler one #116
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#116
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @briansmith on GitHub (Oct 23, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/244
Some issues with LALRPOP I've noticed:
LALRPOP is complex. It is difficult to audit it and the code it generates for correctness, even if one has an extensive background in parsing and parser generators.
LALRPOP generates large code. This is generally a good trade-off as the code is specialized to parse things very fast. However, in the case of a typical use of Trust-DNS-Resolver, resolv.conf is parsed exactly once, and resolv.conf is small and simple, so optimizing for code size makes more sense than optimizing for maximum parsing performance.
It has a lot of dependencies:
github.com/nikomatsakis/lalrpop@01ccd43789/lalrpop/Cargo.toml (L16-L29). Especially with #239 and my (currently-)forthcoming PRs on top of it, LALRPOP's dependencies dwarf trust_dns_resolver's and trust_dns_proto's dependencies.LALRPOP itself is very slow to build: I'm guess LALRPOP is self-hosting and thus uses a LALRPOP-generated parser. This makes LALRPOP very slow to build. It seems to be the slowest part of building trust_dns_resolver from scratch, by far.
I believe we can replace the LALRPOP-based parser with a much simpler one that doesn't need any third-party parsing library or parser generators, because resolv.conf has a very simple file format.
@briansmith commented on GitHub (Oct 23, 2017):
I see now that also the LALRPOP-based parser has trouble with comments. It's probably easier to make a hand-written parser that skips comments than to write a custom lexer for the LALRPOP-based parser that supports comments.
@bluejekyll commented on GitHub (Oct 23, 2017):
Yes. I agree with all of this. The LALRPOP based parser was an experiment to see if it would be worth to use for zone’s file parsing, rather than the custom handwritten parser in place now.
It would be very easier to make a cleaner version of the resolv.conf parser that is more flexible as well.
@briansmith commented on GitHub (Oct 25, 2017):
LALRPOP generates a parser that has a dependency on the
regexcrate, so while it looks like theregexdependency is unused, it is actually needed for this reason. If the new parser isn't implemented usingregexthen theregexdependency can be removed when the new parser is committed.Besides
regex, thelalrpop-utildependency can also be removed whenlalrpopis removed.Also, I noticed that there are some commented-out tests that imply that comments are allowed anywhere at the end of a line. Actualy, according to the Linux resolv.conf man page, comments must start at the first character of a line; i.e. they cannot follow non-comment text or even whitespace on a line. This should make comment filtering easy to handle in the new parser, since we can just break the input into lines and then filter out all lines that start with "#" or ";" before processing them.
@little-dude commented on GitHub (Nov 28, 2017):
What do you think of https://github.com/tailhook/resolv-conf ?
The readme says it depends on
nombut it doesn't actually. The only dependency is https://github.com/tailhook/quick-error, which does not depend on anything else.@bluejekyll commented on GitHub (Nov 28, 2017):
I already use
error-chain, I think that usesquick-errorinternally, so that's not a huge issue.Looking at that impl, it's pretty simple and straightforward. I think that would be ok. I can't say if it handles everything that we need, as I only looked at it briefly, but it looks reasonable.
@little-dude commented on GitHub (Nov 29, 2017):
I've started working on this. I think we could use this crate to parse the resolv.conf. This give us a
resolv_conf::Configthat we can turn into atrust_dns_resolver::config::ResolverConfigandtrust_dns_resolver::config::ResolverOpts.I started porting trust-dns tests to https://github.com/tailhook/resolv-conf/ (see: https://github.com/tailhook/resolv-conf/pull/2)
@cssivision commented on GitHub (Feb 6, 2018):
LALRPOP itself is very slow to build, can we cut a new release for resolver? @bluejekyll , also this issue can be closed.
@bluejekyll commented on GitHub (Feb 6, 2018):
Yes. I need to put together some release notes. And after learning some more about mDNS requirements, I want to review some of the new name and label methods before we release. I think I have some time to do this tonight.
@bluejekyll commented on GitHub (Feb 6, 2018):
Fixed in #335