Repository navigation
add "resolvectl show-cache" call and IPC backend for that - #28012
Conversation
This is identical to json_dispatch_variant() but doesn't increase the ref counter of the variant. This is useful for taking JSON objects apart locally without the intention to keep any component pinned for longer than the local stack frame.
… all of resolved's RR caches This adds a simple varlink call io.systemd.Resolve.Monitor.DumpCache to the existing io.systemd.Resolve.Monitor service. It compiles a JSON object containing the per-scope cache entries and returns it. Replaces: systemd#20053 systemd#19104 Fixes: systemd#14796
It reverse what dns_resource_key_to_json(), i.e. turns JSON data into a parsed DnsResourceKey object. Ultimately this just moves a client-side local wrapper into generic code. Nothing truly new here.
This does the usual compound init trick to get formatted strings of stuff. We should probably port various pieces of code over to using this.
A wrapper around the new varlink call, showing the data either in its native JSON or in a more human readable textual form.
992cd8c to
6050e8b
Compare
|
@Winterhuman well, this really just dumps caches, it does not do statistics or so. But if this works for you then this sounds good to me. |
|
It'd still give the same information, even if not presented nicely, right? If so, yeah, that works for me, a |
|
Can you add some tests to |
Is that really necessary? it's a debug tool... |
|
tbh, i am just too lazy for a debug tool. let's merge. |
It's a tool that has functionality, that can break accidentally. If someone else works on resolved and they don't run this manually, there's nothing checking that it won't break |
=================================================================
==8737==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c0000002eb at pc 0x7f3905aadac1 bp 0x7fff473fe250 sp 0x7fff473fe248
READ of size 1 at 0x60c0000002eb thread T0
#0 0x7f3905aadac0 in json_variant_unref ../src/shared/json.c:864
#1 0x40a3ef in json_variant_unrefp ../src/shared/json.h:96
#2 0x430193 in verb_show_cache ../src/resolve/resolvectl.c:2897
#3 0x7f3905c77d27 in dispatch_verb ../src/shared/verbs.c:103
#4 0x4332bc in native_main ../src/resolve/resolvectl.c:3690
#5 0x4341f6 in run ../src/resolve/resolvectl.c:3830
#6 0x43431c in main ../src/resolve/resolvectl.c:3833
#7 0x7f390424a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
#8 0x7f390424a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
#9 0x407314 in _start (/home/vagrant/systemd/build/resolvectl+0x407314)
0x60c0000002eb is located 107 bytes inside of 120-byte region [0x60c000000280,0x60c0000002f8)
freed by thread T0 here:
#0 0x7f39070b9388 in __interceptor_free.part.0 (/lib64/libasan.so.8+0xb9388)
#1 0x7f3905aadca0 in json_variant_unref ../src/shared/json.c:872
#2 0x7f3905c4e5e9 in varlink_clear_current ../src/shared/varlink.c:441
#3 0x7f3905c4ea78 in varlink_clear ../src/shared/varlink.c:455
#4 0x7f3905c4fc25 in varlink_destroy ../src/shared/varlink.c:489
#5 0x7f3905c50079 in varlink_unref ../src/shared/varlink.c:495
#6 0x40b485 in varlink_unrefp ../src/shared/varlink.h:173
#7 0x430187 in verb_show_cache ../src/resolve/resolvectl.c:2898
#8 0x7f3905c77d27 in dispatch_verb ../src/shared/verbs.c:103
#9 0x4332bc in native_main ../src/resolve/resolvectl.c:3690
#10 0x4341f6 in run ../src/resolve/resolvectl.c:3830
#11 0x43431c in main ../src/resolve/resolvectl.c:3833
#12 0x7f390424a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
previously allocated by thread T0 here:
#0 0x7f39070ba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af)
#1 0x7f3905aa4aa0 in malloc_multiply ../src/basic/alloc-util.h:120
#2 0x7f3905aac078 in json_variant_new_object ../src/shared/json.c:714
#3 0x7f3905ac1d57 in json_parse_internal ../src/shared/json.c:3014
#4 0x7f3905ac4dab in json_parse_with_source ../src/shared/json.c:3258
#5 0x7f3905c4b73b in json_parse ../src/shared/json.h:233
#6 0x7f3905c55b46 in varlink_parse_message ../src/shared/varlink.c:795
#7 0x7f3905c590a8 in varlink_process ../src/shared/varlink.c:1155
#8 0x7f3905c62f11 in varlink_call ../src/shared/varlink.c:1765
#9 0x42fc9a in verb_show_cache ../src/resolve/resolvectl.c:2905
#10 0x7f3905c77d27 in dispatch_verb ../src/shared/verbs.c:103
#11 0x4332bc in native_main ../src/resolve/resolvectl.c:3690
#12 0x4341f6 in run ../src/resolve/resolvectl.c:3830
#13 0x43431c in main ../src/resolve/resolvectl.c:3833
#14 0x7f390424a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
SUMMARY: AddressSanitizer: heap-use-after-free ../src/shared/json.c:864 in json_variant_unref |
Follow-up for: systemd#28012 Addresses these: systemd#28012 (comment)
|
Fix for those memory issues → #28034 |
|
Thanks! Though the idea was to make a compelling argument in favor of a simple test that could just call |
Follow-up for: #28012 Addresses these: #28012 (comment)
This builds on the DNS query monitoring logic, and adds a simply way to dump all of resolved's caches.
Replaces: #20053 #19104
Fixes: #14796