[v3,1/3] dts: fix adjust L2/L3 addresses behavior
Checks
Commit Message
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
Reviewed-by: Dean Marx <dmarx@iol.unh.edu>
Reviewed-by: Patrick Robb <probb@iol.unh.edu>
Tested-by: Patrick Robb <probb@iol.unh.edu>
@@ -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.