The branch, master has been updated
       via  4edece5e973 s3:smb2_tcon: pass down in_flags to 
smbd_smb2_tree_connect_send()
       via  3a7480d6124 s3:lib: Allow open_socket_out without a timeout
       via  09ea7248e01 lib/async_req: remove useless "reentrant" support from 
async_connect_send()
       via  a26be7eeedc s3:lib: avoid calling async_connect_send() again and 
again in open_socket_out*()
       via  d48fba7c096 s3:lib: avoid goto's in open_socket_out_send()
       via  ce1a3f2cb20 s3:lib: s/result/req in open_socket_out_send()
       via  048a4230b27 lib/async_req: make sure we return errors early from 
async_connect_send/recv
       via  6d63fa02466 lib/tsocket: add a comment regarding TEVENT_FD_READ in 
tstream_bsd_connect_send()
       via  aab5c8470f7 s3:wscript: split out dsgetdcname subsystem
       via  f99d8ffcbfe s3:wscript: move libsmb/clidgram.c to LIBNMB
       via  b1ebfec39ee s3:libsmb: move cli_set_message() to 
source3/libsmb/nmblib.c
       via  03562cf1282 s3:libsmb: use only a timeout of 250ms in 
name_resolve_bcast_send()
       via  08a7f5c47dd s3:libsmb: pass dest_ss to cli_cm_open()
       via  e0c502728fb s3:libsmb: pass dest_ss to cli_cm_connect() down to 
cli_connect_nb()
      from  c3242b4dfc8 libsmb: Fill in device which we don't get from 
cli_posix_stat

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4edece5e973ac22ce735be3ca2944147d26bdb5d
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Sep 3 15:28:21 2018 +0200

    s3:smb2_tcon: pass down in_flags to smbd_smb2_tree_connect_send()
    
    SMB 3.1.1 converted the reserved field to a flags field.
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Wed Feb 26 21:11:59 UTC 2020 on sn-devel-184

commit 3a7480d6124e39dcf99c67e602e0c2837e22d438
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Nov 27 10:15:39 2018 +0100

    s3:lib: Allow open_socket_out without a timeout
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 09ea7248e017eddd4764a2b643b720b73c6ec21b
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 26 14:16:05 2020 +0100

    lib/async_req: remove useless "reentrant" support from async_connect_send()
    
    Now that open_socket_out*() doesn't do the strange reentrant calls,
    we can remove support for this in async_connect_send(), so that we'll
    never get any new users of this.
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit a26be7eeedc4995ea1a99f4bbb6ce8beaafda012
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 26 13:36:05 2020 +0100

    s3:lib: avoid calling async_connect_send() again and again in 
open_socket_out*()
    
    There's really no need to do that!
    
    Once connect() is called and returned EINPROGRESS, the kernel
    knowns what to do and reports any state change via
    TEVENT_FD_READ or TEVENT_FD_WRITE.
    The actual success or failure is available via
    getsockopt(.., SOL_SOCKET, SO_ERROR, ...).
    
    Before this commit we called connect() (via async_connect_send()) again
    and again until we reached the final caller provided timeout,
    even if the kernel already found out that the destination is
    unreachable.
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit d48fba7c09603e0dcfc7d268d07eec557759b968
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 26 13:27:32 2020 +0100

    s3:lib: avoid goto's in open_socket_out_send()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ce1a3f2cb2047e90da8b6f1bfdfdee1347a5b30c
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 26 13:21:15 2020 +0100

    s3:lib: s/result/req in open_socket_out_send()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 048a4230b2774f4dd1ec706af5b675226da1e872
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Oct 2 07:56:30 2019 -0700

    lib/async_req: make sure we return errors early from async_connect_send/recv
    
    While it is true that [e]poll() only needs POLLOUT
    and POLLERR/POLLHUP are added implicitly.
    For tevent we need TEVENT_FD_READ in order to see POLLERR/POLLHUP.
    
    The socket becomes only readable when we hit an error.
    Waiting for TEVENT_FD_WRITE is needed for getting success,
    while TEVENT_FD_READ is required to get failures.
    
    This matches what we have in tstream_bsd_connect_send().
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6d63fa024668d1f02fee0fa6b309497703be6a96
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 26 16:36:30 2020 +0100

    lib/tsocket: add a comment regarding TEVENT_FD_READ in 
tstream_bsd_connect_send()
    
    This is different compared to the raw usage of [e]poll
    where [E]POLLOUT is enough to see errors via POLLERR/POLLHUP.
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit aab5c8470f72f601b4185bb49d5539c4f29b3cd8
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Oct 30 15:55:32 2019 +0100

    s3:wscript: split out dsgetdcname subsystem
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit f99d8ffcbfeaf287363ca222f89c193526b6d076
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Oct 30 16:20:19 2019 +0100

    s3:wscript: move libsmb/clidgram.c to LIBNMB
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit b1ebfec39ee53dd42715e8ce6b3b0ab9872aa542
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Oct 30 16:19:40 2019 +0100

    s3:libsmb: move cli_set_message() to source3/libsmb/nmblib.c
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 03562cf12821ab038040aa569a8883ab93ebd3b5
Author: Stefan Metzmacher <me...@samba.org>
Date:   Thu Oct 31 07:47:53 2019 +0100

    s3:libsmb: use only a timeout of 250ms in name_resolve_bcast_send()
    
    We use the same value for broadcasts in name_query().
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 08a7f5c47ddc9673bca7377caf121ad5aad1e3b4
Author: Stefan Metzmacher <me...@samba.org>
Date:   Thu Aug 23 09:21:41 2018 +0200

    s3:libsmb: pass dest_ss to cli_cm_open()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit e0c502728fb6036a2b629285cbc6ea8c624cecb0
Author: Stefan Metzmacher <me...@samba.org>
Date:   Thu Aug 23 09:20:49 2018 +0200

    s3:libsmb: pass dest_ss to cli_cm_connect() down to cli_connect_nb()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/async_req/async_sock.c | 15 +++++----
 lib/tsocket/tsocket_bsd.c  |  8 +++++
 source3/client/client.c    | 26 +++++++++------
 source3/lib/netapi/cm.c    |  2 +-
 source3/lib/util_sock.c    | 81 +++++++++-------------------------------------
 source3/libsmb/clidfs.c    | 14 +++++---
 source3/libsmb/clientgen.c | 15 ---------
 source3/libsmb/namequery.c |  2 +-
 source3/libsmb/nmblib.c    | 15 +++++++++
 source3/libsmb/nmblib.h    |  1 +
 source3/libsmb/proto.h     |  2 +-
 source3/smbd/smb2_tcon.c   | 10 ++++++
 source3/wscript_build      | 14 ++++++--
 13 files changed, 100 insertions(+), 105 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 0a8a333f4f3..e436d00ac79 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -131,10 +131,6 @@ struct tevent_req *async_connect_send(
         * The only errno indicating that an initial connect is still
         * in flight is EINPROGRESS.
         *
-        * We get EALREADY when someone calls us a second time for a
-        * given fd and the connect is still in flight (and returned
-        * EINPROGRESS the first time).
-        *
         * This allows callers like open_socket_out_send() to reuse
         * fds and call us with an fd for which the connect is still
         * in flight. The proper thing to do for callers would be
@@ -142,12 +138,19 @@ struct tevent_req *async_connect_send(
         * socket.
         */
 
-       if (errno != EINPROGRESS && errno != EALREADY) {
+       if (errno != EINPROGRESS) {
                tevent_req_error(req, errno);
                return tevent_req_post(req, ev);
        }
 
-       state->fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE,
+       /*
+        * Note for historic reasons TEVENT_FD_WRITE is not enough
+        * to get notified for POLLERR or EPOLLHUP even if they
+        * come together with POLLOUT. That means we need to
+        * use TEVENT_FD_READ in addition until we have
+        * TEVENT_FD_ERROR.
+        */
+       state->fde = tevent_add_fd(ev, state, fd, 
TEVENT_FD_READ|TEVENT_FD_WRITE,
                                   async_connect_connected, req);
        if (state->fde == NULL) {
                tevent_req_error(req, ENOMEM);
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 1627051f3ec..6ad40bd0ada 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -2341,6 +2341,14 @@ static struct tevent_req 
*tstream_bsd_connect_send(TALLOC_CTX *mem_ctx,
        goto post;
 
  async:
+
+       /*
+        * Note for historic reasons TEVENT_FD_WRITE is not enough
+        * to get notified for POLLERR or EPOLLHUP even if they
+        * come together with POLLOUT. That means we need to
+        * use TEVENT_FD_READ in addition until we have
+        * TEVENT_FD_ERROR.
+        */
        state->fde = tevent_add_fd(ev, state,
                                   state->fd,
                                   TEVENT_FD_READ | TEVENT_FD_WRITE,
diff --git a/source3/client/client.c b/source3/client/client.c
index d907890ddaf..8d329216d58 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -5719,10 +5719,12 @@ static int process_command_string(const char *cmd_in)
                NTSTATUS status;
 
                status = cli_cm_open(talloc_tos(), NULL,
-                                    have_ip ? dest_ss_str : desthost,
+                                    desthost,
                                     service, popt_get_cmdline_auth_info(),
                                     smb_encrypt,
-                                    max_protocol, port, name_type,
+                                    max_protocol,
+                                    have_ip ? &dest_ss : NULL, port,
+                                    name_type,
                                     &cli);
                if (!NT_STATUS_IS_OK(status)) {
                        return 1;
@@ -6162,9 +6164,10 @@ static int process(const char *base_directory)
        NTSTATUS status;
 
        status = cli_cm_open(talloc_tos(), NULL,
-                            have_ip ? dest_ss_str : desthost,
+                            desthost,
                             service, popt_get_cmdline_auth_info(),
-                            smb_encrypt, max_protocol, port,
+                            smb_encrypt, max_protocol,
+                            have_ip ? &dest_ss : NULL, port,
                             name_type, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return 1;
@@ -6199,9 +6202,10 @@ static int do_host_query(const char *query_host)
        NTSTATUS status;
 
        status = cli_cm_open(talloc_tos(), NULL,
-                            have_ip ? dest_ss_str : query_host,
+                            query_host,
                             "IPC$", popt_get_cmdline_auth_info(),
-                            smb_encrypt, max_protocol, port,
+                            smb_encrypt, max_protocol,
+                            have_ip ? &dest_ss : NULL, port,
                             name_type, &cli);
        if (!NT_STATUS_IS_OK(status)) {
                return 1;
@@ -6245,10 +6249,11 @@ static int do_host_query(const char *query_host)
                cli_shutdown(cli);
                d_printf("Reconnecting with SMB1 for workgroup listing.\n");
                status = cli_cm_open(talloc_tos(), NULL,
-                                    have_ip ? dest_ss_str : query_host,
+                                    query_host,
                                     "IPC$", popt_get_cmdline_auth_info(),
                                     smb_encrypt, max_proto,
-                                    NBT_SMB_PORT, name_type, &cli);
+                                    have_ip ? &dest_ss : NULL, NBT_SMB_PORT,
+                                    name_type, &cli);
                if (!NT_STATUS_IS_OK(status)) {
                        d_printf("Unable to connect with SMB1 "
                                 "-- no workgroup available\n");
@@ -6278,10 +6283,11 @@ static int do_tar_op(const char *base_directory)
                NTSTATUS status;
 
                status = cli_cm_open(talloc_tos(), NULL,
-                                    have_ip ? dest_ss_str : desthost,
+                                    desthost,
                                     service, popt_get_cmdline_auth_info(),
                                     smb_encrypt, max_protocol,
-                                    port, name_type, &cli);
+                                    have_ip ? &dest_ss : NULL, port,
+                                    name_type, &cli);
                if (!NT_STATUS_IS_OK(status)) {
             ret = 1;
             goto out;
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index 95132f28f05..1b8f2a4e97a 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -112,7 +112,7 @@ static WERROR libnetapi_open_ipc_connection(struct 
libnetapi_ctx *ctx,
                             auth_info,
                             false,
                             lp_client_ipc_max_protocol(),
-                            0, 0x20, &cli_ipc);
+                            NULL, 0, 0x20, &cli_ipc);
        if (!NT_STATUS_IS_OK(status)) {
                cli_ipc = NULL;
        }
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 8fd2f7fa315..0b7029706a6 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -417,7 +417,6 @@ struct open_socket_out_state {
        struct sockaddr_storage ss;
        socklen_t salen;
        uint16_t port;
-       int wait_usec;
        struct tevent_req *connect_subreq;
 };
 
@@ -459,32 +458,34 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX 
*mem_ctx,
                                        int timeout)
 {
        char addr[INET6_ADDRSTRLEN];
-       struct tevent_req *result;
+       struct tevent_req *req;
        struct open_socket_out_state *state;
        NTSTATUS status;
 
-       result = tevent_req_create(mem_ctx, &state,
-                                  struct open_socket_out_state);
-       if (result == NULL) {
+       req = tevent_req_create(mem_ctx, &state,
+                               struct open_socket_out_state);
+       if (req == NULL) {
                return NULL;
        }
        state->ev = ev;
        state->ss = *pss;
        state->port = port;
-       state->wait_usec = 10000;
        state->salen = -1;
 
        state->fd = socket(state->ss.ss_family, SOCK_STREAM, 0);
        if (state->fd == -1) {
                status = map_nt_error_from_unix(errno);
-               goto post_status;
+               tevent_req_nterror(req, status);
+               return tevent_req_post(req, ev);
        }
 
-       tevent_req_set_cleanup_fn(result, open_socket_out_cleanup);
+       tevent_req_set_cleanup_fn(req, open_socket_out_cleanup);
 
-       if (!tevent_req_set_endtime(
-                   result, ev, timeval_current_ofs_msec(timeout))) {
-               goto fail;
+       if ((timeout != 0) &&
+           !tevent_req_set_endtime(
+                   req, ev, timeval_current_ofs_msec(timeout))) {
+               tevent_req_oom(req);
+               return tevent_req_post(req, ev);
        }
 
 #if defined(HAVE_IPV6)
@@ -517,22 +518,12 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX 
*mem_ctx,
        state->connect_subreq = async_connect_send(
                state, state->ev, state->fd, (struct sockaddr *)&state->ss,
                state->salen, NULL, NULL, NULL);
-       if ((state->connect_subreq == NULL)
-           || !tevent_req_set_endtime(
-                   state->connect_subreq, state->ev,
-                   timeval_current_ofs(0, state->wait_usec))) {
-               goto fail;
+       if (tevent_req_nomem(state->connect_subreq, NULL)) {
+               return tevent_req_post(req, ev);
        }
        tevent_req_set_callback(state->connect_subreq,
-                               open_socket_out_connected, result);
-       return result;
-
- post_status:
-       tevent_req_nterror(result, status);
-       return tevent_req_post(result, ev);
- fail:
-       TALLOC_FREE(result);
-       return NULL;
+                               open_socket_out_connected, req);
+       return req;
 }
 
 static void open_socket_out_connected(struct tevent_req *subreq)
@@ -552,46 +543,6 @@ static void open_socket_out_connected(struct tevent_req 
*subreq)
                return;
        }
 
-       if (
-#ifdef ETIMEDOUT
-               (sys_errno == ETIMEDOUT) ||
-#endif
-               (sys_errno == EINPROGRESS) ||
-               (sys_errno == EALREADY) ||
-               (sys_errno == EAGAIN)) {
-
-               /*
-                * retry
-                */
-
-               if (state->wait_usec < 250000) {
-                       state->wait_usec *= 1.5;
-               }
-
-               subreq = async_connect_send(state, state->ev, state->fd,
-                                           (struct sockaddr *)&state->ss,
-                                           state->salen, NULL, NULL, NULL);
-               if (tevent_req_nomem(subreq, req)) {
-                       return;
-               }
-               if (!tevent_req_set_endtime(
-                           subreq, state->ev,
-                           timeval_current_ofs_usec(state->wait_usec))) {
-                       return;
-               }
-               state->connect_subreq = subreq;
-               tevent_req_set_callback(subreq, open_socket_out_connected, req);
-               return;
-       }
-
-#ifdef EISCONN
-       if (sys_errno == EISCONN) {
-               tevent_req_done(req);
-               return;
-       }
-#endif
-
-       /* real error */
        tevent_req_nterror(req, map_nt_error_from_unix(sys_errno));
 }
 
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index ba851f3f471..25f932c60bb 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -137,6 +137,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                                        const struct user_auth_info *auth_info,
                                        bool force_encrypt,
                                        int max_protocol,
+                                       const struct sockaddr_storage *dest_ss,
                                        int port,
                                        int name_type,
                                        struct cli_state **pcli)
@@ -191,7 +192,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
        }
 
        status = cli_connect_nb(
-               server, NULL, port, name_type, NULL,
+               server, dest_ss, port, name_type, NULL,
                signing_state,
                flags, &c);
 
@@ -274,7 +275,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                return do_connect(ctx, newserver,
                                newshare, auth_info,
                                force_encrypt, max_protocol,
-                               port, name_type, pcli);
+                               NULL, port, name_type, pcli);
        }
 
        /* must be a normal share */
@@ -329,6 +330,7 @@ static NTSTATUS cli_cm_connect(TALLOC_CTX *ctx,
                               const struct user_auth_info *auth_info,
                               bool force_encrypt,
                               int max_protocol,
+                              const struct sockaddr_storage *dest_ss,
                               int port,
                               int name_type,
                               struct cli_state **pcli)
@@ -339,7 +341,7 @@ static NTSTATUS cli_cm_connect(TALLOC_CTX *ctx,
        status = do_connect(ctx, server, share,
                                auth_info,
                                force_encrypt, max_protocol,
-                               port, name_type, &cli);
+                               dest_ss, port, name_type, &cli);
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -424,6 +426,7 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
                                const struct user_auth_info *auth_info,
                                bool force_encrypt,
                                int max_protocol,
+                               const struct sockaddr_storage *dest_ss,
                                int port,
                                int name_type,
                                struct cli_state **pcli)
@@ -453,6 +456,7 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
                                auth_info,
                                force_encrypt,
                                max_protocol,
+                               dest_ss,
                                port,
                                name_type,
                                &c);
@@ -1001,6 +1005,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
                             dfs_auth_info,
                             cli_state_is_encryption_on(rootcli),
                             smbXcli_conn_protocol(rootcli->conn),
+                            NULL, /* dest_ss not needed, we reuse the 
transport */
                             0,
                             0x20,
                             &cli_ipc);
@@ -1058,7 +1063,8 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
                                dfs_auth_info,
                                cli_state_is_encryption_on(rootcli),
                                smbXcli_conn_protocol(rootcli->conn),
-                               0,
+                               NULL, /* dest_ss */
+                               0, /* port */
                                0x20,
                                targetcli);
                if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 6c946ff17d6..d68b86df1c7 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -28,21 +28,6 @@
 #include "../librpc/ndr/libndr.h"
 #include "../include/client.h"
 
-/*******************************************************************
- Setup the word count and byte count for a client smb message.
-********************************************************************/
-
-int cli_set_message(char *buf,int num_words,int num_bytes,bool zero)
-{
-       if (zero && (num_words || num_bytes)) {
-               memset(buf + smb_size,'\0',num_words*2 + num_bytes);
-       }
-       SCVAL(buf,smb_wct,num_words);
-       SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
-       smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
-       return (smb_size + num_words*2 + num_bytes);
-}
-
 /****************************************************************************
  Change the timeout (in milliseconds).
 ****************************************************************************/
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index e27b60b0398..454ea61a895 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1871,7 +1871,7 @@ struct tevent_req *name_resolve_bcast_send(TALLOC_CTX 
*mem_ctx,
        }
 
        subreq = name_queries_send(state, ev, name, name_type, true, true,
-                                  bcast_addrs, num_bcast_addrs, 0, 1000);
+                                  bcast_addrs, num_bcast_addrs, 0, 250);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index c05fac2bba9..a5e691a1c86 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -1448,3 +1448,18 @@ int name_len(unsigned char *s1, size_t buf_len)
 
        return(len);
 }
+
+/*******************************************************************
+ Setup the word count and byte count for a client smb message.
+********************************************************************/
+
+int cli_set_message(char *buf,int num_words,int num_bytes,bool zero)
+{
+       if (zero && (num_words || num_bytes)) {
+               memset(buf + smb_size,'\0',num_words*2 + num_bytes);
+       }
+       SCVAL(buf,smb_wct,num_words);
+       SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
+       smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
+       return (smb_size + num_words*2 + num_bytes);
+}
diff --git a/source3/libsmb/nmblib.h b/source3/libsmb/nmblib.h
index a0624ed085c..52600a41e57 100644
--- a/source3/libsmb/nmblib.h
+++ b/source3/libsmb/nmblib.h
@@ -54,5 +54,6 @@ void sort_query_replies(char *data, int n, struct in_addr ip);
 char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type);
 int name_extract(unsigned char *buf,size_t buf_len, unsigned int ofs, fstring 
name);
 int name_len(unsigned char *s1, size_t buf_len);
+int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
 
 #endif /* _LIBSMB_NMBLIB_H_ */
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 12241fda798..e44dad13200 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -150,6 +150,7 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
                                const struct user_auth_info *auth_info,
                                bool force_encrypt,
                                int max_protocol,
+                               const struct sockaddr_storage *dest_ss,
                                int port,
                                int name_type,
                                struct cli_state **pcli);
@@ -186,7 +187,6 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 
 /* The following definitions come from libsmb/clientgen.c  */
 
-int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
 bool cli_set_backup_intent(struct cli_state *cli, bool flag);
 extern struct GUID cli_state_client_guid;
diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c
index bf709d8686e..76112d04889 100644
--- a/source3/smbd/smb2_tcon.c
+++ b/source3/smbd/smb2_tcon.c
@@ -33,6 +33,7 @@
 static struct tevent_req *smbd_smb2_tree_connect_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct smbd_smb2_request *smb2req,
+                                       uint16_t in_flags,
                                        const char *in_path);
 static NTSTATUS smbd_smb2_tree_connect_recv(struct tevent_req *req,
                                            uint8_t *out_share_type,
@@ -46,7 +47,9 @@ static void smbd_smb2_request_tcon_done(struct tevent_req 
*subreq);
 
 NTSTATUS smbd_smb2_request_process_tcon(struct smbd_smb2_request *req)
 {
+       struct smbXsrv_connection *xconn = req->xconn;
        const uint8_t *inbody;
+       uint16_t in_flags;
        uint16_t in_path_offset;
        uint16_t in_path_length;
        DATA_BLOB in_path_buffer;
@@ -62,6 +65,11 @@ NTSTATUS smbd_smb2_request_process_tcon(struct 
smbd_smb2_request *req)
        }
        inbody = SMBD_SMB2_IN_BODY_PTR(req);
 
+       if (xconn->protocol >= PROTOCOL_SMB3_11) {
+               in_flags = SVAL(inbody, 0x02);
+       } else {
+               in_flags = 0;
+       }
        in_path_offset = SVAL(inbody, 0x04);
        in_path_length = SVAL(inbody, 0x06);
 
@@ -96,6 +104,7 @@ NTSTATUS smbd_smb2_request_process_tcon(struct 
smbd_smb2_request *req)
        subreq = smbd_smb2_tree_connect_send(req,
                                             req->sconn->ev_ctx,
                                             req,
+                                            in_flags,
                                             in_path_string);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
@@ -425,6 +434,7 @@ struct smbd_smb2_tree_connect_state {
 static struct tevent_req *smbd_smb2_tree_connect_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct smbd_smb2_request *smb2req,
+                                       uint16_t in_flags,
                                        const char *in_path)
 {
        struct tevent_req *req;
diff --git a/source3/wscript_build b/source3/wscript_build
index 5dd0af73c8b..465c1e5875d 100644
--- a/source3/wscript_build


-- 
Samba Shared Repository

Reply via email to