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.
Introduces a configuration flag to disable Virtual Function polling,
providing users with control over polling behavior for performance
optimization scenarios.
Fixes: #1097
Signed-off-by: pasteley <ceasebeing@gmail.com>
Allows the ability to set NETLINK_GET_STRICT_CHK socket option on netlink handles.
This can be used to avoid missing routes due to a kernel bug[1]. The
choice to make this a toggle is because not all operations use the
correctly formatted message and so some will fail. The scope of
determining which calls use the wrong message format is an unknown
amount of work at this time so we give the consumer of the library a
toggle they can use when needed.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=885b8b4dbba5ca6114db0fcd0737fe2512650745
When receiving a lot of route changes (10,000 routes are enough), the
default receive buffer size (value of
`/proc/sys/net/core/rmem_default`) is too small and we get a `ENOBUF`
error. A user may want to increase the buffer size up to the value of
`/proc/sys/net/core/rmem_max` (by default, this is the same value). A
`SetSocketReceiveBufferSize()` function is provided to this
destination.
Possible improvements:
1. automatically increase receive buffer size in higher level
functions until we hit a maximum (get an error and/or the current
value is smaller than expected)
2. accept a "force" argument to use `SO_RCVBUFFORCE` to increase the
value over `rmem_max` value
If the socket is closed the recv that are waiting for messages
are not woken up. The result especially for Subscribe socket is
most likely a go routine leak.
This commit introduces a method to set the timeout
Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>