[v3,1/3] dts: fix adjust L2/L3 addresses behavior

Message ID 20241108170138.203096-2-luca.vizzarro@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Paul Szczepanek
Headers
Series dts: add l2fwd test suite |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Luca Vizzarro Nov. 8, 2024, 5:01 p.m. UTC
The _adjust_addresses function has been updated to both modify the
original packets and return new updated copies of them. Having a double
behavior even if documented is not intuitive and can lead to bugs.

This changes the behavior to solely act on copies, leaving the original
packet untouched.

Fixes: 1a1825962777 ("dts: rework packet addressing")

Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 dts/framework/test_suite.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Dean Marx Nov. 12, 2024, 5:11 p.m. UTC | #1
Reviewed-by: Dean Marx <dmarx@iol.unh.edu>
  
Patrick Robb Nov. 13, 2024, 3:36 p.m. UTC | #2
Reviewed-by: Patrick Robb <probb@iol.unh.edu>
Tested-by: Patrick Robb <probb@iol.unh.edu>
  

Patch

diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index fb5d646ce3..5b3e7c205e 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -324,8 +324,7 @@  def get_expected_packet(self, packet: Packet) -> 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.
+        Copies of `packets` will be made, modified and returned in this method.
 
         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
@@ -343,7 +342,9 @@  def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> li
             A list containing copies of all packets in `packets` after modification.
         """
         ret_packets = []
-        for packet in packets:
+        for original_packet in packets:
+            packet = original_packet.copy()
+
             # update l2 addresses
             # If `expected` is :data:`True`, the packet enters the TG from SUT, otherwise the
             # packet leaves the TG towards the SUT.