From ca184670a2d36262c704bdd79a5ebf05e3a47161 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 24 Sep 2024 17:02:38 +1000 Subject: [PATCH] Add grease controls to the view structure --- lib/dns/include/dns/message.h | 3 ++- lib/dns/include/dns/view.h | 14 ++++++++++++++ lib/dns/view.c | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index a467ea447f..6c80694e5e 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -99,7 +99,8 @@ #define DNS_MESSAGEFLAG_CD 0x0010U /*%< EDNS0 extended message flags */ -#define DNS_MESSAGEEXTFLAG_DO 0x8000U +#define DNS_MESSAGEEXTFLAG_DO 0x8000U +#define DNS_MESSAGEEXTFLAG_KNOWN_FLAGS DNS_MESSAGEEXTFLAG_DO /*%< EDNS0 extended OPT codes */ diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 266ba49d6c..9dd2f0041d 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -186,6 +186,20 @@ struct dns_view { uint16_t max_queries; uint8_t max_restarts; + /* + * Grease the protocol by sending possible future + * changes and checking the result matches defined + * behaviour. + */ + bool grease_dns_flags; /* DNS flag 0x40 */ + bool grease_edns_flags; /* EDNS Unknown flags */ + bool grease_edns_neg; /* EDNS version negotiation */ + bool grease_nsid; /* Request NSID */ + uint8_t grease_edns_max_version; /* Currently 0 */ + uint16_t grease_edns_known_flags; /* Don't grease these flags */ + unsigned int grease_rate; /* Grease this % of queries */ + time_t grease_until; /* Turn off flags greasing at this time */ + /* * Configurable data for server use only, * locked by server configuration lock. diff --git a/lib/dns/view.c b/lib/dns/view.c index 963d862723..e6b4a20c8a 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -120,6 +120,7 @@ dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, .root_key_sentinel = true, .udpsize = DEFAULT_EDNS_BUFSIZE, .max_restarts = DEFAULT_MAX_RESTARTS, + .grease_edns_known_flags = DNS_MESSAGEEXTFLAG_KNOWN_FLAGS, }; isc_refcount_init(&view->references, 1);