Skip to content

Commit

Permalink
fix everflow policer test for egress mirroring test
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
Stepan Blyschak committed Oct 15, 2019
1 parent c91d113 commit 620a2a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
23 changes: 19 additions & 4 deletions ansible/roles/test/files/acstests/everflow_policer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def setUp(self):
self.hwsku = self.test_params['hwsku']
self.asic_type = self.test_params['asic_type']
self.router_mac = self.test_params['router_mac']
self.mirror_stage = self.test_params['mirror_stage']
self.session_src_ip = "1.1.1.1"
self.session_dst_ip = "2.2.2.2"
self.session_ttl = 1
Expand Down Expand Up @@ -106,7 +107,15 @@ def checkMirroredFlow(self):
Mellanox crafts the GRE packets with extra information:
That is: 22 bytes extra information after the GRE header
"""
payload = self.base_pkt
payload = self.base_pkt.copy()
payload_mask = Mask(payload)

if self.mirror_stage == "egress":
payload['Ethernet'].src = self.router_mac
payload['IP'].ttl -= 1
payload_mask.set_do_not_care_scapy(scapy.Ether, "dst")
payload_mask.set_do_not_care_scapy(scapy.IP, "chksum")

if self.asic_type in ["mellanox"]:
import binascii
payload = binascii.unhexlify("0"*44) + str(payload) # Add the padding
Expand All @@ -130,17 +139,23 @@ def checkMirroredFlow(self):
masked_exp_pkt.set_do_not_care_scapy(scapy.Ether, "dst")
masked_exp_pkt.set_do_not_care_scapy(scapy.IP, "flags")
masked_exp_pkt.set_do_not_care_scapy(scapy.IP, "chksum")
masked_exp_pkt.set_do_not_care(38*8, len(payload)*8) # don't match payload, payload will be matched be seperate routine

if self.asic_type in ["mellanox"]:
masked_exp_pkt.set_do_not_care(304, 176) # Mask the Mellanox specific inner header
def match_payload(pkt):
pkt = scapy.Ether(pkt).load
if self.asic_type in ["mellanox"]:
pkt = pkt[22:] # Mask the Mellanox specific inner header
pkt = scapy.Ether(pkt)

return dataplane.match_exp_pkt(payload_mask, pkt)

self.dataplane.flush()

count = 0
for i in range(0,self.NUM_OF_TOTAL_PACKETS):
testutils.send_packet(self, self.src_port, self.base_pkt)
(rcv_device, rcv_port, rcv_pkt, pkt_time) = testutils.dp_poll(self, timeout=0.1, exp_pkt=masked_exp_pkt)
if rcv_pkt is not None:
if rcv_pkt is not None and match_payload(rcv_pkt):
count += 1
elif count == 0:
print "The first mirrored packet is not recieved"
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/test/tasks/everflow_testbed/testcase_5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- src_port='{{src_port_ptf_id}}'
- dst_ports='{{",".join((spine_ptf_ports))}}'
- dst_mirror_ports='{{dst_port_1_ptf_id}}'
- mirror_stage='{{ mirror_stage }}'
ptf_extra_options: "--relax --debug info"

always:
Expand Down

0 comments on commit 620a2a3

Please sign in to comment.