|
13 | 13 | from lib.py import defer |
14 | 14 | from lib.py import ksft_run, ksft_exit, ksft_pr |
15 | 15 | from lib.py import ksft_true, ksft_eq, ksft_ne, ksft_gt, ksft_raises |
| 16 | +from lib.py import ksft_not_none |
16 | 17 | from lib.py import KsftSkipEx |
17 | 18 | from lib.py import NetDrvEpEnv, PSPFamily, NlError |
18 | 19 | from lib.py import bkg, rand_port, wait_port_listen |
@@ -500,6 +501,61 @@ def data_stale_key(cfg): |
500 | 501 | _close_psp_conn(cfg, s) |
501 | 502 |
|
502 | 503 |
|
| 504 | +def __nsim_psp_rereg(cfg): |
| 505 | + # The PSP dev ID will change, remember what was there before |
| 506 | + before = set([x['id'] for x in cfg.pspnl.dev_get({}, dump=True)]) |
| 507 | + |
| 508 | + cfg._ns.nsims[0].dfs_write('psp_rereg', '1') |
| 509 | + |
| 510 | + after = set([x['id'] for x in cfg.pspnl.dev_get({}, dump=True)]) |
| 511 | + |
| 512 | + new_devs = list(after - before) |
| 513 | + ksft_eq(len(new_devs), 1) |
| 514 | + cfg.psp_dev_id = list(after - before)[0] |
| 515 | + |
| 516 | + |
| 517 | +def removal_device_rx(cfg): |
| 518 | + """ Test removing a netdev / PSD with active Rx assoc """ |
| 519 | + |
| 520 | + # We could technically devlink reload real devices, too |
| 521 | + # but that kills the control socket. So test this on |
| 522 | + # netdevsim only for now |
| 523 | + cfg.require_nsim() |
| 524 | + |
| 525 | + s = _make_clr_conn(cfg) |
| 526 | + try: |
| 527 | + rx_assoc = cfg.pspnl.rx_assoc({"version": 0, |
| 528 | + "dev-id": cfg.psp_dev_id, |
| 529 | + "sock-fd": s.fileno()}) |
| 530 | + ksft_not_none(rx_assoc) |
| 531 | + |
| 532 | + __nsim_psp_rereg(cfg) |
| 533 | + finally: |
| 534 | + _close_conn(cfg, s) |
| 535 | + |
| 536 | + |
| 537 | +def removal_device_bi(cfg): |
| 538 | + """ Test removing a netdev / PSD with active Rx/Tx assoc """ |
| 539 | + |
| 540 | + # We could technically devlink reload real devices, too |
| 541 | + # but that kills the control socket. So test this on |
| 542 | + # netdevsim only for now |
| 543 | + cfg.require_nsim() |
| 544 | + |
| 545 | + s = _make_clr_conn(cfg) |
| 546 | + try: |
| 547 | + rx_assoc = cfg.pspnl.rx_assoc({"version": 0, |
| 548 | + "dev-id": cfg.psp_dev_id, |
| 549 | + "sock-fd": s.fileno()}) |
| 550 | + cfg.pspnl.tx_assoc({"dev-id": cfg.psp_dev_id, |
| 551 | + "version": 0, |
| 552 | + "tx-key": rx_assoc['rx-key'], |
| 553 | + "sock-fd": s.fileno()}) |
| 554 | + __nsim_psp_rereg(cfg) |
| 555 | + finally: |
| 556 | + _close_conn(cfg, s) |
| 557 | + |
| 558 | + |
503 | 559 | def psp_ip_ver_test_builder(name, test_func, psp_ver, ipver): |
504 | 560 | """Build test cases for each combo of PSP version and IP version""" |
505 | 561 | def test_case(cfg): |
@@ -551,7 +607,7 @@ def main() -> None: |
551 | 607 | ] |
552 | 608 |
|
553 | 609 | ksft_run(cases=cases, globs=globals(), |
554 | | - case_pfx={"dev_", "data_", "assoc_"}, |
| 610 | + case_pfx={"dev_", "data_", "assoc_", "removal_"}, |
555 | 611 | args=(cfg, )) |
556 | 612 |
|
557 | 613 | cfg.comm_sock.send(b"exit\0") |
|
0 commit comments