From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7856E45A3B; Thu, 26 Sep 2024 20:18:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26FAA40DDB; Thu, 26 Sep 2024 20:18:37 +0200 (CEST) Received: from mail-io1-f103.google.com (mail-io1-f103.google.com [209.85.166.103]) by mails.dpdk.org (Postfix) with ESMTP id 5502740DD3 for ; Thu, 26 Sep 2024 20:18:32 +0200 (CEST) Received: by mail-io1-f103.google.com with SMTP id ca18e2360f4ac-82aa3f65864so56184539f.2 for ; Thu, 26 Sep 2024 11:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1727374711; x=1727979511; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PlNN/ehHBx0EB4m/2pAKJLbZeaChnxh801e9dXGmEtY=; b=V6l7bHzA5R9Byy16fqFLk5SjdIhcOmT8EzE8+wnvSPjQWRT3oAXAL+W2sC9g3Zx+Jm jGxSN3TXCiOm10UatU/q0zFm81FYU/9xp3pLsi3r91NJRLyfRP1D9eKEnJloeQCRilal cqZ7Y6TEORVPIjdWdbOb8+N83wO6qMXI9UZx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727374711; x=1727979511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlNN/ehHBx0EB4m/2pAKJLbZeaChnxh801e9dXGmEtY=; b=kxmvjaxiG3o869QVAQDNNrPWR1QhqQ56+HMTdi9UlAdyxyl8G6rdDMCZpJYKN+bUH0 8zQXM3aCvhXJeZ47xpy3ePxBv+mT4mYc01hJB5rThvplMs9yByjnf3b+csDq0R7vdOOK vIe/VprrRuUvJfv4WqGF5QTtZCmaOP5jQAMfKZNVTgTwkbMDggSZJ2tFi/j5Vp52SYC6 T7NDeUeB4Svq+KbtiMjj2ZuJurx04P2g3/59rcVr3XIOJj6KGHaqptmPtLjp3Tc3xKOD qdwTW5pyQ4rouVslQKUmIMxKFpu9G0EEgAIXXjL8xSMDzPm7Bn/mSXVofgIgvyB6PMZZ gODg== X-Gm-Message-State: AOJu0YyBIpOBUREisHKO8iMnzWGq3kI4NZrFUIsvNNbLKfIkA31SWw/M sxzvOdVz4HBidsXQy3vCXIqVdGawm0N/OARH+O/2dn2wGPgMeXA/O8DL+w+3cH7sg/mSxWoDeNJ gwg0QmB4byjhZkY9mM0bWrPK8gJ8ZCx7P X-Google-Smtp-Source: AGHT+IH7gXmV0NkdzMs6PssYAivI7+IKtrWTc30Fn/ALm7Kxeh2L44Os5YfiLWFWcMA5i9Poc4S/OmYmk5ZH X-Received: by 2002:a05:6602:1585:b0:82c:967b:6f96 with SMTP id ca18e2360f4ac-834931e3091mr65262239f.8.1727374711582; Thu, 26 Sep 2024 11:18:31 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id 8926c6da1cb9f-4d8888a3942sm20843173.55.2024.09.26.11.18.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Sep 2024 11:18:31 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 806F96050A6B; Thu, 26 Sep 2024 14:18:30 -0400 (EDT) From: jspewock@iol.unh.edu To: alex.chapman@arm.com, wathsala.vithanage@arm.com, thomas@monjalon.net, probb@iol.unh.edu, juraj.linkes@pantheon.tech, Honnappa.Nagarahalli@arm.com, Luca.Vizzarro@arm.com, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v5 1/2] dts: rework packet addressing Date: Thu, 26 Sep 2024 14:18:27 -0400 Message-ID: <20240926181828.15037-2-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240926181828.15037-1-jspewock@iol.unh.edu> References: <20240904152827.11914-1-jspewock@iol.unh.edu> <20240926181828.15037-1-jspewock@iol.unh.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jeremy Spewock This patch updates the _adjust_addresses method of test suites so that addresses of packets are only modified if the developer did not configure them beforehand. This allows for developers to have more control over the content of their packets when sending them through the framework. Signed-off-by: Jeremy Spewock --- dts/framework/test_suite.py | 71 +++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py index 051509fb86..b2d8de99e7 100644 --- a/dts/framework/test_suite.py +++ b/dts/framework/test_suite.py @@ -225,7 +225,7 @@ def send_packets_and_capture( Returns: A list of received packets. """ - packets = [self._adjust_addresses(packet) for packet in packets] + packets = self._adjust_addresses(packets) return self.tg_node.send_packets_and_capture( packets, self._tg_port_egress, @@ -243,41 +243,66 @@ def get_expected_packet(self, packet: Packet) -> Packet: Returns: `packet` with injected L2/L3 addresses. """ - return self._adjust_addresses(packet, expected=True) + return self._adjust_addresses([packet], expected=True)[0] - def _adjust_addresses(self, packet: Packet, expected: bool = False) -> Packet: + def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions. + Packets in `packets` will be directly modified in this method. The returned list of packets + however will be copies of the modified packets. + + Only missing addresses are added to packets, existing addresses will not be overridden. If + any packet in `packets` has multiple IP layers (using GRE, for example) only the inner-most + IP layer will have its addresses adjusted. + Assumptions: Two links between SUT and TG, one link is TG -> SUT, the other SUT -> TG. Args: - packet: The packet to modify. + packets: The packets to modify. expected: If :data:`True`, the direction is SUT -> TG, otherwise the direction is TG -> SUT. - """ - if expected: - # The packet enters the TG from SUT - # update l2 addresses - packet.src = self._sut_port_egress.mac_address - packet.dst = self._tg_port_ingress.mac_address - # The packet is routed from TG egress to TG ingress - # update l3 addresses - packet.payload.src = self._tg_ip_address_egress.ip.exploded - packet.payload.dst = self._tg_ip_address_ingress.ip.exploded - else: - # The packet leaves TG towards SUT + Returns: + A list containing copies of all packets in `packets` after modification. + """ + ret_packets = [] + for packet in packets: # update l2 addresses - packet.src = self._tg_port_egress.mac_address - packet.dst = self._sut_port_ingress.mac_address + # If `expected` is :data:`True`, the packet enters the TG from SUT, otherwise the + # packet leaves the TG towards the SUT. + + # The fields parameter of a packet does not include fields of the payload, so this can + # only be the Ether src/dst. + if "src" not in packet.fields: + packet.src = ( + self._sut_port_egress.mac_address + if expected + else self._tg_port_egress.mac_address + ) + if "dst" not in packet.fields: + packet.dst = ( + self._tg_port_ingress.mac_address + if expected + else self._sut_port_ingress.mac_address + ) - # The packet is routed from TG egress to TG ingress # update l3 addresses - packet.payload.src = self._tg_ip_address_egress.ip.exploded - packet.payload.dst = self._tg_ip_address_ingress.ip.exploded - - return Ether(packet.build()) + # The packet is routed from TG egress to TG ingress regardless of whether it is + # expected or not. + num_ip_layers = packet.layers().count(IP) + if num_ip_layers > 0: + # Update the last IP layer if there are multiple (the framework should be modifying + # the packet address instead of the tunnel address if there is one). + l3_to_use = packet.getlayer(IP, num_ip_layers) + if "src" not in l3_to_use.fields: + l3_to_use.src = self._tg_ip_address_egress.ip.exploded + + if "dst" not in l3_to_use.fields: + l3_to_use.dst = self._tg_ip_address_ingress.ip.exploded + ret_packets.append(Ether(packet.build())) + + return ret_packets def verify(self, condition: bool, failure_description: str) -> None: """Verify `condition` and handle failures. -- 2.46.0