tree: 8ff977dff4f41d7168ae1bf66443af274d0b46ea [path history] [tgz]
  1. big_endian.cc
  2. big_endian.h
  3. dns_protocol.h
  4. dns_query.cc
  5. dns_query.h
  6. dns_query_test.cc
  7. dns_response.cc
  8. dns_response.h
  9. dns_response_test.cc
  10. dns_util.cc
  11. dns_util.h
  12. io_buffer.cc
  13. io_buffer.h
  14. README.md
patchpanel/dns/README.md

DNS

Warning: This document is old & has moved. Please update any links:
https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/patchpanel/dns/README.md

This directory contains DNS library which is a modified copy of Chromium's DNS code (net/dns). The current files are taken from milestone M88 of the code with the latest commit hash of ad67ec1efbf21306b583c4daf34cf2ba4c591237.

DNS library is used by:

  • Patchpanel's multicast forwarder.
  • DNS proxy for DNS over HTTPS.

It provides DNS functionalities of:

  • Parsing DNS queries.
  • Create raw DNS responses from DNS queries' answers.

Modifications

The code here is a modification of Chromium's DNS code. The modification is done to minimize the code imported. Currently, the necessary functions we want are:

  • DnsQuery::Parse (for parsing queries),
  • DnsResponse::WriteHeader, WriteAnswer, ... (for writing raw responses).

The modification process is done by importing only the necessary functions, followed by importing the minimal amount of code necessary to make the necessary functions work. For example, functionality of writing DNS queries and parsing DNS responses are removed.

Below are the changes made:

  • Namespaces are changed from net to patchpanel.
  • All the necessary files are flattened into one directory.
  • Update NET_EXPORT with BRILLO_EXPORT.
  • Remove all unneeded functionality.

Alternatives Considered

An alternative is to having a modified copy of the Chromium's DNS code is to port the DNS code to libchrome. Although it avoids having to copy and maintain duplicated code, it has the downsides of needing to continuously update the code alongside libchrome uprevs and having to include the whole DNS code.

Another option would be to use a low level library like libbind9. One disadvantage of going with this approach is introducing additional payload by adding the development package. The API of the library is also fairly complicated and prone to introducing semantic bugs.