Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup interface and code, add new base16 decoder, etc #117

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

k0ekk0ek
Copy link
Contributor

This PR removes exposing the type and field information externally, thereby simplifying the code. It also adds the High performance base16 decoder from client9. Most importantly, it simplifies the SIMD and fallback scanners by adopting a slightly different interface and updates a lot of individual parser functions.

A lot of the code was more-or-less:

parse_xxx_rdata(...)
{
  // lex called in parse_rr
  if ((error = parse_yyy(...)) < 0)
    return error;
  lex(parser, token);
  if ((error = parse_zzz(...)) < 0)
    return error;
  ...
}

First the lex function would classify the type of token (e.g. <contiguous>, <quoted>, <line-feed> or <end-of-file>) to correctly set pointer and length, after which the parse_yyy and parse_zzz functions would check again to ensure proper syntax. In zone files though, often times we know exactly what type to expect and I've opted to remove the checks from the parse functions and simply do them in one go:

parse_xxx_rdata(...)
{
  if ((error = have_contiguous(...)) < 0)
    return error;
  if ((error = parse_yyy(...)) < 0)
    return error;
  if ((error = take_contiguous(...)) < 0)
    return error;
  if ((error = parse_zzz(...)) < 0)
    return error;
  ...
}

Leading to ~4% faster code.

Needs more testing etc before merging to main.

Exposing type and field information makes little sense. Applications are
required to interpret wire representation for handling queries. Unknown
types can simply be handled generically. Removing the information
simplifies the interface and code.

Fixes NLnetLabs#98.
@k0ekk0ek k0ekk0ek force-pushed the still-not-spring-cleaning branch from 1dfddc9 to e735b6d Compare December 19, 2023 15:27
@k0ekk0ek k0ekk0ek marked this pull request as ready for review December 19, 2023 15:27
@k0ekk0ek k0ekk0ek merged commit f6df110 into NLnetLabs:main Dec 19, 2023
4 checks passed
@k0ekk0ek k0ekk0ek deleted the still-not-spring-cleaning branch February 8, 2024 09:05
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.

1 participant