schneuwlym created an issue (kamailio/kamailio#4174)
### Description
A NAPTR record in dns cache may be skipped if all IPs are unreachable. The NAPTR record contains the internal parameter `skip_record`. From outside, it is not possible to view the state of a certain NAPTR record.
Extend the return value of `dns_cache_print_entry` with the parameter `skip_record`.
### Expected behavior
The answer of `kamcmd dns.view` shows `yes` or `no` depending on the internal state of `skip_record`. ``` { name: skipped.example.com type: NAPTR size_bytes: 208 reference_counter: 2 permanent: no expires: 268 last_used: 29 negative_entry: no records: { { rr_idx: 0 rr_order: 10 rr_preference: 10 -> rr_skip_record: yes rr_flags: S rr_service: SIPS+D2T rr_regexp: rr_regexp: _sips._tcp.skipped.example.com rr_permanent: no rr_expires: 268 } } } { name: valid.example.com type: NAPTR size_bytes: 328 reference_counter: 1 permanent: no expires: 294 last_used: 5 negative_entry: no records: { { rr_idx: 0 rr_order: 20 rr_preference: 20 -> rr_skip_record: no rr_flags: S rr_service: SIP+D2U rr_regexp: rr_regexp: _sip._udp.valid.example.com rr_permanent: no rr_expires: 294 } { rr_idx: 1 rr_order: 10 rr_preference: 10 -> rr_skip_record: no rr_flags: S rr_service: SIPS+D2T rr_regexp: rr_regexp: _sips._tcp.valid.example.com rr_permanent: no rr_expires: 294 } } }
```
#### Actual observed behavior
At the moment it is not visible why a NAPTR record is not used.
### Possible Solutions
The following patch extends the output of `dns_cache_print_entry` with the parameter `rr_skip_record`.
The patch has been tested locally.
```patch From c4d559f12892fb5a2c3b572f9660b637299fcafb Mon Sep 17 00:00:00 2001 From: Mathias Schneuwly mathias.schneuwly@ruag.ch Date: Tue, 11 Mar 2025 12:38:44 +0000 Subject: [PATCH] Print parameter skip_record in dns_cache_print_entry
--- src/core/dns_cache.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c index 1507e89015..1bb95a2d41 100644 --- a/src/core/dns_cache.c +++ b/src/core/dns_cache.c @@ -3898,6 +3898,13 @@ int dns_cache_print_entry(rpc_t *rpc, void *ctx, struct dns_hash_entry *e) rpc->fault(ctx, 500, "Internal error adding naptr order"); return -1; } + if(rpc->struct_add(sh, "s", "rr_skip_record", + ((struct naptr_rdata *)(rr->rdata))->skip_record ? "yes" : "no") + < 0) { + rpc->fault( + ctx, 500, "Internal error adding naptr rr_skip_record"); + return -1; + } s.s = ((struct naptr_rdata *)(rr->rdata))->flags; s.len = ((struct naptr_rdata *)(rr->rdata))->flags_len; if(rpc->struct_add(sh, "S", "rr_flags", &s) < 0) {