Skip to content
  • Matthijs Mekking's avatar
    Simplify cachedb rrset statistic counters · 37b41ff6
    Matthijs Mekking authored and Matthijs Mekking's avatar Matthijs Mekking committed
    This commit simplifies the cachedb rrset statistics in two ways:
    - Introduce new rdtypecounter arithmetics, allowing bitwise
      operations.
    - Remove the special DLV statistic counter.
    
    New rdtypecounter arithmetics
    -----------------------------
    "The rdtypecounter arithmetics is a brain twister".  Replace the
    enum counters with some defines.  A rdtypecounter is now 8 bits for
    RRtypes and 3 bits for flags:
    
          0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
        |  |  |  |  |  |  S  |NX|         RRType        |
        +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    
    If the 8 bits for RRtype are all zero, this is an Other RRtype.
    
    Bit 7 is the NXRRSET (NX) flag and indicates whether this is a
    positive (0) or a negative (1) RRset.
    
    Then bit 5 and 6 mostly tell you if this counter is for an active,
    stale, or ancient RRtype:
    
        S = 0x00 means Active
        S = 0x01 means Stale
        S = 0x10 means Ancient
    
    Since a counter cannot be stale and ancient at the same time, we
    treat S = 0x11 as a special case to deal with NXDOMAIN counters.
    
    S = 0x11 indicates an NXDOMAIN counter and in this case the RRtype
    field signals the expiry of this cached item:
    
        RRType = 0 means Active
        RRType = 1 means Stale
        RRType = 2 means Ancient
    37b41ff6