diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-06-16 11:09:36 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-06-16 23:50:00 +0200 |
| commit | ab2260a0c73623f51e95f922002393170d0abe1f (patch) | |
| tree | 1e22a34d3889d1a3da21eb0761c739ecc626ef8a | |
| parent | 50e3dcc44074dea26ed8486f65aa02d1dc2291ec (diff) | |
| download | passt-ab2260a0c73623f51e95f922002393170d0abe1f.tar passt-ab2260a0c73623f51e95f922002393170d0abe1f.tar.gz passt-ab2260a0c73623f51e95f922002393170d0abe1f.tar.bz2 passt-ab2260a0c73623f51e95f922002393170d0abe1f.tar.lz passt-ab2260a0c73623f51e95f922002393170d0abe1f.tar.xz passt-ab2260a0c73623f51e95f922002393170d0abe1f.tar.zst passt-ab2260a0c73623f51e95f922002393170d0abe1f.zip | |
It's a bit odd to have the listen(2) call for TCP listening sockets, down
deep in sock_l4_() conditional upon the epoll type passed in. Move it to
pif_listen(), which is at least about listening, although it does still
need to be conditional on TCP.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | pif.c | 14 | ||||
| -rw-r--r-- | util.c | 7 |
2 files changed, 10 insertions, 11 deletions
@@ -125,11 +125,17 @@ int pif_listen(const struct ctx *c, uint8_t proto, uint8_t pif, ref.listen.pif = pif; ref.listen.rule = rule; - ret = epoll_add(c->epollfd, EPOLLIN, ref); - if (ret < 0) { - close(ref.fd); - return ret; + if (proto == IPPROTO_TCP && listen(ref.fd, 128) < 0) { + ret = -errno; + goto fail; } + ret = epoll_add(c->epollfd, EPOLLIN, ref); + if (ret < 0) + goto fail; + return ref.fd; +fail: + close(ref.fd); + return ret; } @@ -169,13 +169,6 @@ static int sock_l4_(const struct ctx *c, enum epoll_type type, } } - if (type == EPOLL_TYPE_TCP_LISTEN && listen(fd, 128) < 0) { - ret = -errno; - warn("TCP socket listen: %s", strerror_(-ret)); - close(fd); - return ret; - } - return fd; } |
