]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: add cache flush flag to DnsResourceKey
authorDaniel Mack <daniel@zonque.org>
Tue, 24 Nov 2015 14:45:15 +0000 (15:45 +0100)
committerDaniel Mack <daniel@zonque.org>
Tue, 8 Dec 2015 15:41:45 +0000 (16:41 +0100)
MDNS has a 'key cache flush' flag for records which must be masked out for
the parsers to do our right thing. We will also use that flag later (in a
different patch) in order to alter the cache behavior.

src/resolve/resolved-dns-packet.c
src/resolve/resolved-dns-rr.h

index 3a4482a1b7bc8110f05b63594a9f4cb6d7ac6a70..35d1fb02be4c8117968c6fb49181d3d13fae2165 100644 (file)
@@ -1421,6 +1421,7 @@ fail:
 
 int dns_packet_read_key(DnsPacket *p, DnsResourceKey **ret, size_t *start) {
         _cleanup_free_ char *name = NULL;
+        bool cache_flush = false;
         uint16_t class, type;
         DnsResourceKey *key;
         size_t saved_rindex;
@@ -1443,12 +1444,23 @@ int dns_packet_read_key(DnsPacket *p, DnsResourceKey **ret, size_t *start) {
         if (r < 0)
                 goto fail;
 
+        if (p->protocol == DNS_PROTOCOL_MDNS) {
+                /* See RFC6762, Section 10.2 */
+
+                if (class & MDNS_RR_CACHE_FLUSH) {
+                        class &= ~MDNS_RR_CACHE_FLUSH;
+                        cache_flush = true;
+                }
+        }
+
         key = dns_resource_key_new_consume(class, type, name);
         if (!key) {
                 r = -ENOMEM;
                 goto fail;
         }
 
+        key->cache_flush = cache_flush;
+
         name = NULL;
         *ret = key;
 
index b82fa7756221aef4a3596166abb1b50509771940..5cbb927681f39217abf85d4b84603ab117303ef6 100644 (file)
@@ -45,6 +45,9 @@ enum {
 #define DNSKEY_FLAG_ZONE_KEY (UINT16_C(1) << 8)
 #define DNSKEY_FLAG_SEP      (UINT16_C(1) << 0)
 
+/* mDNS RR flags */
+#define MDNS_RR_CACHE_FLUSH  (UINT16_C(1) << 15)
+
 /* DNSSEC algorithm identifiers, see
  * http://tools.ietf.org/html/rfc4034#appendix-A.1 and
  * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml */
@@ -76,6 +79,7 @@ struct DnsResourceKey {
         unsigned n_ref;
         uint16_t class, type;
         char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
+        bool cache_flush:1;
 };
 
 /* Creates a temporary resource key. This is only useful to quickly