netlink
netlink copied to clipboard
Preserve results when NLM_F_DUMP_INTR is set
When the kernel detects a change in a set of resources being dumped (walked-over) by a netlink call, it sets flag NLM_F_DUMP_INTR
to indicate that the results may be incomplete or inconsistent.
Before https://github.com/vishvananda/netlink/pull/925 (in v1.2.1), the flag was ignored and results were returned without an error. With that change, response handling is aborted, results are discarded, and unix.EINTR
is returned.
Depending on what the caller is looking for, the incomplete/inconsistent results may be usable - and that may be preferable to retrying the whole request (which could take unbounded time on a system that's seeing a lot of changes in a lot of data).
This PR introduces a new error, netlink.ErrDumpInterrupted
that's specific to the NLM_F_DUMP_INTR
case. Response handling completes as normal, and data is returned along with the error. So, the caller can use something like errors.Is(err, netlink.ErrDumpInterrupted)
, and take appropriate action.
If any callers are checking for errors.Is(err, unix.EINTR)
, that'll continue to work. But, this is a breaking change for any callers checking the error with a simple err == unix.EINTR
.