]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:lib/util_sock: allow {before,after}_connect hooks to be passed to open_socket_out_...
authorStefan Metzmacher <metze@samba.org>
Thu, 18 Dec 2025 11:47:15 +0000 (12:47 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 13 Jan 2026 08:13:04 +0000 (08:13 +0000)
async_connect_send() already has these hooks now open_socket_out_send()
callers can pass them through.

This will be useful for IPPROTO_SMBDIRECT sockets to setup things
between the socket() and connect() syscalls.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jan 13 08:13:04 UTC 2026 on atb-devel-224

source3/include/proto.h
source3/lib/util_sock.c
source3/libsmb/smbsock_connect.c

index e13584c4d6cade60cd0ecb223592997faa3704ca..854945e8db7ce6d2a09697feb3195c04ddfedc82 100644 (file)
@@ -497,7 +497,10 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
                                        int protocol,
                                        const struct sockaddr_storage *pss,
                                        uint16_t port,
-                                       int timeout);
+                                       int timeout,
+                                       void (*before_connect)(int fd, void *private_data),
+                                       void (*after_connect)(int fd, void *private_data),
+                                       void *private_data);
 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
 
index 44c38de5ccfebda53db68ea5022363b63922ca8e..d88596ba426a09cfd74a0a2f95267d5fa66b74f5 100644 (file)
@@ -407,7 +407,10 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
                                        int protocol,
                                        const struct sockaddr_storage *pss,
                                        uint16_t port,
-                                       int timeout)
+                                       int timeout,
+                                       void (*before_connect)(int fd, void *private_data),
+                                       void (*after_connect)(int fd, void *private_data),
+                                       void *private_data)
 {
        char addr[INET6_ADDRSTRLEN];
        struct tevent_req *req;
@@ -472,7 +475,8 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
 
        state->connect_subreq = async_connect_send(
                state, state->ev, state->fd, &state->saddr.u.sa,
-               state->saddr.sa_socklen, NULL, NULL, NULL);
+               state->saddr.sa_socklen,
+               before_connect, after_connect, private_data);
        if (tevent_req_nomem(state->connect_subreq, NULL)) {
                return tevent_req_post(req, ev);
        }
@@ -540,7 +544,8 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
                goto fail;
        }
 
-       req = open_socket_out_send(frame, ev, IPPROTO_TCP, pss, port, timeout);
+       req = open_socket_out_send(frame, ev, IPPROTO_TCP, pss, port, timeout,
+                                  NULL, NULL, NULL);
        if (req == NULL) {
                goto fail;
        }
index b6189d1891e54747081d5b3a85b322f744eaa7b5..403435c45d9e1260347aeb589ccafd5b7ae0144c 100644 (file)
@@ -207,7 +207,10 @@ static struct tevent_req *nb_connect_send(TALLOC_CTX *mem_ctx,
                                      IPPROTO_TCP,
                                      addr,
                                      port,
-                                     5000);
+                                     5000,
+                                     NULL,
+                                     NULL,
+                                     NULL);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -317,7 +320,10 @@ static void nb_connect_done(struct tevent_req *subreq)
                                              IPPROTO_TCP,
                                              state->addr,
                                              NBT_SMB_PORT,
-                                             5000);
+                                             5000,
+                                             NULL,
+                                             NULL,
+                                             NULL);
                if (tevent_req_nomem(subreq, req)) {
                        return;
                }
@@ -685,7 +691,10 @@ static bool smbsock_connect_submit_next(struct tevent_req *req)
                                                 IPPROTO_TCP,
                                                 state->addr,
                                                 s->transport.port,
-                                                5000);
+                                                5000,
+                                                NULL,
+                                                NULL,
+                                                NULL);
                if (tevent_req_nomem(s->subreq, req)) {
                        return false;
                }
@@ -705,7 +714,10 @@ static bool smbsock_connect_submit_next(struct tevent_req *req)
                                                 IPPROTO_QUIC,
                                                 state->addr,
                                                 s->transport.port,
-                                                5000);
+                                                5000,
+                                                NULL,
+                                                NULL,
+                                                NULL);
                if (tevent_req_nomem(s->subreq, req)) {
                        return false;
                }