[PATCH 0/4] passt-repair improvements
This series has a number of minor clean ups to passt-repair, plus one more significant change. The latter allows passt-repair to report partial failures, but does require a small change to its protocol. David Gibson (4): passt-repair: Add die() macro passt-repair: Consistently avoid strerror() passt-repair: Improve validation of anciliary data length passt-repair: Allow passt-repair to report partial failures passt-repair.c | 126 ++++++++++++++++++++++++------------------------- repair.c | 11 +++-- 2 files changed, 68 insertions(+), 69 deletions(-) -- 2.48.1
passt-repair has a frequently repeated idiom of printing an error message
then exiting with non-zero code. Add our own version of a die() macro to
simplify this. Probably because of confusion with passt's die() macro we
forgot to explicitly add a newline in some of those error messages. Make
die() add this as well to be consistent.
Signed-off-by: David Gibson
In a0b7f56b3a3c ("passt-repair: Don't use perror(), accept ECONNRESET as
termination") we altered passt-repair to avoid perror() since the glibc
version used a number of syscalls we didn't really want to add to our
seccomp filter. We replaced the perror() calls with explicit messages just
printing the errno.
However, there are a number of other places we still explicitly use
strerror(errno). As we discovered in passt, at least the glibc version is
rather more complex than you'd expect since it deals with locales. Since
passt-repair is supposed to be minimal, and might be suid we want to avoid
this.
Consistently avoid strerror() with the help of a new ie_errno() macro which
prints errno as an integer instead.
Signed-off-by: David Gibson
At present we use a rather awkward loop to invert CMSG_LEN() in order to
determine how many fds we have been passed as anciliary data. We can do
a bit better with some pointer trickery. This also lets us validate the
number of fds we've been passed a bit more naturally.
While we're there, allow an empty message (n == 0) because why not.
Signed-off-by: David Gibson
Although it's unlikely it's possible that passt-repair could encounter an
error on some but not all the fds in a batch it is given. At present,
passt-repair will die in this situation, meaning that passt knows something
went wrong, but doesn't know the state of the fds it passed in the last
batch.
Change the passt-repair protocol, so that instead of replying with a copy
of the command byte, it replies with the number of fds that were
successfuly handled. We always process the fds in the order given, and
bail out on the first error, so this is sufficient to tell passt the state
of all the fds it passed.
For now we don't use that extra information in passt, we just update it to
understand the new protocol.
Signed-off-by: David Gibson
participants (1)
-
David Gibson