Skip to content

Commit c868b3b

Browse files
congh-nvidianikamirrr
authored andcommitted
[DASH] Update the dash eni counter test to align with the latest PL test change (sonic-net#21196)
* Update the dash eni counter test to align with the latest PL test change * Update packets.py to fix pre-commit * Update test_dash_eni_counter.py to fix pre-commit --------- Co-authored-by: Nikolay Mirin <[email protected]>
1 parent 867891f commit c868b3b

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

tests/dash/packets.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def set_do_not_care_layer(mask, layer, field_name, n=1):
119119

120120

121121
def inbound_pl_packets(
122-
config, floating_nic=False, inner_packet_type="udp", vxlan_udp_dport=4789, inner_sport=4567, inner_dport=6789
122+
config, floating_nic=False, inner_packet_type="udp", vxlan_udp_dport=4789, inner_sport=4567, inner_dport=6789,
123+
vxlan_udp_base_src_port=VXLAN_UDP_BASE_SRC_PORT, vxlan_udp_src_port_mask=VXLAN_UDP_SRC_PORT_MASK
123124
):
124125
inner_sip = get_pl_overlay_dip( # not a typo, inner DIP/SIP are reversed for inbound direction
125126
pl.PE_CA, pl.PL_OVERLAY_DIP, pl.PL_OVERLAY_DIP_MASK
@@ -129,14 +130,16 @@ def inbound_pl_packets(
129130
pl.VM1_CA, pl.PL_OVERLAY_SIP, pl.PL_OVERLAY_SIP_MASK, pl.PL_ENCODING_IP, pl.PL_ENCODING_MASK
130131
)
131132

133+
l4_protocol_key = get_scapy_l4_protocol_key(inner_packet_type)
134+
132135
inner_packet = generate_inner_packet(inner_packet_type, ipv6=True)(
133136
eth_src=pl.REMOTE_MAC,
134137
eth_dst=pl.ENI_MAC,
135138
ipv6_src=inner_sip,
136139
ipv6_dst=inner_dip,
137-
udp_sport=inner_sport,
138-
udp_dport=inner_dport,
139140
)
141+
inner_packet[l4_protocol_key].sport = inner_sport
142+
inner_packet[l4_protocol_key].dport = inner_dport
140143

141144
gre_packet = testutils.simple_gre_packet(
142145
eth_dst=config[DUT_MAC],
@@ -166,7 +169,7 @@ def inbound_pl_packets(
166169
ip_ttl=254,
167170
ip_id=0,
168171
udp_dport=vxlan_udp_dport,
169-
udp_sport=VXLAN_UDP_BASE_SRC_PORT,
172+
udp_sport=vxlan_udp_base_src_port,
170173
vxlan_vni=pl.ENCAP_VNI if floating_nic else int(pl.VNET1_VNI),
171174
inner_frame=exp_inner_packet,
172175
)
@@ -175,7 +178,7 @@ def inbound_pl_packets(
175178
masked_exp_packet.set_do_not_care_packet(scapy.Ether, "src")
176179
masked_exp_packet.set_do_not_care_packet(scapy.Ether, "dst")
177180
masked_exp_packet.set_do_not_care_packet(scapy.UDP, "chksum")
178-
masked_exp_packet.set_do_not_care(8 * (34 + 2) - VXLAN_UDP_SRC_PORT_MASK, VXLAN_UDP_SRC_PORT_MASK)
181+
masked_exp_packet.set_do_not_care(8 * (34 + 2) - vxlan_udp_src_port_mask, vxlan_udp_src_port_mask)
179182
masked_exp_packet.set_do_not_care_packet(scapy.IP, "ttl")
180183
masked_exp_packet.set_do_not_care_packet(scapy.IP, "chksum")
181184
if floating_nic:
@@ -227,15 +230,17 @@ def outbound_pl_packets(
227230
vni=None
228231
):
229232
outer_vni = int(vni if vni else pl.VM_VNI)
233+
234+
l4_protocol_key = get_scapy_l4_protocol_key(inner_packet_type)
235+
230236
inner_packet = generate_inner_packet(inner_packet_type)(
231237
eth_src=pl.VM_MAC if floating_nic else pl.ENI_MAC,
232238
eth_dst=pl.ENI_MAC if floating_nic else pl.REMOTE_MAC,
233239
ip_src=pl.VM1_CA,
234240
ip_dst=pl.PE_CA,
235-
udp_sport=inner_sport,
236-
udp_dport=inner_dport,
237241
)
238-
l4_protocol_key = get_scapy_l4_protocol_key(inner_packet_type)
242+
inner_packet[l4_protocol_key].sport = inner_sport
243+
inner_packet[l4_protocol_key].dport = inner_dport
239244

240245
if outer_encap == "vxlan":
241246
outer_packet = testutils.simple_vxlan_packet(

tests/dash/test_dash_eni_counter.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
import ptf.testutils as testutils
77
import pytest
88
from constants import LOCAL_PTF_INTF, LOCAL_DUT_INTF, REMOTE_DUT_INTF, REMOTE_PTF_RECV_INTF, \
9-
REMOTE_PTF_SEND_INTF, VXLAN_UDP_BASE_SRC_PORT
9+
REMOTE_PTF_SEND_INTF
1010
from gnmi_utils import apply_messages
1111
from packets import outbound_pl_packets, inbound_pl_packets
12-
from tests.common import config_reload
1312
from tests.common.plugins.allure_wrapper import allure_step_wrapper as allure
1413
from tests.common.helpers.assertions import pytest_assert
1514
from tests.common.utilities import wait_until
@@ -51,7 +50,7 @@ def setup_npu_routes(duthost, dash_pl_config, skip_config, skip_cleanup, dpu_ind
5150

5251

5352
@pytest.fixture(autouse=True, scope="module")
54-
def common_setup_teardown(localhost, duthost, ptfhost, dpu_index, dpuhosts, skip_config, set_vxlan_udp_sport_range):
53+
def common_setup_teardown(localhost, duthost, ptfhost, dpu_index, dpuhosts, skip_config):
5554
if skip_config:
5655
return
5756
dpuhost = dpuhosts[dpu_index]
@@ -68,7 +67,7 @@ def common_setup_teardown(localhost, duthost, ptfhost, dpu_index, dpuhosts, skip
6867
apply_messages(localhost, duthost, ptfhost, base_config_messages, dpuhost.dpu_index)
6968

7069
route_and_mapping_messages = {
71-
**pl.PE1_VNET_MAPPING_CONFIG,
70+
**pl.PE_VNET_MAPPING_CONFIG,
7271
**pl.PE_SUBNET_ROUTE_CONFIG,
7372
**pl.VM_SUBNET_ROUTE_CONFIG
7473
}
@@ -95,9 +94,6 @@ def common_setup_teardown(localhost, duthost, ptfhost, dpu_index, dpuhosts, skip
9594
apply_messages(localhost, duthost, ptfhost, route_and_mapping_messages, dpuhost.dpu_index, False)
9695
apply_messages(localhost, duthost, ptfhost, base_config_messages, dpuhost.dpu_index, False)
9796

98-
if str(VXLAN_UDP_BASE_SRC_PORT) in dpuhost.shell("redis-cli -n 0 hget SWITCH_TABLE:switch vxlan_sport")['stdout']:
99-
config_reload(dpuhost, safe_reload=True)
100-
10197

10298
@pytest.fixture(scope="function", params=["vxlan", "gre"])
10399
def outer_encap(request):
@@ -239,7 +235,8 @@ def test_inbound_pkt_eni_counter(
239235
packet_number = 1
240236

241237
vm_to_dpu_pkt, _ = outbound_pl_packets(dash_pl_config, outer_encap, inner_packet_type=inner_packet_type)
242-
pe_to_dpu_pkt, exp_dpu_to_vm_pkt = inbound_pl_packets(dash_pl_config, inner_packet_type=inner_packet_type)
238+
pe_to_dpu_pkt, exp_dpu_to_vm_pkt = inbound_pl_packets(
239+
dash_pl_config, inner_packet_type=inner_packet_type, vxlan_udp_src_port_mask=16)
243240

244241
with allure.step("send outbound and inbound packet and verify the relevant eni counter"):
245242
eni_counter_check_point_dict = {"SAI_ENI_STAT_FLOW_CREATED": 1,

0 commit comments

Comments
 (0)