From: Vladimír Čunát Date: Wed, 28 Jun 2023 15:48:51 +0000 (+0200) Subject: avoid knot_pkt_default_padding_size() X-Git-Tag: v5.7.0~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b485e5e7432581c5429de0cc4bdf7aa1bc4b5ca;p=thirdparty%2Fknot-resolver.git avoid knot_pkt_default_padding_size() 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. --- diff --git a/NEWS b/NEWS index 5eaa0ffd9..7453ee685 100644 --- 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) diff --git a/lib/resolve.c b/lib/resolve.c index cb43c8e2a..e9436927a 100644 --- a/lib/resolve.c +++ b/lib/resolve.c @@ -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));