At the moment we discard the reply message; the fact that it exists is the
only thing we check. Check it has the expected value to be a bit more
thorough.
Signed-off-by: David Gibson
---
repair.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/repair.c b/repair.c
index f473e1f4..d2886173 100644
--- a/repair.c
+++ b/repair.c
@@ -150,6 +150,7 @@ int repair_flush(struct ctx *c)
__attribute__ ((aligned(__alignof__(struct cmsghdr))));
struct cmsghdr *cmsg;
struct msghdr msg;
+ int8_t reply;
if (!repair_nfds)
return 0;
@@ -172,13 +173,19 @@ int repair_flush(struct ctx *c)
return ret;
}
- if (recv(c->fd_repair, &((int8_t){ 0 }), 1, 0) < 0) {
+ if (recv(c->fd_repair, &reply, sizeof(reply), 0) < 0) {
int ret = -errno;
err_perror("Failed to receive reply from TCP_REPAIR helper");
repair_close(c);
return ret;
}
+ if (reply != repair_cmd) {
+ err("Unexpected reply from TCP_REPAIR helper: %d", reply);
+ repair_close(c);
+ return -ENXIO;
+ }
+
return 0;
}
--
2.48.1