aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Hrnciar <phrnciar@cisco.com>2016-07-28 15:22:50 +0200
committerJan Gelety <jgelety@cisco.com>2016-08-25 14:51:32 +0000
commit53ce7d17816de6516f3c21bd01835b8c1c474c79 (patch)
tree67bb0b4d8e39251f657dbff7567f9958631252f9
parent874fe8911a88bc813592f70c8b777f49db0a652c (diff)
CSIT-31 DHCPv6 Proxy test
Change-Id: Ie06980f6e42af3676d8f1ee42c9b9733428365af Signed-off-by: Patrik Hrnciar <phrnciar@cisco.com>
-rw-r--r--resources/libraries/robot/dhcp_proxy.robot44
-rwxr-xr-xresources/traffic_scripts/dhcp/send_dhcp_v6_messages.py330
-rw-r--r--tests/func/dhcp/dhcp_v6_proxy.robot68
3 files changed, 441 insertions, 1 deletions
diff --git a/resources/libraries/robot/dhcp_proxy.robot b/resources/libraries/robot/dhcp_proxy.robot
index 0045349ad5..b6948dc384 100644
--- a/resources/libraries/robot/dhcp_proxy.robot
+++ b/resources/libraries/robot/dhcp_proxy.robot
@@ -114,4 +114,46 @@
| | ... | --tx_dst_ip | ${tx_dst_ip}
| | Run Keyword And Expect Error | DHCP DISCOVER Rx timeout
| | ... | Run Traffic Script On Node | dhcp/send_and_check_proxy_discover.py
-| | ... | ${tg_node} | ${args} \ No newline at end of file
+| | ... | ${tg_node} | ${args}
+
+| Send DHCPv6 Messages
+| | [Documentation] | Send and receive DHCPv6 messages between client
+| | ... | and server through DHCPv6 proxy.
+| | ...
+| | ... | *Arguments:*
+| | ... | - tg_node - TG node. Type: dictionary
+| | ... | - tg_interface1 - TG interface. Type: string
+| | ... | - tg_interface2 - TG interface. Type: string
+| | ... | - proxy_ip - DHCPv6 proxy IP address. Type: string
+| | ... | - proxy_mac - Proxy MAC address. Type: string
+| | ... | - server_ip - DHCPv6 server IP address. Type: string
+| | ... | - server_mac - Server MAC address. Type: string
+| | ... | - client_mac - Client MAC address. Type: string
+| | ... | - proxy_to_server_mac - MAC address of proxy interface
+| | ... | connected to server. Type: string
+| | ...
+| | ... | *Return:*
+| | ... | - No value returned.
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Send DHCPv6 Messages \| ${nodes['TG']} \
+| | ... | \| eth3 \| eth4 \| 3ffe:62::1 \| 08:00:27:54:59:f9 \
+| | ... | \| 3ffe:63::2 \| 08:00:27:cc:4f:54 \|
+| | ... | \| 08:00:27:64:18:d2 \| 08:00:27:c9:6a:d5 \|
+| | ...
+| | [Arguments] | ${tg_node} | ${tg_interface1} | ${tg_interface2} | ${proxy_ip}
+| | ... | ${proxy_mac} | ${server_ip} | ${server_mac} | ${client_mac}
+| | ... | ${proxy_to_server_mac}
+| | ${tg_interface_name1}= | Get interface name | ${tg_node} | ${tg_interface1}
+| | ${tg_interface_name2}= | Get interface name | ${tg_node} | ${tg_interface2}
+| | ${args}= | Catenate | --tx_if | ${tg_interface_name1}
+| | ... | --rx_if | ${tg_interface_name2}
+| | ... | --proxy_ip | ${proxy_ip}
+| | ... | --proxy_mac | ${proxy_mac}
+| | ... | --server_ip | ${server_ip}
+| | ... | --server_mac | ${server_mac}
+| | ... | --client_mac | ${client_mac}
+| | ... | --proxy_to_server_mac | ${proxy_to_server_mac}
+| | Run Traffic Script On Node | dhcp/send_dhcp_v6_messages.py
+| | ... | ${tg_node} | ${args}
diff --git a/resources/traffic_scripts/dhcp/send_dhcp_v6_messages.py b/resources/traffic_scripts/dhcp/send_dhcp_v6_messages.py
new file mode 100755
index 0000000000..d570a8c8aa
--- /dev/null
+++ b/resources/traffic_scripts/dhcp/send_dhcp_v6_messages.py
@@ -0,0 +1,330 @@
+#!/usr/bin/env python
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Traffic script that sends DHCPv6 proxy packets."""
+
+from scapy.layers.dhcp6 import *
+from scapy.layers.inet6 import IPv6, UDP, UDP_SERVICES
+
+from resources.libraries.python.PacketVerifier import RxQueue, TxQueue
+from resources.libraries.python.TrafficScriptArg import TrafficScriptArg
+
+
+def _check_udp_checksum(pkt):
+ """Check udp checksum in ip packet.
+ Return true if checksum is correct."""
+ new = pkt.__class__(str(pkt))
+ del new['UDP'].chksum
+ new = new.__class__(str(new))
+ return new['UDP'].chksum == pkt['UDP'].chksum
+
+
+def dhcpv6_solicit(tx_if, rx_if, dhcp_multicast_ip, link_local_ip, proxy_ip,
+ server_ip, server_mac, client_duid, client_mac):
+ """Send and check DHCPv6 SOLICIT proxy packet.
+
+ :param tx_if: Client interface.
+ :param rx_if: DHCPv6 server interface.
+ :param dhcp_multicast_ip: Servers and relay agents multicast address.
+ :param link_local_ip: Client link-local address.
+ :param proxy_ip: IP address of DHCPv6 proxy server.
+ :param server_ip: IP address of DHCPv6 server.
+ :param server_mac: MAC address of DHCPv6 server.
+ :param client_duid: Client DHCP Unique Identifier.
+ :param client_mac: Client MAC address.
+ :type tx_if: str
+ :type rx_if: str
+ :type dhcp_multicast_ip: str
+ :type link_local_ip: str
+ :type proxy_ip: str
+ :type server_ip: str
+ :type server_mac: str
+ :type client_duid: str
+ :type client_mac: str
+ :return interface_id: ID of proxy interface.
+ :rtype interface_id: str
+ """
+
+ rxq = RxQueue(rx_if)
+ txq = TxQueue(tx_if)
+
+ sent_packets = []
+
+ dhcp6_solicit_pkt = Ether(src=client_mac, dst="33:33:00:01:00:02") / \
+ IPv6(src=link_local_ip, dst=dhcp_multicast_ip) / \
+ UDP(sport=UDP_SERVICES.dhcpv6_client,
+ dport=UDP_SERVICES.dhcpv6_server) / \
+ DHCP6_Solicit() / \
+ DHCP6OptClientId(duid=client_duid)
+
+ sent_packets.append(dhcp6_solicit_pkt)
+ txq.send(dhcp6_solicit_pkt)
+
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError('DHCPv6 SOLICIT timeout')
+
+ if ether.dst != server_mac:
+ raise RuntimeError("Destination MAC address error!")
+ print "Destination MAC address: OK."
+
+ if ether['IPv6'].src != proxy_ip:
+ raise RuntimeError("Source IP address error!")
+ print "Source IP address: OK."
+
+ if ether['IPv6'].dst != server_ip:
+ raise RuntimeError("Destination IP address error!")
+ print "Destination IP address: OK."
+
+ if ether['IPv6']['UDP']\
+ ['DHCPv6 Relay Forward Message (Relay Agent/Server Message)']:
+ print "Relay Agent/Server Message: OK."
+ else:
+ raise RuntimeError("Relay Agent/Server Message error.")
+
+ if ether['IPv6']['UDP']\
+ ['DHCPv6 Relay Forward Message (Relay Agent/Server Message)']\
+ .linkaddr != proxy_ip:
+ raise RuntimeError("Proxy IP address error!")
+ print "Proxy IP address: OK."
+
+ try:
+ interface_id = ether['IPv6']['UDP']\
+ ['DHCPv6 Relay Forward Message (Relay Agent/Server Message)']\
+ ['Unknown DHCPv6 OPtion']['DHCP6 Interface-Id Option'].ifaceid
+ except Exception:
+ raise RuntimeError("DHCP6 Interface-Id error!")
+
+ return interface_id
+
+
+def dhcpv6_advertise(rx_if, tx_if, link_local_ip, proxy_ip,
+ server_ip, server_mac, proxy_to_server_mac, interface_id):
+ """Send and check DHCPv6 ADVERTISE proxy packet.
+
+ :param rx_if: DHCPv6 server interface.
+ :param tx_if: Client interface.
+ :param link_local_ip: Client link-local address.
+ :param proxy_ip: IP address of DHCPv6 proxy server.
+ :param server_ip: IP address of DHCPv6 server.
+ :param server_mac: MAC address of DHCPv6 server.
+ :param proxy_to_server_mac: MAC address of DHCPv6 proxy interface.
+ :param interface_id: ID of proxy interface.
+ :type rx_if: str
+ :type tx_if: str
+ :type link_local_ip: str
+ :type proxy_ip: str
+ :type server_ip: str
+ :type server_mac: str
+ :type proxy_to_server_mac: str
+ :type interface_id: str
+ """
+
+ rxq = RxQueue(rx_if)
+ txq = TxQueue(tx_if)
+
+ sent_packets = []
+
+ dhcp6_advertise_pkt = Ether(src=server_mac, dst=proxy_to_server_mac) / \
+ IPv6(src=server_ip, dst=proxy_ip) / \
+ UDP(sport=UDP_SERVICES.dhcpv6_server,
+ dport=UDP_SERVICES.dhcpv6_client) / \
+ DHCP6_RelayReply(peeraddr=link_local_ip,
+ linkaddr=proxy_ip) / \
+ DHCP6OptIfaceId(ifaceid=interface_id) / \
+ DHCP6OptRelayMsg() / \
+ DHCP6_Advertise()
+
+ sent_packets.append(dhcp6_advertise_pkt)
+ txq.send(dhcp6_advertise_pkt)
+
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError('DHCPv6 ADVERTISE timeout')
+
+ if ether['IPv6'].src != proxy_ip:
+ raise RuntimeError("Source IP address error!")
+ print "Source IP address: OK."
+
+ if not _check_udp_checksum(ether['IPv6']):
+ raise RuntimeError("Checksum error!")
+ print "Checksum: OK."
+
+ if ether['IPv6']['UDP']['Raw'].load != interface_id:
+ raise RuntimeError("Interface ID error!")
+ print "Interface ID: OK."
+
+
+def dhcpv6_request(tx_if, rx_if, dhcp_multicast_ip, link_local_ip, proxy_ip,
+ server_ip, client_duid, client_mac):
+ """Send and check DHCPv6 REQUEST proxy packet.
+
+ :param tx_if: Client interface.
+ :param rx_if: DHCPv6 server interface.
+ :param dhcp_multicast_ip: Servers and relay agents multicast address.
+ :param link_local_ip: Client link-local address.
+ :param proxy_ip: IP address of DHCPv6 proxy server.
+ :param server_ip: IP address of DHCPv6 server.
+ :param client_duid: Client DHCP Unique Identifier.
+ :param client_mac: Client MAC address.
+ :type tx_if: str
+ :type rx_if: str
+ :type dhcp_multicast_ip: str
+ :type link_local_ip: str
+ :type proxy_ip: str
+ :type server_ip: str
+ :type client_duid: str
+ :type client_mac: str
+ """
+
+ rxq = RxQueue(rx_if)
+ txq = TxQueue(tx_if)
+
+ sent_packets = []
+
+ dhcp6_request_pkt = Ether(src=client_mac, dst="33:33:00:01:00:02") / \
+ IPv6(src=link_local_ip, dst=dhcp_multicast_ip) / \
+ UDP(sport=UDP_SERVICES.dhcpv6_client,
+ dport=UDP_SERVICES.dhcpv6_server) / \
+ DHCP6_Request() / \
+ DHCP6OptClientId(duid=client_duid)
+
+ sent_packets.append(dhcp6_request_pkt)
+ txq.send(dhcp6_request_pkt)
+
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError('DHCPv6 REQUEST timeout')
+
+ if ether['IPv6'].src != proxy_ip:
+ raise RuntimeError("Source IP address error!")
+ print "Source IP address: OK."
+
+ if ether['IPv6'].dst != server_ip:
+ raise RuntimeError("Destination IP address error!")
+ print "Destination IP address: OK."
+
+ if ether['IPv6']['UDP']\
+ ['DHCPv6 Relay Forward Message (Relay Agent/Server Message)']:
+ print "Relay Agent/Server Message: OK."
+ else:
+ raise RuntimeError("Relay Agent/Server Message error.")
+
+ if ether['IPv6']['UDP']\
+ ['DHCPv6 Relay Forward Message (Relay Agent/Server Message)']\
+ .linkaddr != proxy_ip:
+ raise RuntimeError("Proxy IP address error!")
+ print "Proxy IP address: OK."
+
+
+def dhcpv6_reply(rx_if, tx_if, link_local_ip, proxy_ip, server_ip, server_mac,
+ interface_id):
+ """Send and check DHCPv6 REPLY proxy packet.
+
+ :param rx_if: DHCPv6 server interface.
+ :param tx_if: Client interface.
+ :param link_local_ip: Client link-local address.
+ :param proxy_ip: IP address of DHCPv6 proxy server.
+ :param server_ip: IP address of DHCPv6 server.
+ :param server_mac: MAC address of DHCPv6 server.
+ :param interface_id: ID of proxy interface.
+ :type rx_if: str
+ :type tx_if: str
+ :type link_local_ip: str
+ :type proxy_ip: str
+ :type server_ip: str
+ :type server_mac: str
+ :type interface_id: str
+ """
+
+ rxq = RxQueue(rx_if)
+ txq = TxQueue(tx_if)
+
+ sent_packets = []
+
+ dhcp_reply_pkt = Ether(src=server_mac) / \
+ IPv6(src=server_ip, dst=proxy_ip) / \
+ UDP(sport=UDP_SERVICES.dhcpv6_server,
+ dport=UDP_SERVICES.dhcpv6_client) / \
+ DHCP6_RelayReply(peeraddr=link_local_ip,
+ linkaddr=proxy_ip) / \
+ DHCP6OptIfaceId(ifaceid=interface_id) / \
+ DHCP6OptRelayMsg() / \
+ DHCP6_Reply()
+
+ sent_packets.append(dhcp_reply_pkt)
+ txq.send(dhcp_reply_pkt)
+
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError('DHCPv6 REPLY timeout')
+
+ if ether['IPv6'].src != proxy_ip:
+ raise RuntimeError("Source IP address error!")
+ print "Source IP address: OK."
+
+ if not _check_udp_checksum(ether['IPv6']):
+ raise RuntimeError("Checksum error!")
+ print "Checksum: OK."
+
+ if ether['IPv6']['UDP']['Raw'].load != interface_id:
+ raise RuntimeError("Interface ID error!")
+ print "Interface ID: OK."
+
+
+def main():
+ """Send DHCPv6 proxy messages."""
+
+ args = TrafficScriptArg(['tx_src_ip', 'tx_dst_ip', 'proxy_ip', 'proxy_mac',
+ 'server_ip', 'client_mac', 'server_mac',
+ 'proxy_to_server_mac'])
+
+ client_if = args.get_arg('tx_if')
+ server_if = args.get_arg('rx_if')
+ proxy_ip = args.get_arg('proxy_ip')
+ proxy_mac = args.get_arg('proxy_mac')
+ proxy_to_server_mac = args.get_arg('proxy_to_server_mac')
+ server_ip = args.get_arg('server_ip')
+ client_mac = args.get_arg('client_mac')
+ server_mac = args.get_arg('server_mac')
+
+ link_local_ip = "fe80::1"
+ dhcp_multicast_ip = "ff02::1:2"
+ client_duid = str(random.randint(0, 9999))
+
+ # SOLICIT
+ interface_id = dhcpv6_solicit(client_if, server_if, dhcp_multicast_ip,
+ link_local_ip, proxy_ip, server_ip,
+ server_mac, client_duid, client_mac)
+
+ # ADVERTISE
+ dhcpv6_advertise(client_if, server_if, link_local_ip, proxy_ip,
+ server_ip, server_mac, proxy_to_server_mac, interface_id)
+
+ # REQUEST
+ dhcpv6_request(client_if, server_if, dhcp_multicast_ip, link_local_ip,
+ proxy_ip, server_ip, client_duid, client_mac)
+
+ # REPLY
+ dhcpv6_reply(client_if, server_if, link_local_ip, proxy_ip, server_ip,
+ server_mac, interface_id)
+
+ sys.exit(0)
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/func/dhcp/dhcp_v6_proxy.robot b/tests/func/dhcp/dhcp_v6_proxy.robot
new file mode 100644
index 0000000000..6df638241c
--- /dev/null
+++ b/tests/func/dhcp/dhcp_v6_proxy.robot
@@ -0,0 +1,68 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+| Resource | resources/libraries/robot/default.robot
+| Resource | resources/libraries/robot/testing_path.robot
+| Resource | resources/libraries/robot/dhcp_proxy.robot
+| Resource | resources/libraries/robot/ipv6.robot
+| Library | resources.libraries.python.Trace
+| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
+| Test Setup | Run Keywords | Setup all DUTs before test
+| ... | AND | Setup all TGs before traffic script
+| Test Teardown | Run Keywords | Show Packet Trace on All DUTs | ${nodes}
+| ... | AND | Show vpp trace dump on all DUTs
+| Documentation | *DHCPv6 proxy test cases*
+| ...
+| ... | *[Top] Network Topologies:* TG = DUT
+| ... | with two links between the nodes.
+| ... | *[Cfg] DUT configuration:* DUT is configured with DHCP proxy.
+| ... | *[Ver] TG verification:*Test DHCP packets are sent
+| ... | on TG on first link to DUT and received on TG on second link.
+| ... | On receive TG verifies if DHCP packets are valid
+| ... | *[Ref] Applicable standard specifications:* RFC 3315
+
+
+*** Variables ***
+| ${dut_to_tg_if1_ip}= | 3ffe:62::1
+| ${dut_to_tg_if2_ip}= | 3ffe:63::1
+| ${dhcp_server_ip}= | 3ffe:63::2
+| ${prefix_length}= | 64
+
+
+*** Test Cases ***
+| TC01: VPP proxies valid DHCPv6 request to DHCPv6 server
+| | [Documentation] |
+| | ... | [Top] TG=DUT
+| | ... | [Cfg] On DUT setup DHCP proxy.
+| | ... | [Ver] Make TG verify matching DHCPv6 packets between client and DHCP \
+| | ... | server through DHCP proxy.
+| | ... | [Ref] RFC 3315
+| | ...
+| | Given Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | And Interfaces in 2-node path are up
+| | And Vpp Set If Ipv6 Addr | ${dut_node}
+| | ... | ${dut_to_tg_if1} | ${dut_to_tg_if1_ip} | ${prefix_length}
+| | And Vpp Set If Ipv6 Addr | ${dut_node}
+| | ... | ${dut_to_tg_if2} | ${dut_to_tg_if2_ip} | ${prefix_length}
+| | And VPP Route Add | ${dut_node} | ff02::1:2 | 128 | ${NONE} | local
+| | ... | ${FALSE} | ${NONE}
+| | And Add IP Neighbor | ${dut_node} | ${dut_to_tg_if2} | ${dhcp_server_ip}
+| | ... | ${tg_to_dut_if2_mac}
+| | And Vpp All Ra Suppress Link Layer | ${nodes}
+| | When DHCP Proxy Config | ${dut_node} | ${dhcp_server_ip}
+| | ... | ${dut_to_tg_if1_ip}
+| | Then Send DHCPv6 Messages | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
+| | ... | ${dut_to_tg_if1_ip} | ${dut_to_tg_if1_mac} | ${dhcp_server_ip}
+| | ... | ${tg_to_dut_if2_mac} | ${tg_to_dut_if1_mac} | ${dut_to_tg_if2_mac}