Skip to content

[macsec]: Return recent packets in macsec_dp_poll#6992

Merged
theasianpianist merged 2 commits intosonic-net:masterfrom
theasianpianist:macsec-dp-poll-fix
Dec 20, 2022
Merged

[macsec]: Return recent packets in macsec_dp_poll#6992
theasianpianist merged 2 commits intosonic-net:masterfrom
theasianpianist:macsec-dp-poll-fix

Conversation

@theasianpianist
Copy link
Contributor

@theasianpianist theasianpianist commented Dec 8, 2022

Signed-off-by: Lawrence Lee [email protected]

Description of PR

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205

Approach

What is the motivation for this PR?

macsec_dp_poll replaces the original dp_poll function from the PTF library in all test cases (this is used by methods such as ptf.testutils.verify_packet). When macsec_dp_poll doesn't find a packet matching the expected packet, it doesn't return a list of recently received packets (the original dp_poll does), which makes debugging difficult. Instead, it will raise an error with the following message:

E       AssertionError: Expected packet was not received on device 0, port 1.
E       ========== RECEIVED ==========
E       0 total packets.
E       ==============================

How did you do it?

Always store received packets in case they need to be returned in a PollFailure object later.

How did you verify/test it?

Call ptf.testutils.verify_packet and provide some expected packet which will not be received. The method should fail with a message similar to below:

E       AssertionError: Expected packet was not received on device 0, port 1.
E       ========== EXPECTED ==========
E       Mask:
E       0000  4E E0 F6 98 88 DD 08 C0 EB 20 38 EC 08 00 45 00  N........ 8...E.
E       0010  00 88 00 00 00 00 00 11 A4 43 0A 01 00 20 0A 00  .........C... ..
E       0020  02 02 04 D2 12 B5 00 74 A2 60 08 00 00 00 00 07  .......t.`......
E       0030  D0 00 F9 22 83 99 22 A2 F4 93 9F EF C4 7E 08 00  ...".."......~..
E       0040  45 00 00 56 00 01 00 00 40 11 58 91 0B 01 01 01  [email protected].....
E       0050  14 02 02 02 04 D2 00 50 00 42 00 00 74 65 73 74  .......P.B..test
E       0060  73 2E 64 61 73 68 2E 74 65 73 74 5F 64 61 73 68  s.dash.test_dash
E       0070  20 74 65 73 74 73 2E 64 61 73 68 2E 74 65 73 74   tests.dash.test
E       0080  5F 64 61 73 68 20 74 65 73 74 73 2E 64 61 73 68  _dash tests.dash
E       0090  2E 74 65 73 74 5F                                .test_
E       mask = ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0010   00 00 ff ff ff ff ff ff  00 00 ff ff ff ff ff ff
E       0020   ff ff 00 00 ff ff ff ff  00 00 00 ff ff ff ff ff
E       0030   ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0040   ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0050   ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0060   ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0070   ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0080   ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
E       0090   ff ff ff ff ff ff
E
E       ========== RECEIVED ==========
E       3 total packets. Displaying most recent 3 packets:
E       ------------------------------
E       0000  4E E0 F6 98 88 DD 08 C0 EB 20 38 14 08 00 45 C0  N........ 8...E.
E       0010  00 34 E2 07 40 00 01 06 7E FA 0A 00 02 01 0A 00  .4..@...~.......
E       0020  02 02 C3 4C 00 B3 50 B5 61 90 CB C4 A9 7F 80 10  ...L..P.a.......
E       0030  01 F0 45 C5 00 00 01 01 08 0A 03 EC 26 CA 1B FC  ..E.........&...
E       0040  E4 C9                                            ..
E       ------------------------------
E       0000  4E E0 F6 98 88 DD 08 C0 EB 20 38 14 08 00 45 C0  N........ 8...E.
E       0010  00 47 E2 08 40 00 01 06 7E E6 0A 00 02 01 0A 00  .G..@...~.......
E       0020  02 02 C3 4C 00 B3 50 B5 61 90 CB C4 A9 7F 80 18  ...L..P.a.......
E       0030  01 F0 3E CC 00 00 01 01 08 0A 03 EC 29 95 1B FC  ..>.........)...
E       0040  E4 C9 FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ................
E       0050  FF FF 00 13 04                                   .....
...

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

if ptf.dataplane.match_exp_pkt(exp_pkt, pkt):
return ret
else:
macsec_info = load_macsec_info(test.duthost, find_portname_from_ptf_id(test.mg_facts, ret.port), force_reload[ret.port])
Copy link
Contributor

@Pterosaur Pterosaur Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the PR #6828,
To non-Ether packet, we don't need to go to MACsec decap at all.
So, maybe need to skip this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've moved this inside the packet type check

@theasianpianist theasianpianist merged commit ab265a2 into sonic-net:master Dec 20, 2022
wangxin pushed a commit that referenced this pull request Dec 26, 2022
- Always store received packets in case they need to be returned in a PollFailure object later.

Signed-off-by: Lawrence Lee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants