Skip to content

DHCP Relay Agent Test Plan

Joe LeVeque edited this page Nov 15, 2017 · 26 revisions

Overview

This test is aimed at confirming proper operation of certain features of the isc-dhcp-relay implementation. We must ensure the basic objective the DHCP relay agent is met. This involves validating that DHCP discover, offer, request, and ack packets are successfully relayed from client to server(s). We must also insure that features such as the proper attachment of an Option 82 field are supported by this agent.

PTF Test

  • Basic DHCP packet construction functions have been added to p4/ptf/testutils (DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, DHCPACK)
  • PTF test simulates a DHCP client acquiring a lease
    • We simulate a DHCP client (a server under the ToR) booting up by manually creating DHCP packets and sending them on an interface that is part of the ToR's VLAN.
  1. Create a DHCPDISCOVER packet and send it to the ToR on an interface that is part of the ToR's VLAN. The DHCP relay should receive this packet, add and Option 82 header and forward the packet to all known DHCP servers via it's uplinks.
  2. Listen to all packets on the ToR's uplinks and count the number of forwarded DHCPDISCOVER packets to ensure one is sent to every known DHCP server.
  3. Create a DHCPOFFER packet and send it to the ToR via one of its uplinks. The DHCP relay should forward this packet to the "client" on its VLAN
  4. Listen for the DHCPOFFER on the "client's" interface to ensure it would be received
  5. Create a DHCPREQUEST packet and send it to the ToR on an interface that is part of the ToR's VLAN. The DHCP relay should receive this packet, add and Option 82 header and forward the packet to all known DHCP servers via it's uplinks.
  6. Listen to all packets on the ToR's uplinks and count the number of forwarded DHCPREQUEST packets to ensure one is sent to every known DHCP server.
  7. Create a DHCPACK packet and send it to the ToR via one of its uplinks. The DHCP relay should forward this packet to the "client" on its VLAN
  8. Listen for the DHCPACK on the "client's" interface to ensure it would be received

Related Files

  • sonic-mgmt/ansible/roles/test/files/ptftests/dhcp_relay_test.py
    • Main PTF testing script
  • sonic-mgmt/ansible/roles/test/tasks/dhcp_relay.yml
    • Ansible playbook for deploying/running test on switch
  • sonic-mgmt/ansible/roles/sonic-common/templates/dhcp_relay.yml.j2
    • Jinja2 template used to dynamically populate DHCP server IP addresses into sonic-mgmt/ansible/roles/test/tasks/dhcp_relay.yml.

DHCP servers should be defined in the device's minigraph file as a sub-object of each VLAN interface, using the <DhcpRelays> tag, in a semicolon-delimited list similar to the following:

<VlanInterfaces>
        <VlanInterface>
          <Name>Vlan1000</Name>
          <AttachTo>fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24</AttachTo>
          <NoDhcpRelay>False</NoDhcpRelay>
          <StaticDHCPRelay>0.0.0.0/0</StaticDHCPRelay>
          <Type i:nil="true"/>
          <DhcpRelays>192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4</DhcpRelays>
          <VlanID>1000</VlanID>
          <Tag>1000</Tag>
          <Subnets>192.168.0.0/27</Subnets>
        </VlanInterface>
      </VlanInterfaces>

The number of DHCP servers you define is up to you and your testing requirements.

How to Run Test

$ ansible-playbook test_sonic.yml -i str --limit <switch_running_relay_agent> --become --tags dhcp_relay --extra-vars "ptf_host=<IP_address_of_PTF_container>"
Clone this wiki locally