Commit Graph

4 Commits

Author SHA1 Message Date
Vishvananda Abrams
1e35ba25dc test: Improve test reliability with proper cleanup and isolation
Refactors test setup and teardown logic to use `t.Cleanup` instead
of `defer`. This ensures that cleanup functions are correctly scoped
to each subtest's lifecycle, improving test isolation and reliability.

The `setUpNetlinkTest` helper function is also improved to correctly
save and restore the original network namespace, ensuring that tests
do not leak state.

To support this, a `Close()` method that returns an error is added to
the `Handle` struct, allowing for proper cleanup of underlying netlink
sockets. The test helpers are updated to use this new method,
preventing resource leaks between tests.

Additionally, a bug in the `netns` tests is fixed where a large
namespace ID could overflow a 32-bit integer, causing spurious
failures on some systems.
2025-08-27 09:24:17 -07:00
Tobias Klauser
77df5d35f7 Make xfrm linux-only
The xfrm framework is linux-only. Only implement the respective types
for GOOS=linux to avoid dependencies to x/sys/unix on non-linux or
non-unix platforms. Provide dummy XfrmPolicy and XfrmState types for the
globally defined XfrmPolicy* and XfrmState* functions.
2023-10-24 10:58:52 -07:00
Vishvananda Ishaya
1a26b9f251 Move all low level calls into nl subpackage 2014-09-18 19:04:48 -07:00
Vishvananda Ishaya
8dab8b7462 Initial commit of netlink package 2014-08-31 20:34:46 -07:00