Merge branch 'kdig_badcookie_max' into 'master'

kdig: limit re-tries on BADCOOKIE

See merge request knot/knot-dns!1205
This commit is contained in:
Daniel Salzman 2020-10-25 17:43:50 +01:00
commit aa4bac94de
3 changed files with 9 additions and 5 deletions

View file

@ -741,7 +741,7 @@ static int process_query_packet(const knot_pkt_t *query,
}
// Check for BADCOOKIE RCODE and repeat query with the new cookie if required.
if (knot_pkt_ext_rcode(reply) == KNOT_RCODE_BADCOOKIE && query_ctx->badcookie) {
if (knot_pkt_ext_rcode(reply) == KNOT_RCODE_BADCOOKIE && query_ctx->badcookie > 0) {
printf("\n");
WARN("bad cookie from %s, retrying with the received one\n",
net->remote_str);
@ -770,6 +770,8 @@ static int process_query_packet(const knot_pkt_t *query,
// Restore the original client cookie.
new_ctx.cc = query_ctx->cc;
new_ctx.badcookie--;
knot_pkt_t *new_query = create_query_packet(&new_ctx);
ret = process_query_packet(new_query, net, &new_ctx, ignore_tc,
sign_ctx, style);

View file

@ -43,6 +43,8 @@
#define DEFAULT_ALIGNMENT_SIZE 128
#define DEFAULT_TLS_OCSP_STAPLING (7 * 24 * 3600)
#define BADCOOKIE_RETRY_MAX 10
static const flags_t DEFAULT_FLAGS_DIG = {
.aa_flag = false,
.tc_flag = false,
@ -1005,14 +1007,14 @@ static int opt_nocookie(const char *arg, void *query)
static int opt_badcookie(const char *arg, void *query)
{
query_t *q = query;
q->badcookie = true;
q->badcookie = BADCOOKIE_RETRY_MAX;
return KNOT_EOK;
}
static int opt_nobadcookie(const char *arg, void *query)
{
query_t *q = query;
q->badcookie = false;
q->badcookie = 0;
return KNOT_EOK;
}
@ -1480,7 +1482,7 @@ query_t *query_create(const char *owner, const query_t *conf)
query->edns = -1;
query->cc.len = 0;
query->sc.len = 0;
query->badcookie = true;
query->badcookie = BADCOOKIE_RETRY_MAX;
query->padding = -1;
query->alignment = 0;
tls_params_init(&query->tls);

View file

@ -114,7 +114,7 @@ struct query {
/*!< EDNS server cookie. */
knot_edns_cookie_t sc;
/*!< Repeat query after BADCOOKIE. */
bool badcookie;
int badcookie;
/*!< EDNS0 padding (16unsigned + -1 ~ uninitialized, -2 ~ default, -3 ~ none). */
int32_t padding;
/*!< Query alignment with EDNS0 padding (0 ~ uninitialized). */