Skip to content

fix(ipsec-xfrm): reject missing-SA rekeys in MockXfrmBackend #417

Description

@VerifiedOrganic

Problem

LinuxXfrmBackend::rekey_sa issues XFRM_MSG_UPDSA. The upstream Linux handler routes that message to xfrm_state_update, which locates the existing SA and returns -ESRCH when the lookup misses. The SDK maps that authoritative miss to XfrmError::NotFound.

MockXfrmBackend::rekey_sa currently uses map insertion and returns Ok(()) even when no matching SA exists. It therefore creates state on an update-only operation and can false-green rekey behavior that the Linux backend rejects.

Required contract

  • Build the existing-SA lookup using the same modeled Linux lookup identity as the mock SA store.
  • If no matching SA exists, return XfrmError::NotFound without inserting or altering any SA.
  • Operation capture may record the rejected rekey attempt, but stored state must remain unchanged.
  • Preserve successful update behavior when the matching SA does exist.

Required tests

  • Rekey an empty unscoped mock backend, assert NotFound, then query the identity and prove that no SA was inserted.
  • Repeat with a nonzero if_id; the Linux SA lookup tuple still controls whether an existing SA is present, and a miss must not create one.
  • Install an SA first, rekey the matching identity, and prove the intended existing-state update still succeeds.

The regression must exercise the public MockXfrmBackend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrustPull requests that update rust code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions