edfbb2
commit 08443b19965f48862b02c2fd7b33a39d66daf2ff
edfbb2
Author: Florian Weimer <fweimer@redhat.com>
edfbb2
Date:   Wed Oct 14 10:54:39 2020 +0200
edfbb2
edfbb2
    support: Provide a way to clear the RA bit in DNS server responses
edfbb2
edfbb2
diff --git a/support/resolv_test.c b/support/resolv_test.c
edfbb2
index 8cca4e6cf723de28..9323f1d55b0be8f1 100644
edfbb2
--- a/support/resolv_test.c
edfbb2
+++ b/support/resolv_test.c
edfbb2
@@ -181,7 +181,9 @@ resolv_response_init (struct resolv_response_builder *b,
edfbb2
   b->buffer[2] |= b->query_buffer[2] & 0x01; /* Copy the RD bit.  */
edfbb2
   if (flags.tc)
edfbb2
     b->buffer[2] |= 0x02;
edfbb2
-  b->buffer[3] = 0x80 | flags.rcode; /* Always set RA.  */
edfbb2
+  b->buffer[3] = flags.rcode;
edfbb2
+  if (!flags.clear_ra)
edfbb2
+    b->buffer[3] |= 0x80;
edfbb2
   if (flags.ad)
edfbb2
     b->buffer[3] |= 0x20;
edfbb2
 
edfbb2
diff --git a/support/resolv_test.h b/support/resolv_test.h
edfbb2
index ff5571dace92c936..825abb9ff2897a43 100644
edfbb2
--- a/support/resolv_test.h
edfbb2
+++ b/support/resolv_test.h
edfbb2
@@ -148,6 +148,10 @@ struct resolv_response_flags
edfbb2
   /* If true, the AD (authenticated data) flag will be set.  */
edfbb2
   bool ad;
edfbb2
 
edfbb2
+  /* If true, do not set the RA (recursion available) flag in the
edfbb2
+     response.  */
edfbb2
+  bool clear_ra;
edfbb2
+
edfbb2
   /* Initial section count values.  Can be used to artificially
edfbb2
      increase the counts, for malformed packet testing.*/
edfbb2
   unsigned short qdcount;