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