From: Stefan Metzmacher Date: Fri, 4 Apr 2025 11:33:31 +0000 (+0200) Subject: s3:lib: pass 'protocol' to open_socket_out_send() X-Git-Tag: tevent-0.17.0~281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6934c7ae402ee7ef593b613022f0330303766287;p=thirdparty%2Fsamba.git s3:lib: pass 'protocol' to open_socket_out_send() For now this is always explicitly IPPROTO_TCP, but that will change when we add support for IPPROTO_QUIC. Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/include/proto.h b/source3/include/proto.h index ba1238ea27b..016e0657bb3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -498,6 +498,7 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port, int timeout, int *pfd); struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, + int protocol, const struct sockaddr_storage *pss, uint16_t port, int timeout); diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index f7d85c2cf6e..d4f05b84ce9 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -404,6 +404,7 @@ static void open_socket_out_cleanup(struct tevent_req *req, struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, + int protocol, const struct sockaddr_storage *pss, uint16_t port, int timeout) @@ -427,7 +428,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, }; state->port = port; - state->fd = socket(state->saddr.u.sa.sa_family, SOCK_STREAM, 0); + state->fd = socket(state->saddr.u.sa.sa_family, SOCK_STREAM, protocol); if (state->fd == -1) { status = map_nt_error_from_unix(errno); tevent_req_nterror(req, status); @@ -539,7 +540,7 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port, goto fail; } - req = open_socket_out_send(frame, ev, pss, port, timeout); + req = open_socket_out_send(frame, ev, IPPROTO_TCP, pss, port, timeout); if (req == NULL) { goto fail; } @@ -612,8 +613,12 @@ static void open_socket_out_defer_waited(struct tevent_req *subreq) return; } - subreq = open_socket_out_send(state, state->ev, &state->ss, - state->port, state->timeout); + subreq = open_socket_out_send(state, + state->ev, + IPPROTO_TCP, + &state->ss, + state->port, + state->timeout); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index 7f0baadd368..5486dd196fb 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -192,7 +192,12 @@ static struct tevent_req *nb_connect_send(TALLOC_CTX *mem_ctx, tevent_req_set_cleanup_fn(req, nb_connect_cleanup); - subreq = open_socket_out_send(state, ev, addr, NBT_SMB_PORT, 5000); + subreq = open_socket_out_send(state, + ev, + IPPROTO_TCP, + addr, + NBT_SMB_PORT, + 5000); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -297,8 +302,12 @@ static void nb_connect_done(struct tevent_req *subreq) state->called_name = "*SMBSERVER"; make_nmb_name(&state->called, state->called_name, 0x20); - subreq = open_socket_out_send(state, state->ev, state->addr, - NBT_SMB_PORT, 5000); + subreq = open_socket_out_send(state, + state->ev, + IPPROTO_TCP, + state->addr, + NBT_SMB_PORT, + 5000); if (tevent_req_nomem(subreq, req)) { return; } @@ -393,7 +402,11 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx, return req; } if (port != 0) { - state->req_445 = open_socket_out_send(state, ev, addr, port, + state->req_445 = open_socket_out_send(state, + ev, + IPPROTO_TCP, + addr, + port, 5000); if (tevent_req_nomem(state->req_445, req)) { return tevent_req_post(req, ev); @@ -407,7 +420,12 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx, * port==0, try both */ - state->req_445 = open_socket_out_send(state, ev, addr, TCP_SMB_PORT, 5000); + state->req_445 = open_socket_out_send(state, + ev, + IPPROTO_TCP, + addr, + TCP_SMB_PORT, + 5000); if (tevent_req_nomem(state->req_445, req)) { return tevent_req_post(req, ev); }