resolved: add "static RRs" concept#41213
Conversation
|
Please see the comments in #40980 (review). |
let's ensure the name is actually a valid DNS name.
This only parses a small subset of RR types for now, but we can add more later. Covered are the most important RR types: A, AAAA, PTR.
When we are told to reload our configuration also flush out /etc/hosts explicitly. This is particularly relevant since we suppress too frequent reloads, and hence a synchronous way to force a reload is very useful.
This is an extension of the /etc/hosts concept, but can provide any kind of RRs (well, actually, we only parse A/AAAA/PTR for now, but the concept is open for more). Fixes: systemd#17791
c80680e to
f868062
Compare
|
I addressed all earlier claude and human reviews now. ptal |
Claude review of PR #41213 (f868062)<!-- claude-pr-review --> Must fix
Suggestions
Nits
|
| }, | ||
| /* flags= */ 0, | ||
| &dummy)); | ||
| ASSERT_EQ(be32toh(data.addr.s_addr), 0xC0A80101U); |
There was a problem hiding this comment.
Claude: must-fix: This assertion checks data.addr.s_addr, but the string dispatch above writes to &dummy (at offset 0). Since data.addr still holds 0xC0A80101U from the earlier array-based test, this assertion always passes regardless of whether string dispatch works correctly.
Should be:
ASSERT_EQ(be32toh(dummy.s_addr), 0xC0A80101U);| /* flags= */ 0, | ||
| &dummy)); | ||
|
|
||
| ASSERT_EQ(data.addr.s6_addr[15], 1); |
There was a problem hiding this comment.
Claude: must-fix: Same issue as the IPv4 test: the string dispatch writes to &dummy, but these assertions check data.addr.s6_addr (which still holds ::1 from the earlier array-based test). The string dispatch result in dummy is never verified.
Should be:
ASSERT_EQ(dummy.s6_addr[15], 1);
for (size_t i = 0; i < 15; i++)
ASSERT_EQ(dummy.s6_addr[i], 0);| Resolve.Cache, config_parse_dns_cache_mode, DNS_CACHE_MODE_YES, offsetof(Manager, enable_cache) | ||
| Resolve.DNSStubListener, config_parse_dns_stub_listener_mode, 0, offsetof(Manager, dns_stub_listener_mode) | ||
| Resolve.ReadEtcHosts, config_parse_bool, 0, offsetof(Manager, read_etc_hosts) | ||
| Resolve.ReadStaticRecords, config_parse_bool, 0, offsetof(Manager, read_static_records) |
There was a problem hiding this comment.
Claude: must-fix: The new Resolve.ReadStaticRecords= configuration option is registered here and in resolved.conf.in, but there is no corresponding <varlistentry> documentation in man/resolved.conf.xml. Every other Resolve.* option (e.g., ReadEtcHosts=) has a man page entry describing its behavior and default value.
| q->state != DNS_TRANSACTION_NULL) | ||
| return 0; | ||
|
|
||
| r = dns_query_try_static_records(q); |
There was a problem hiding this comment.
Claude: suggestion: Static records are checked before /etc/hosts in the query resolution order, meaning .rr drop-in files silently take priority over /etc/hosts entries for the same name. This seems intentional, but the systemd.rr(5) man page doesn't mention this precedence relationship. A brief note in the Description section (and/or a comment here analogous to the one above dns_query_try_etc_hosts) would help users understand the resolution order.
| <member><filename>/run/systemd/resolve/static.d/*.rr</filename></member> | ||
| <member><filename>/usr/lib/systemd/resolve/static.d/*.rr</filename></member> | ||
| </simplelist></para> | ||
| </refsynopsisdiv> |
There was a problem hiding this comment.
Claude: suggestion: The synopsis lists /etc/, /run/, and /usr/lib/ paths but omits /usr/local/lib/systemd/resolve/static.d/*.rr. The code uses CONF_PATHS_NULSTR() which includes /usr/local/lib/ as well. Other systemd man pages (e.g., resolved.conf.xml) consistently list all four paths.
| <title>See Also</title> | ||
| <para><simplelist type="inline"> | ||
| <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> | ||
| <member><citerefentry><refentrytitle>systemd-resolved.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
There was a problem hiding this comment.
Claude: nit: The See Also section references systemd-resolved.service(8) and hosts(5) but does not reference resolved.conf(5), which is where the ReadStaticRecords= option to enable/disable this feature lives.
| *ret = TAKE_PTR(rr); | ||
| return 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
Claude: nit: The log message "Decoding DNS type %i is currently not supported." outputs just the raw numeric type. Consider including the symbolic name via dns_type_to_string() for easier debugging, similar to the pattern in resolvectl.c which uses both the name and number.
split out of #40980