Skip to content

Commit 0eef697

Browse files
authored
Add DHCP IP2ME copp test (#5111)
1 parent e0bc49b commit 0eef697

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

ansible/roles/test/files/ptftests/copp_tests.py

+73
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# ARPTest
88
# DHCPTest
99
# DHCPTopoT1Test
10+
# DHCPIP2METest
11+
# DHCPOTHERIPTest
1012
# DHCP6Test
1113
# LLDPTest
1214
# BGPTest
@@ -55,6 +57,7 @@ def __init__(self):
5557

5658
self.myip = test_params.get('myip', None)
5759
self.peerip = test_params.get('peerip', None)
60+
self.randip = test_params.get('randip', None)
5861
self.default_server_send_rate_limit_pps = test_params.get('send_rate_limit', 2000)
5962

6063
self.needPreSend = None
@@ -353,6 +356,76 @@ def contruct_packet(self, port_number):
353356

354357
return packet
355358

359+
class DHCPIP2METest(NoPolicyTest):
360+
def __init__(self):
361+
NoPolicyTest.__init__(self)
362+
363+
def runTest(self):
364+
self.log("DHCPIP2METest")
365+
self.run_suite()
366+
367+
def contruct_packet(self, port_number):
368+
src_mac = self.my_mac[port_number]
369+
dst_mac = self.peer_mac[port_number]
370+
dst_ip = self.peerip
371+
372+
packet = testutils.simple_udp_packet(
373+
pktlen=100,
374+
eth_src=src_mac,
375+
eth_dst=dst_mac,
376+
dl_vlan_enable=False,
377+
vlan_vid=0,
378+
vlan_pcp=0,
379+
dl_vlan_cfi=0,
380+
ip_src='0.0.0.0',
381+
ip_dst=dst_ip,
382+
ip_tos=0,
383+
ip_ttl=64,
384+
udp_sport=68,
385+
udp_dport=67,
386+
ip_ihl=None,
387+
ip_options=False,
388+
with_udp_chksum=True
389+
)
390+
391+
return packet
392+
393+
class DHCPOTHERIPTest(PolicyTest):
394+
def __init__(self):
395+
PolicyTest.__init__(self)
396+
# Police rate is expected to be 0
397+
self.PPS_LIMIT_MIN = 0
398+
self.PPS_LIMIT_MAX = 0
399+
400+
def runTest(self):
401+
self.log("DHCPOTHERIPTest")
402+
self.run_suite()
403+
404+
def contruct_packet(self, port_number):
405+
src_mac = self.my_mac[port_number]
406+
dst_mac = self.peer_mac[port_number]
407+
408+
packet = testutils.simple_udp_packet(
409+
pktlen=100,
410+
eth_dst=dst_mac,
411+
eth_src=src_mac,
412+
dl_vlan_enable=False,
413+
vlan_vid=0,
414+
vlan_pcp=0,
415+
dl_vlan_cfi=0,
416+
ip_src='0.0.0.0',
417+
ip_dst=self.randip,
418+
ip_tos=0,
419+
ip_ttl=64,
420+
udp_sport=68,
421+
udp_dport=67,
422+
ip_ihl=None,
423+
ip_options=False,
424+
with_udp_chksum=True
425+
)
426+
427+
return packet
428+
356429

357430
# SONIC configuration has no policer limiting for DHCPv6
358431
class DHCP6Test(NoPolicyTest):

tests/copp/test_copp.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from tests.ptf_runner import ptf_runner
3131
from tests.common import config_reload, constants
3232
from tests.common.system_utils import docker
33+
from tests.common.helpers.generators import generate_ip_through_default_route
3334
from tests.common.reboot import reboot
3435
from tests.common.utilities import skip_release
3536
from tests.common.utilities import wait_until
@@ -73,7 +74,8 @@ class TestCOPP(object):
7374
@pytest.mark.parametrize("protocol", ["ARP",
7475
"IP2ME",
7576
"SNMP",
76-
"SSH"])
77+
"SSH",
78+
"DHCPOTHERIP"])
7779
def test_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, copp_testbed, dut_type):
7880
"""
7981
Validates that rate-limited COPP groups work as expected.
@@ -90,6 +92,7 @@ def test_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_host
9092

9193
@pytest.mark.parametrize("protocol", ["BGP",
9294
"DHCP",
95+
"DHCPIP2ME",
9396
"DHCP6",
9497
"LACP",
9598
"LLDP",
@@ -264,6 +267,7 @@ def _copp_runner(dut, ptf, protocol, test_params, dut_type, has_trap=True):
264267
"target_port": test_params.nn_target_port,
265268
"myip": test_params.myip,
266269
"peerip": test_params.peerip,
270+
"randip": generate_ip_through_default_route(duthost, [test_params.peerip]),
267271
"send_rate_limit": test_params.send_rate_limit,
268272
"has_trap": has_trap}
269273

0 commit comments

Comments
 (0)