<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "reference.RFC.2119.xml">
<!ENTITY RFC2131 SYSTEM "reference.RFC.2131.xml">
<!ENTITY RFC3046 SYSTEM "reference.RFC.3046.xml">
<!ENTITY RFC3118 SYSTEM "reference.RFC.3118.xml">
<!ENTITY RFC3315 SYSTEM "reference.RFC.3315.xml">
<!ENTITY RFC8174 SYSTEM "reference.RFC.8174.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc number="8357" category="std" submissionType="IETF" consensus="yes" ipr="trust200902">
  <front>

    <title abbrev="DHCP Relay Source Port">Generalized UDP Source Port for DHCP Relay</title>

    <author fullname="Naiming Shen" initials="N" surname="Shen">
      <organization>Cisco Systems</organization>

      <address>
        <postal>
          <street>560 McCarthy Blvd.</street>


          <city>Milpitas</city>

          <region>CA</region>

          <code>95035</code>

          <country>United States of America</country>
        </postal>

        <phone/>
        
        <email>naiming@cisco.com</email>


      </address>
    </author>

    <author fullname="Enke Chen" initials="E" surname="Chen">
      <organization>Cisco Systems</organization>

      <address>
        <postal>
          <street>560 McCarthy Blvd.</street>


          <city>Milpitas</city>

          <region>CA</region>

          <code>95035</code>

          <country>United of States of America</country>
        </postal>

        <phone/>
        
        <email>enkechen@cisco.com</email>


      </address>
    </author>

    <date month="March" year="2018"/>

    <area>Internet</area>

    <workgroup>Networking Working Group</workgroup>

    <abstract>
        <t> This document defines an extension to the DHCP protocols
            that allows a relay agent to use any available source port for
            upstream communications. The extension also allows inclusion of a DHCP option that can
            be used to statelessly route responses back to the appropriate
            source port on downstream communications.
        </t>
    </abstract>
  </front>

  <middle>

    <section title="Introduction">
        <t>RFC 2131 <xref target="RFC2131"/> and RFC 3315 <xref target="RFC3315"/> specify the use of
            UDP as the transport protocol for DHCP.
            They also define both the server- and client-side port numbers. The IPv4 server port is
            UDP number (67) and the client port is UDP number (68); for
            IPv6, the server port is (547) and the client port is (546).
      </t>
      <t> The fixed UDP port combinations for the DHCP protocol scheme creates
          challenges in certain DHCP relay operations.
          For instance, in a large-scale DHCP relay implementation
          on a single-switch node, the DHCP relay
          functionality may be partitioned among multiple relay
          processes.
          All of these DHCP relay processes may share the
          same IP address of the switch node. If the UDP source port has
          to be a fixed number as currently specified, the
          transport socket operation of DHCP packets would need
          to go through a central entity or process, which would defeat
          the purpose of distributing DHCP relay functionality.
      </t>
      <t> In some large-scale deployments, the decision
          to split the DHCP functionality into multiple processes on a node may
          not be purely based on DHCP relay computational load. Rather,
          DHCP relay could just be
          one of the functions in a multi-process implementation.
      </t>
      <t> Although assigning a different IPv4/IPv6 source address for
          each DHCP relay process can be a solution, this would introduce
          operational and network management complexities, especially
          given the scarceness of IPv4 addresses.
      </t>

      <t> This document defines an extension to relax the fixed UDP source port
          requirement for the DHCP relay agents. This extension
          requires a DHCP server to
          remember the inbound packet's UDP port number along with
          the IPv4/IPv6 address. When sending back replies, the DHCP server
          MUST use the UDP port number that the incoming relay agent
          uses instead of the fixed DHCP port number. In the case of
          IPv6-cascaded relay agents <xref target="RFC3315"></xref>, the
          upstream relay agent needs to use the "Relay Source Port Option"
          to record the downstream source port, and it MUST use this
          recorded port number instead of the fixed DHCP port number when
          replaying the reply messages.
      </t>

    </section>

    <section title="Terminology">

      <section title="Requirements Language">
        <t>
    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
    NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
    "MAY", and "OPTIONAL" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>

      </section>

       <section title="Definitions"> <t>
        <list style='hanging' hangIndent="3">

            <t hangText="Downstream Device:">
                In the DHCP relay context, this refers to the next relay agent
                that forwards Relay-reply messages.
            </t>
            <t hangText="Upstream Device:">
                In the DHCP relay context, this refers to the next relay agent
                or DHCP server that forwards Relay-forward messages.
            </t>
            <t hangText="Relay Source Port:">
                This is the UDP port that a relay agent uses to receive
                Relay-forward messages from an upstream device.
            </t>
            <t hangText="Downstream Source Port:">
                This is the UDP port that the downstream device uses when
                forwarding Relay-forward messages to this relay agent device.
                This UDP port is to be used by this relay agent device
                when forwarding the Relay-reply messages to that downstream device.
            </t>
            <t hangText="Non-DHCP UDP Port:">
                Any valid and non-zero UDP port other than port 67 for DHCPv4 and port
                547 for DHCPv6. 
            </t>
        </list>
        </t>
    </section>
    </section>    
    <section title="Changes to DHCP Specifications">

      <section title="Additions to DHCPv4 in RFC 2131">
        <t> Section 4.1 of RFC 2131 <xref target="RFC2131"/> specifies that:
        </t>
        <t>
            <list>
<!-- DNE -->
                <t>
            DHCP uses UDP as its transport protocol.  DHCP messages from
            a client to a server are sent to the 'DHCP server' port (67),
            and DHCP messages from a server to a client are sent to the
            'DHCP client' port (68).
                </t>
<!-- DNE end -->
            </list>
        </t>

        <t> 
            Relay agents implementing this specification may be configured instead
            to 1) use a source port number other than 67 when relaying messages toward
            servers and 2) receive responses toward clients on that same port.
            This will only work when the DHCP server or relay agent to which
            such a relay agent is forwarding messages is upgraded to support
            this extension.
      </t>

     </section>

      <section title="Additions to DHCPv6 in RFC 3315">
      <t> Section 5.2 of RFC 3315 <xref target="RFC3315"/> specifies that:
      </t>
      <t>
          <list>
<!-- DNE -->
              <t>
          Clients listen for DHCP messages on UDP port 546.  Servers
          and relay agents listen for DHCP messages on UDP port 547.
              </t>
<!-- DNE end -->
          </list>
      </t>

      <t> 
            Relay agents implementing this specification may be configured instead
            to 1) use a source port number other than 547 when relaying messages toward
            servers and 2) receive responses toward clients on that same port.
This will only work when the DHCP server or relay agent to which such a                            
relay agent is forwarding messages is upgraded to support this extension.  
      </t>

     </section>

    </section>

    <section title="Relay Source Port Sub-option and Option">

        <t> Relay agents do not maintain state. To return a message
            to its source, the relay agent must include all the required
            information in the Relay-forward message. When a relay in
            a sequence of cascaded relays does not use the standard
            source port, that source port must be included along with
            the source address. This option allows the relay agent to do so.
        </t>

    <section title="Source Port Sub-option for DHCPv4">

        <t>The relay agent "Source Port Sub-option" is a new option,
            and it is part of the
            "Relay Agent Information" option for DHCPv4
            <xref target="RFC3046"></xref>.
        </t>

        <t> The format of the "Source Port Sub-option"
            is shown below:
        </t>
<!-- [rfced] Throughout, please review the IANA updates and let us know if any
updates are needed.  For example:

Original:
      SubOpt Code:  SUBOPT_RELAY_PORT. 8 bit value, to be assigned by
               IANA.

Was updated to reflect the following:
   SubOpt Code:  SUBOPT_RELAY_PORT. 8-bit value, 135.
-->

        <figure align="center">
            <preamble></preamble>
            <artwork align="left"><![CDATA[
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         | SubOpt Code   |      Len      |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]></artwork>
         <postamble></postamble>
         </figure>
       <t>Where:</t>
           <t>
          <list style='hanging' hangIndent="9">
            <t hangText="SubOpt Code:">
                SUBOPT_RELAY_PORT. 8-bit value, 19.
            </t>
            <t hangText="Len:">
                8-bit value to be set to 0.
            </t>
          </list>
         </t>

    </section>

    <section title="Relay Source Port Option for DHCPv6">

        <t> The "Relay Source Port Option" is a new DHCPv6 option.
            It MUST be used by either 1) a DHCPv6 relay agent that uses
            a non-DHCP UDP port (not 547) communicating with the
            IPv6 server and
            the upstream relay agent or 2) an IPv6 relay agent that
            detects the use of a non-DHCP UDP port (not 547) by a
            downstream relay agent.
        </t>

        <t> The format of the "Relay Source Port Option"
            is shown below:
        </t>
        <figure align="center">
            <preamble></preamble>
            <artwork align="left"><![CDATA[
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |    OPTION_RELAY_PORT    |         Option-Len                  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |    Downstream Source Port     |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]></artwork>
         <postamble></postamble>
         </figure>
         <t>Where:</t>
          <t>
          <list style='hanging' hangIndent="3">
            <t hangText="Option-Code:">
                OPTION_RELAY_PORT. 16-bit value, 135.
            </t>
            <t hangText="Option-Len:">
                16-bit value to be set to 2.
            </t>
            <t hangText="Downstream Source Port:">
                16-bit value. To be set by the IPv6 relay either to
                the downstream relay agent's UDP source port used
                for the UDP packet, or to zero if only the local
                relay agent uses the non-DHCP UDP port (not 547).
            </t>
          </list>
          </t>

    </section>

    </section>

    <section title="Relay Agent and Server Behavior">
      <section title="DHCPv4">
          <t> When a relay agent uses a non-DHCP UDP port (not 67)
              to communicate with the DHCP server,
              it MUST include the "Source Port Sub-option"
               in Relay-forward messages to indicate that.
           </t>
           <t>
	   		When an IPv4 server receives a message from a relay agent
			with the "Source Port Sub-option", it MUST remember the
			UDP source port of the message and use that port number
			as the UDP destination port when sending the reply message
			to the same relay agent.
           </t>
      </section>
      <section title="DHCPv6">
        <t> The IPv6 relay agent MUST include the "Relay Source
            Port Option" when it uses a non-DHCP UDP port (not 547) to communicate
            to a DHCPv6 server or an upstream IPv6 relay agent.
            Also, when an IPv6 relay agent detects that a
            downstream relay agent uses a non-DHCP UDP port in the
            packet, it MUST record the port number in the "Downstream
            Source Port" field of this option. If this option is included to
	    indicate only the local non-DHCP UDP port usage and the port is
	    not being used by a downstream relay agent, the Downstream Source Port field MUST be set to zero. 
        </t>

        <t> The IPv6 relay agent MUST include this option in the
            following three cases:
            <list style="numbers">
                <t>The local relay agent uses a non-DHCP UDP port (not 547).
                </t>
                <t>The downstream relay agent uses a non-DHCP UDP port (not 547).
                </t>
                <t>The local relay agent and the downstream relay agent both use non-DHCP UDP ports (not 547).
                </t>
            </list>
        </t>
        <t>
            In the first case, the value of the
            "Downstream Source Port" field is set to zero.
            In the other two cases,
            the value of the field is set to the UDP port
            number that the  downstream relay agent uses.
        </t>
        <t> When an IPv6 server receives a Relay-forward message with
            the "Relay Source Port Option", it MUST copy the
            option when constructing the Relay-reply chain in response
            to the Relay-forward message. This option MUST NOT appear
            in any message other than a Relay-forward or Relay-reply
            message. Additionally, the IPv6 server MUST check and use the
            UDP source port from the UDP packet of the Relay-forward message
            in replying to the relay agent.
        </t>
        <t> When a relay agent receives a Relay-reply message with
            the "Relay Source Port Option" from a server or from an
            upstream relay agent,
            if the "Downstream Source Port" field in the option is non-zero,
            it MUST use this UDP port number to forward the Relay-reply message
            to the downstream relay agent.
        </t>
      </section>

      <section title="Compatibility" anchor="compatibility">
        	<t>
                Sites that need relay agents to specify a source port 
                need to install new DHCP server and DHCP relay agent software
                with this feature. If a site installs only DHCP relay agent
                software with this feature, there is no possibility that the
                DHCP server will be able to communicate to the relay agent.
        	</t>

      </section> 
      <section title="Deployment Considerations">

<t>During deployment, the operator and/or user of the new DHCP play port
implementation should upgrade the DHCP server before the relay implementations
are deployed. This would ensure that the erroneous case noted in
                <xref target="compatibility" /> is not encountered.
                If the upstream relay agent or server does not support this extension,
                this DHCP relay port feature needs to be disabled.
            </t> 
            <t> 
                When the DHCP relay port implementation is deployed, the default
                relay agent behavior should use the DHCP UDP port, and it is
                recommended that the configuration be set up to allow for the mode of
                operation where a non-DHCP port can be used for the DHCP relay agents.
      		</t>
        <t> If the network uses a firewall to block or allow
            DHCP packets with both static UDP source and
            destination port numbers, this may no longer match the
            packets from new DHCP relay agent and server software with
            this extension.
            The firewall rules need to be modified to match only
            the DHCP server side of the UDP port number and,
            if necessary, IP addresses and other attributes.
        </t>
      </section> 

    </section>

    <section title="Example of an IPv6-Cascaded Relay">
        <t>An example of IPv6-cascaded relay agents with the
            "Relay Source Port Option" is shown below.
        </t>
        <figure align="center">
            <preamble></preamble>
            <artwork align="left"><![CDATA[
           (forward)          (forward)          (forward)
   Relay1 ----------> Relay2 ----------> Relay3 ----------> Server
       (1000)              (547)              (547)
            (reply)            (reply)            (reply)
          <----------        <----------        <----------
            ]]></artwork>
         <postamble></postamble>
         </figure>
         <t> In the above diagram, all the IPv6 devices support
             this generalized UDP source port extension except for
             Relay3. Relay1 is the only relay agent device that uses a
             non-DHCP UDP port (not 547). Relay2 is the upstream device of Relay1.
        </t>
        <t> Both Relay1 and Relay2 include the "Relay Source
            Port Option" in the Relay-forward message. Relay1 sets the
            "Downstream Source Port" field in the option to zero.
            Relay2 notices that the "Relay Source Port Option" is
            included in the message from Relay1, and it determines that
            the UDP source
            port used by Relay1 is 1000. Relay2 will include the
            "Relay Source Port Option", and it
            sets the "Downstream Source Port" field
            in the option to 1000. The IPv6 server copies the
            "Relay Source Port Option" when replying with the
            Relay-reply message.
        </t>
        <t> When Relay2 receives the Relay-reply message with the
            "Relay Source Port Option", it finds that
            the "Downstream Source Port" field has the value of 1000.
            Relay2 then uses this port number in the UDP packet when
            sending the Relay-reply message to Relay1.
        </t>
        <t> When Relay1 receives the Relay-reply message with the
            "Relay Source Port Option", it finds that
            the "Downstream Source Port" field has the value of zero.
            Relay1 then uses the normal IPv6 port 547 in the packet sending
            the Relay-reply message to its downstream relay agent or 
            uses UDP port 546 to an IPv6 client.
        </t>
        <t> This DHCP extension works with any combination of IPv6-cascaded
            relay agents, as long as the relay agent that uses a non-DHCP
            UDP port (not 547) and its upstream relay device support this
            generalized UDP source port extension.
        </t>
        <t> Similar to the above example, but now assume that Relay2 uses the UDP
            source port of 2000 instead of 547 as in the diagram.
            The Relay3 device needs to support this DHCP extension and it will
            set 2000 in its "Downstream Source Port" field of the option in the
            Relay-forward message.
            When the DHCP server sends the DHCP Relay-reply to Relay3, Relay3
	    finds that its
            own relay option has this "Downstream Source Port" with the value of 2000.
            Relay3 will use this UDP port when sending the Relay-reply message
            to Relay2. Relay2 finds its own relay option also has this
            "Downstream Source Port" with the value of 1000. Relay2 will use this
            UDP port when sending the Relay-reply message to Relay1.
        </t>
    </section>

    <?rfc needLines="8" ?>

    <section anchor="IANA" title="IANA Considerations">
        <t> IANA has registered "DHCPv4 Relay Source Port
	Sub-option" (19) for the IPv4 "Relay Agent Information" option
            within the
"DHCP Relay Agent Sub-Option Codes" registry
&lt;https://www.iana.org/assignments/bootp-dhcp-parameters&gt; <xref target="RFC3046"/>.  
        </t>

        <t> IANA has registered "OPTION_RELAY_PORT" (135) for the DHCPv6 "Relay
	Source Port Option" within the DHCPv6 "Option Codes" registry 
            &lt;http://www.iana.org/assignments/dhcpv6-parameters"&gt;
	    <xref target="RFC3315"></xref>.
        </t>
        
    </section>
    
    <section anchor="Security" title="Security Considerations">

        <t> <xref target="RFC3118"></xref> and 
            <xref target="RFC3315"></xref> described many of the
            threats in using DHCP. This extension does not raise
            additional security issues.
        </t>
    </section>

  </middle>


  <back>

    <references title="Normative References">

      &RFC2131;

      &RFC2119;

      &RFC3046;

      &RFC3118;

      &RFC3315;
      
      &RFC8174;

    </references>

    <section anchor="Acknowledgments" title="Acknowledgments" numbered="no">
        <t> The authors would like to thank Peter Arberg,
            Luyuan Fang, Bhanu Gopalasetty, Scott Kelly,
            Andre Kostur, Victor Kuarsingh, Ted Lemon, Adam Roach,
            Kishore Seshadri, and Jackelyn Shen for their
            review and comments of this document.
      </t>
      <t> The authors would like to thank Bernie Volz for discussions
            that led to the definition of the "Relay Source Port
            Sub-option" and DHCPv6 "Relay Source Port Option".
      </t>
    </section>

  </back>
</rfc>
