From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id EE5085A0276; Fri, 07 Feb 2025 09:03:58 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] passt-repair: Send one confirmation *per command*, not *per socket* Date: Fri, 7 Feb 2025 09:03:58 +0100 Message-ID: <20250207080358.3491153-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: WCKM7K5LEQNZCFGQHBKKAEF455RL5RJY X-Message-ID-Hash: WCKM7K5LEQNZCFGQHBKKAEF455RL5RJY X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: It looks like me, myself and I couldn't agree on the "simple" protocol between passt and passt-repair. The man page and passt say it's one confirmation per command, but the passt-repair implementation had one confirmation per socket instead. This caused all sort of mysterious issues with repair mode pseudo-randomly enabled, and leading to hours of fun (mostly not mine). Oops. Switch to one confirmation per command (of course). Signed-off-by: Stefano Brivio --- passt-repair.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/passt-repair.c b/passt-repair.c index 322066a..614cee0 100644 --- a/passt-repair.c +++ b/passt-repair.c @@ -63,6 +63,7 @@ int main(int argc, char **argv) struct cmsghdr *cmsg; struct msghdr msg; struct iovec iov; + int op; prctl(PR_SET_DUMPABLE, 0); @@ -150,25 +151,24 @@ loop: _exit(1); } - for (i = 0; i < n; i++) { - int o = cmd; + op = cmd; - if (setsockopt(fds[i], SOL_TCP, TCP_REPAIR, &o, sizeof(o))) { + for (i = 0; i < n; i++) { + if (setsockopt(fds[i], SOL_TCP, TCP_REPAIR, &op, sizeof(op))) { fprintf(stderr, - "Setting TCP_REPAIR to %i on socket %i: %s", o, + "Setting TCP_REPAIR to %i on socket %i: %s", op, fds[i], strerror(errno)); _exit(1); } /* Close _our_ copy */ close(fds[i]); + } - /* Confirm setting by echoing the command back */ - if (send(s, &cmd, sizeof(cmd), 0) < 0) { - fprintf(stderr, "Reply to command %i: %s\n", - o, strerror(errno)); - _exit(1); - } + /* Confirm setting by echoing the command back */ + if (send(s, &cmd, sizeof(cmd), 0) < 0) { + fprintf(stderr, "Reply to %i: %s\n", op, strerror(errno)); + _exit(1); } goto loop; -- 2.43.0