diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2025-02-27 16:55:15 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2025-04-02 14:32:10 +1100 |
commit | 4b8660b3d5a9c3530de600239ce190094d26f1c5 (patch) | |
tree | 7447010bd0c32c88226f772a8a0508c8cfa5bd04 | |
parent | 83f95ade5bd97b465240c82f45669bfe3ce259f8 (diff) | |
download | passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.tar passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.tar.gz passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.tar.bz2 passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.tar.lz passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.tar.xz passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.tar.zst passt-4b8660b3d5a9c3530de600239ce190094d26f1c5.zip |
tcp: Correct error code handling from tcp_flow_repair_socket()
There are two small bugs in error returns from tcp_low_repair_socket(),
which is supposed to return a negative errno code:
1) On bind() failures, wedirectly pass on the return code from bind(),
which is just 0 or -1, instead of an error code.
2) In the caller, tcp_flow_migrate_target() we call strerror_() directly
on the negative error code, but strerror() requires a positive error
code.
Correct both of these.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | tcp.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3285,7 +3285,8 @@ int tcp_flow_repair_socket(struct ctx *c, struct tcp_tap_conn *conn) tcp_sock_set_nodelay(s); - if ((rc = bind(s, &a.sa, sizeof(a)))) { + if (bind(s, &a.sa, sizeof(a))) { + rc = -errno; err_perror("Failed to bind socket for migrated flow"); goto err; } @@ -3380,7 +3381,7 @@ int tcp_flow_migrate_target(struct ctx *c, int fd) conn->seq_init_from_tap = ntohl(t.seq_init_from_tap); if ((rc = tcp_flow_repair_socket(c, conn))) { - flow_err(flow, "Can't set up socket: %s, drop", strerror_(rc)); + flow_err(flow, "Can't set up socket: %s, drop", strerror_(-rc)); flow_alloc_cancel(flow); return 0; } |