]> git.ipfire.org Git - thirdparty/bind9.git/commit
Simplify and speed up DNS name compression
authorTony Finch <fanf@isc.org>
Thu, 23 Jun 2022 20:53:46 +0000 (21:53 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 17 Oct 2022 06:45:44 +0000 (08:45 +0200)
commit45b2d8938bda00ef3d733501a74a510493c7377d
treeb3801e06e7c58fac12baba75dfb1098d06a74fb8
parenta00333d0d85d9b90d611cd672ae387ff87bbd9c1
Simplify and speed up DNS name compression

All we need for compression is a very small hash set of compression
offsets, because most of the information we need (the previously added
names) can be found in the message using the compression offsets.

This change combines dns_compress_find() and dns_compress_add() into
one function dns_compress_name() that both finds any existing suffix,
and adds any new prefix to the table. The old split led to performance
problems caused by duplicate names in the compression context.

Compression contexts are now either small or large, which the caller
chooses depending on the expected size of the message. There is no
dynamic resizing.

There is a behaviour change: compression now acts on all the labels in
each name, instead of just the last few.

A small benchmark suggests this is about 2x faster.
24 files changed:
bin/dig/dighost.c
bin/nsupdate/nsupdate.c
bin/tests/wire_test.c
fuzz/dns_message_parse.c
fuzz/dns_rdata_fromwire_text.c
lib/dns/compress.c
lib/dns/include/dns/compress.h
lib/dns/include/dns/request.h
lib/dns/include/dns/types.h
lib/dns/message.c
lib/dns/name.c
lib/dns/ncache.c
lib/dns/rdata.c
lib/dns/rdataset.c
lib/dns/request.c
lib/dns/resolver.c
lib/dns/xfrin.c
lib/ns/client.c
lib/ns/xfrout.c
tests/dns/dnstap_test.c
tests/dns/name_test.c
tests/dns/rdata_test.c
tests/dns/tsig_test.c
tests/libtest/ns.c