<?xml version="1.0" encoding="US-ASCII"?>
<?rfc symrefs="yes" sortrefs="yes" toc="yes" compact="yes"
      subcompact="no" ?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
  <!ENTITY rfc1034 PUBLIC '' 
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1034.xml'>
  <!ENTITY rfc1183 PUBLIC '' 
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1183.xml'>
  <!ENTITY rfc2119 PUBLIC '' 
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
  <!ENTITY rfc2782 PUBLIC '' 
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2782.xml'>
]>

<rfc ipr="trust200902" docName="draft-allbery-afs-srv-records-01"
     category="info">
  <front>
    <title>DNS SRV Resource Records for AFS</title>

    <author initials="R." surname="Allbery" fullname="Russ Allbery">
      <organization>Stanford University</organization>
      <address>
        <postal>
          <street>P.O. Box 20066</street>
          <city>Stanford</city> <region>CA</region>
          <code>94309</code>
          <country>US</country>
        </postal>
        <email>rra@stanford.edu</email>
        <uri>http://www.eyrie.org/~eagle/</uri>
      </address>
    </author>

    <date month="October" year="2009" />

    <area>Applications</area>
    <keyword>AFS</keyword>
    <keyword>DNS</keyword>
    <keyword>SRV</keyword>

    <abstract>
      <t>This document specifies how to use DNS (Domain Name Service) SRV
      RRs (Resource Records) to locate services for the AFS distributed
      file system and how the priority and weight values of the SRV RR
      should be interpreted in the server ranking system used by AFS.  It
      deprecates use of the AFSDB RR to locate AFS cell database servers
      and provides guidance for backward compatibility.</t>
    </abstract>

    <note title="Internet Draft Comments">
      <t>Comments are solicited.  Please include the AFS Standardization
      mailing list at afs3-standardization@openafs.org as a recipient of
      any comments.</t>
    </note>
  </front>

  <middle>
    <section title="Overview and Rationale">
      <t>AFS (a registered trademark of IBM Corporation) is a distributed
      file system organized administratively into cells.  Each AFS cell
      consists of one or more Volume Location Database (VLDB) servers, one
      or more Protection Service (PTS) servers, and one or more file
      servers and volume servers, plus possibly additional services not
      relevant to this document.  Data stored in AFS is divided into
      collections of files called volumes.  An AFS protocol client, when
      accessing a file within a specific AFS cell, first contacts a VLDB
      server for that cell to determine the file server for the AFS volume
      in which that file is located, and then contacts that file server
      directly to access the file.  A client may also need to contact a
      PTS server for that cell to register before accessing files in that
      cell or to query protection database information.</t>

      <t>An AFS client therefore needs to determine, for a given AFS cell,
      the VLDB and possibly the PTS servers for that cell.
      (Traditionally, the VLDB and PTS servers are provided by the same
      host.)  Once the client is in contact with the VLDB server, it
      locates file and volume servers through AFS protocol queries to the
      VLDB server.  Originally, VLDB server information was configured
      separately on each client in a file called the CellServDB file.
      <xref target="RFC1183"/> specified the DNS RR (Resource Record)
      AFSDB to locate VLDB servers for AFS.</t>

      <t>Subsequent to <xref target="RFC1183"/>, a general DNS RR was
      defined by <xref target="RFC2782"/> for service location for any
      service.  This DNS SRV RR has several advantages over the AFSDB RR:
        <list style="symbols">
          <t>AFSDB RRs do not support priority or ranking, leaving AFS
          cell administrators without a way to control which VLDB servers
          clients prefer.</t>

          <t>AFSDB RRs do not include protocol or port information,
          implicitly assuming that all VLDB servers will be contacted over
          the standard port and the UDP protocol.  Future changes to the
          AFS protocol may require separate VLDB server lists for UDP and
          TCP traffic, and some uses of AFS, such as providing VLDB
          service for multiple cells from the same systems, require use of
          different ports.</t>

          <t>Clients using AFSDB RRs must assume that VLDB and PTS
          services are provided by the same host, but it may be useful to
          separate VLDB servers from PTS servers.</t>

          <t>DNS SRV RRs are in widespread use, whereas AFSDB RRs are a
          little-known and little-supported corner of the DNS
          protocol.</t>
        </list>
      For those reasons, it is desirable to move AFS service location from
      the AFSDB RR to DNS SRV RRs.</t>
    </section>

    <section title="Scope">
      <t>This document describes the format and use of DNS SRV RRs for AFS
      service location and deprecates the AFSDB RR.  It also provides
      guidance for transition from the AFSDB RR to DNS SRV RRs and
      recommendations for backward compatibility.</t>

      <t>Documentation of the AFS protocol, the exact purpose and use of
      the VLDB and PTS services, and other information about AFS is
      outside the scope of this document.</t>

      <t>AFSDB RRs may also be used for locating servers for the Open
      Software Foundation's (OSF) Distributed Computing Environment (DCE)
      authenticated naming system, as described in
      <xref target="RFC1183"/>.  Service location for DCE servers is
      outside the scope of this document and not modified by this
      specification.</t>
    </section>

    <section title="Requirements Notation">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL"
      in this document are to be interpreted as described in
      <xref target="RFC2119"/>.</t>
    </section>

    <section title="DNS SRV RRs for AFS">
      <figure>
        <preamble>The label of a DNS SRV RR, as defined in
        <xref target="RFC2782"/>, is:</preamble>

        <artwork>
    _&lt;service&gt;._&lt;proto&gt;.&lt;name&gt;
        </artwork>
      </figure>

      <t>The following values for &lt;service&gt; advertise servers
      providing AFS services:
        <list style="hanging">
          <t hangText="afs3-vlserver:">servers providing AFS VLDB
          services.</t>

          <t hangText="afs3-prserver:">servers providing AFS PTS
          services.</t>
        </list>
      Other AFS services, such as file and volume management services, are
      located through the VLDB service and therefore do not use DNS SRV
      RRs.</t>

      <t>&lt;proto&gt; MUST be "udp" for the current AFS protocol, which
      uses Rx over UDP.  Other values may be used for future revisions of
      the AFS protocol supporting other protocols, such as Rx over
      TCP.</t>

      <t>&lt;name&gt; MUST be the AFS cell name for which the identified
      server provides AFS services.  Clients MUST query DNS SRV RRs only
      for a &lt;name&gt; value exactly matching the AFS cell of interest.
      They MUST not remove leading components to search for more general
      DNS SRV RRs.  The AFS cell "prod.example.com" and the AFS cell
      "example.com" are entirely different cells in the AFS protocol and
      VLDB servers for the latter cannot provide information for the
      former.
        <list style="empty">
          <t>NOTE: As with AFSDB RRs, this means that DNS SRV RRs can only
          be used to locate AFS services for cells whose naming matches
          the structure of the DNS.  This is not a requirement of the AFS
          protocol, but sites creating new AFS cells SHOULD use names that
          follow the structure of the DNS and which result in DNS SRV RRs
          under their administrative control.  This both permits use of
          DNS SRV RRs instead of client configuration and helps avoid
          naming conflicts between separate AFS cells.</t>
        </list>
      </t>

      <t>DNS SRV RRs include a priority and a weight.  As defined in the
      DNS SRV RR specification <xref target="RFC2782"/>, clients MUST
      attempt to contact the target host with the lowest-numbered priority
      they can reach.  AFS clients which use a ranked algorithm to
      determine which server to contact MUST therefore assign a
      sufficiently distinct ranks to targets with different priorities
      such that targets with a higher-numbered priority are only contacted
      if all targets with a lower-numbered priority are inaccessible.
      See <xref target="ranking"/> for more information.</t>

      <t>If there are multiple targets with an equal priority, the weight
      value of the DNS SRV RR SHOULD be used as input to a weighted
      algorithm for selecting servers.  This server ordering MAY be done
      either per call or for the lifetime of the DNS SRV RR information.
      As specified by <xref target="RFC2782"/>, larger weights SHOULD be
      given a proportionately higher probability of being selected.  In
      the presence of records containing weights greater than 0, records
      with weight 0 should have a very small chance of being selected.  A
      weight of 0 SHOULD be used if all targets with that priority are
      weighted equally.  AFS clients MAY take into account network
      performance and other protocol metrics along with SRV RR weights
      when selecting servers, thereby possibly selecting different servers
      than a system based purely on the SRV RRs would indicate.  However,
      such information MUST NOT override the priority information in the
      SRV RR.</t>

      <t>AFS clients MAY cache targets known to be inaccessible by that
      client and ignore those targets when determining which server to
      contact first.  Clients which do this SHOULD have a mechanism to
      retry targets which were previously inaccessible and reconsider them
      according to their priority and weight if they become accessible
      again.</t>

      <t>DNS SRV RRs, like all DNS RRs, have a time-to-live (TTL), after
      which the SRV record information is no longer valid.  As specified
      in <xref target="RFC1034"/>, DNS RRs MUST be discarded after their
      TTL and the DNS query repeated.  This applies to DNS SRV RRs for AFS
      as to any other DNS RR.  Any information derived from the DNS SRV
      RRs, such as preference ranks, MUST also be regenerated based on new
      DNS query results once the TTL for the original DNS information has
      passed.</t>

      <section anchor="ranking" title="Interpretation as AFS Preference Ranks">
        <t>Several AFS implementations use a ranking algorithm that
        assigns numbers representing a preference rank to each server when
        the client first contacts that AFS cell and then prefers the
        server with the lowest rank unless that server goes down.  Clients
        using this algorithm SHOULD assign their ranks as follows:
          <list style="numbers">
            <t>Sort targets by priority and assign a base rank value to
            each target based on its priority.  Each base rank value MUST
            be sufficiently different from the base rank assigned to any
            higher-numbered priority that higher-numbered targets will
            only be attempted if lower-numbered targets cannot be reached.
            It MUST, in other words, be farther from the base rank of any
            distinct priority than any possible automatic adjustment in
            the rank.  When calculating base ranks, observe that the
            numeric value of a priority has no meaning.  Only the ordering
            of distinct priority values between multiple SRV RR targets
            needs to be reflected in the base ranks.</t>

            <t>For each group of targets with the same priority, follow
            the algorithm in <xref target="RFC2782"/> to order those
            targets.  Then, assign those targets ranks formed by
            incrementing the base weight for that priority such that the
            first selected target has the lowest rank, the second selected
            target has the next lowest rank, and so on.</t>
          </list>
        </t>

        <t>After assignment of ranks, the AFS client MAY then adjust the
        ranks dynamically based on network performance and other protocol
        metrics, provided that such adjustments are sufficiently small
        compared to the difference between base ranks that they cannot
        cause servers with a higher-numbered priority to be contacted
        instead of a server with a lower-numbered priority.</t>

        <t>The TTL of the DNS SRV RRs MUST be honored by invalidating and
        regenerating the server preference ranks with new DNS information
        once that TTL has expired.  However, accumulated network and
        protocol metrics may be retained and reapplied to the new
        rankings.</t>

        <t>AFS server preference ranks are conventionally numbers between
        1 and 65535.  DNS SRV RR priorities are numbers between 0 and
        65535.  Implementations following this algorithm could therefore
        encounter problems assigning sufficiently distinct base rank
        values in exceptional cases of very large numbers of DNS SRV RR
        targets with different priorities.  However, an AFS cell
        configuration with thousands of DNS SRV RR targets for an AFS VLDB
        or PTS service with meaningfully distinct priorities is highly
        improbable.  AFS client implementations encountering a DNS SRV RR
        containing targets with more distinct priority values than can be
        correctly represented as base ranks SHOULD fall back to generating
        ranks based solely on priorities, ignoring other rank inputs, and
        disabling dynamic adjustment of ranks.  Implementations MUST be
        able to assign distinct base ranks as described above for at least
        ten distinct priority values.</t>
      </section>
    </section>

    <section title="Use of AFSDB RRs">
      <t>Since many AFS client implementations currently support AFSDB RRs
      but do not support DNS SRV RRs, AFS cells providing DNS SRV RRs
      SHOULD also provide AFSDB RRs.  However, be aware that AFSDB RRs do
      not provide priority or weighting information; all servers listed in
      ASFDB RRs are treated as equal.  AFSDB RRs also do not provide port
      information.</t>

      <t>An AFS cell using DNS SRV RRs SHOULD therefore also provide an
      AFSDB RR listing all AFS servers for which the following statements
      are all true:
        <list style="symbols">
          <t>The server provides both VLDB and PTS service on the standard
          ports (7003 and 7002) respectively.</t>

          <t>The server provides these services over UDP.</t>

          <t>The server either has the lowest-numbered priority of those
          listed in the DNS SRV RRs or the AFS cell administrator believes
          it reasonable for clients using AFSDB RRs to use this server by
          preference.</t>
        </list>
      The above is a default recommendation.  AFS cell administrators MAY
      use different lists of servers in the AFSDB RRs and DNS SRV RRs if
      desired for specific effects based on local knowledge of which
      clients use AFSDB RRs and which clients use DNS SRV RRs.  However,
      AFS servers SHOULD NOT be advertised with AFSDB RRs unless they
      provide VLDB and PTS services via UDP on the standard ports.</t>

      <t>An AFS cell SHOULD have at least one VLDB and at least one PTS
      server providing service on the standard ports of 7003 and 7002,
      respectively, since clients without DNS SRV RR support cannot locate
      servers on non-standard ports.</t>

      <t>Clients SHOULD query DNS SRV RRs by default but SHOULD then fall
      back on AFSDB RRs if no DNS SRV RRs are found.  In the absence of
      DNS SRV RRs, an AFSDB RR of &lt;subtype> 1 SHOULD be treated as
      equivalent to the following pair of DNS SRV RRs:</t>

      <figure>
        <artwork>
    _afs3-vlserver._udp.&lt;cell&gt; &lt;ttl&gt; IN SRV 0 0 7003 &lt;hostname&gt;
    _afs3-prserver._udp.&lt;cell&gt; &lt;ttl&gt; IN SRV 0 0 7002 &lt;hostname&gt;
        </artwork>
      </figure>

      <t>&lt;cell&gt; is the label of the AFSDB RR, &lt;tt&gt; is its TTL,
      and &lt;hostname&gt; is the &lt;hostname&gt; value of the AFSDB RR
      as specified in <xref target="RFC1183"/>.  This is the
      fully-qualified domain name of the server.</t>
    </section>

    <section title="Example">
      <figure>
        <preamble>The following example includes TCP AFS services,
        separation of a PTS server from a VLDB server, and use of
        non-standard ports, all features that either assume future AFS
        protocol development or are not widely supported by current
        clients.  This example is intended to show the range of
        possibilities for AFS DNS SRV RRs, not as a practical example for
        an existing cell.  This is a part of the zone file for a
        fictional example.com domain with AFS services.</preamble>

        <artwork>
    $ORIGIN example.com.
    @                    SOA   server.example.com. root.example.com.
                                ( 2009100201 3600 3600 604800 86400 )
                         NS    server.example.com.
    _afs3-vlserver._udp  SRV   0 2 7003 afsdb1.example.com.
    _afs3-vlserver._udp  SRV   0 4 7003 afsdb2.example.com.
    _afs3-vlserver._udp  SRV   1 0 7008 afsdb3.example.com.

    _afs3-vlserver._tcp  SRV   0 0 7003 afsdb3.example.com.

    _afs3-prserver._udp  SRV   0 0 7002 afsdb1.example.com.

    _afs3-prserver._tcp  SRV   0 0 7002 afsdb3.example.com.

    @                    AFSDB 1 afsdb1.example.com.

    afsdb1               A     172.30.79.10
    afsdb2               A     172.30.79.11
    afsdb3               A     172.30.79.12
        </artwork>
      </figure>

      <t>In this example, the AFS cell name is example.com.</t>

      <t>afsdb1, afsdb2, and afsdb3 all provide VLDB service via UDP.  The
      first two have the same priority but have weights indicating that
      afsdb1 should get about twice as many clients as afsdb2.  afsdb3
      should only be used for UDP VLDB service if afsdb1 and afsdb2 are
      not accessible and provides that service on a non-standard port
      (7008).</t>

      <t>Only one host, afsdb1, provides UDP PTS service.</t>

      <t>afsdb3 provides a theoretical TCP version of AFS VLDB and PTS
      service on the standard ports and is the only server providing these
      services over TCP for this cell.</t>

      <t>An AFSDB RR is provided for backward compatibility with older
      clients.  It lists only afsdb1, since only that host provides both
      VLDB and PTS service over UDP on the standard ports.</t>
    </section>

    <section title="Security Considerations">
      <t>Use of DNS SRV RRs for AFS service location pose the same
      security issues as the existing AFSDB RRs.  Specifically, unless the
      integrity and authenticity of the DNS response is checked, an
      attacker may forge DNS replies and thereby direct clients at a VLDB
      or PTS server under the control of the attacker.  From there, the
      attacker may decieve an AFS client about the volumes and file
      servers in a cell and about the contents of files and directories in
      that cell.  If the client uses cell data in a trusted way, such as
      by executing programs out of that AFS cell or using data from the
      cell as input to other programs, the attacker may be able to further
      compromise the security of the client and trick it into taking
      actions under the attacker's control.</t>

      <t>This attack can be ameliorated if the server is authenticated,
      since the client can then detect a failure to authenticate the
      attacker's servers and thereby detect possible impersonation.
      However, this applies only to authenticated AFS access, and much AFS
      access is unauthenticated.  Furthermore, clients after failure to
      authenticate may fall back to unauthenticated access, which the
      attacker's servers may permit.</t>

      <t>This vulnerability is inherent in the current AFS protocol and
      may be exploited in ways other than DNS spoofing, such as by
      spoofing the results of VLDB queries for an AFS cell.  Addressing it
      properly requires changes to the AFS protocol allowing clients to
      always authenticate AFS services and discard unauthenticated
      data.  Addition of DNS SRV RRs does not make this vulnerability more
      severe, only opens another equivalent point of attack.</t>
    </section>
  </middle>

  <back>
    <references>
      &rfc1034;
      &rfc1183;
      &rfc2119;
      &rfc2782;
    </references>
  </back>
</rfc>
