]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
avoid knot_pkt_default_padding_size()
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 28 Jun 2023 15:48:51 +0000 (17:48 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 10 Jul 2023 18:54:32 +0000 (20:54 +0200)
The reserved size in packet is a messy thing, broken by
https://gitlab.nic.cz/knot/knot-dns/-/commit/ded5fbf01d00a875f141
Fortunately this function is trivial, so we can inline what we need.
It gets complicated by an earlier typo fix, though.

NEWS
lib/resolve.c

diff --git a/NEWS b/NEWS
index 5eaa0ffd97edd0c3f8c2770e4b46dfd27282c6e9..7453ee6851c7b0f7787c2b642e04c864e0a6212a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Bugfixes
 - fix unusual timestamp format in debug dumps of records (!1386)
 - adjust linker options; it should help less common platforms (!1384)
 - hints module: fix names inside home.arpa. (!1406)
+- EDNS padding (RFC 8467) compatibility with knot-dns 3.3 libs (!1422)
 
 
 Knot Resolver 5.6.0 (2023-01-26)
index cb43c8e2a3bbb315a09ab6845270bc3df4bed346..e9436927a92041365b155fdecedd15206a77d26a 100644 (file)
@@ -429,7 +429,15 @@ static int pkt_padding(knot_pkt_t *packet, int32_t padding)
        int32_t pad_bytes = -1;
 
        if (padding == -1) { /* use the default padding policy from libknot */
-               pad_bytes =  knot_pkt_default_padding_size(packet, opt_rr);
+               const size_t block_size = knot_wire_get_qr(packet->wire)
+                                       ? KNOT_EDNS_ALIGNMENT_RESPONSE_DEFAULT
+                               #if KNOT_VERSION_HEX < 0x030200
+                                       : KNOT_EDNS_ALIGNMENT_QUERY_DEFALT;
+                               #else
+                                       : KNOT_EDNS_ALIGNMENT_QUERY_DEFAULT;
+                               #endif
+               pad_bytes = knot_edns_alignment_size(packet->size, knot_rrset_size(opt_rr),
+                                                       block_size);
        }
        if (padding >= 2) {
                int32_t max_pad_bytes = knot_edns_get_payload(opt_rr) - (packet->size + knot_rrset_size(opt_rr));