summaryrefslogtreecommitdiffstats
path: root/source3/smbd/smb2_server.c
Commit message (Collapse)AuthorAgeFilesLines
* s3:smb2_server: call smbd_smb2_flush_send_queue() directlyStefan Metzmacher2014-05-311-6/+5
| | | | | | | | | | | | This avoids recursion into smbd_smb2_io_handler(), which avoids confusion when analysing out put of performance analysing tools, e.g. callgrind. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat May 31 04:25:36 CEST 2014 on sn-devel-104
* s3:smb2_server: fix invalid TALLOC_FREE(iov) in smbd_smb2_inbuf_parse_compound()Stefan Metzmacher2014-05-311-7/+7
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: remove unused get_min_receive_file_size() wrapper functionStefan Metzmacher2014-04-111-13/+2
| | | | | | | | | | smb2req always comes from talloc_zero(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Apr 11 23:55:17 CEST 2014 on sn-devel-104
* s3:smb2_server: only allocate the required buffer in the smb2 recvfile() ↵Stefan Metzmacher2014-04-111-19/+29
| | | | | | | | | | code path This way the buffer will likely be allocated within the existing talloc_pool, which avoids one malloc() per request. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: prepare smbd_smb2_request_verify_sizes() for the optimized ↵Stefan Metzmacher2014-04-111-0/+9
| | | | | | | | | recvfile() case For recvfile we haven't read and may not allocated the dyn buffer. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: make sure we don't try recvfile for special NBT messagesStefan Metzmacher2014-04-111-0/+3
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: use the same logic to avoid recvfile() for IPC/PRINT sharesStefan Metzmacher2014-04-111-0/+41
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: avoid talloc_zero_array() in smbd_smb2_request_setup_out()Stefan Metzmacher2014-03-061-4/+11
| | | | | | | | | | | In the common case with just one request, we can use a preallocated req->out.vector. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Mar 6 00:59:29 CET 2014 on sn-devel-104
* s3:smb2_server: don't assume that req->out.vector is always a valid talloc ↵Stefan Metzmacher2014-03-051-4/+4
| | | | | | | | | pointer We use 'req' instead as it has the same lifetime. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: avoid talloc_zero_array() in smbd_smb2_request_error_ex()Stefan Metzmacher2014-03-051-6/+2
| | | | | | | | | It is only important that the content of info->data stays alive for the lifetime of the request, but the DATA_BLOB structure itself can be on the stack, while passing it as 'dyn' to smbd_smb2_request_done_ex(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: optimize smbd_smb2_generate_outbody() for the common caseStefan Metzmacher2014-03-051-0/+6
| | | | | | | Use a preallocated buffer for the first response in the compound chain. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: add smbd_smb2_generate_outbody() helperStefan Metzmacher2014-03-051-0/+5
| | | | | | | We can add optimization there later. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_read: avoid 2 talloc* calls when using sendfile()Stefan Metzmacher2014-03-051-3/+11
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: avoid a call to data_blob_clear_free() if not neededStefan Metzmacher2014-03-051-6/+18
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: optimize smbd_smb2_request_setup_out()Stefan Metzmacher2014-03-051-6/+8
| | | | | | | | | | We can use a preallocated buffer for the possible error response of the first response in the compound chain. This avoids a talloc_array_zero() call for the common case. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: optimize req->in.vector allocationStefan Metzmacher2014-03-051-13/+30
| | | | | | | | | We can avoid a talloc_zero_array() call in the common case (without compound requests) and use a preallocated array instead. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: maintain smbd_server_connection->statusStefan Metzmacher2014-02-211-0/+16
| | | | | | | | | If this isn't NT_STATUS_OK, we skip any io on the socket. This avoids possible problems during shutdown. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* smbd: Fix CID 1138328 Logically dead codeVolker Lendecke2013-12-171-0/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smb2_server: avoid calling set_current_user_info() for each requestStefan Metzmacher2013-11-271-3/+6
| | | | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Nov 27 16:31:44 CET 2013 on sn-devel-104
* s3:smb2_server: generate a header blob for the sendfile pathStefan Metzmacher2013-11-271-1/+33
| | | | | | | | | | We need to pass the NBT header, SMB2 header and SMB2 Read header as header blob to SMB_VFS_SENDFILE(). This allows the usage of MSG_SEND or other tricks to avoid multiple TCP packets on the wire. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:smb2_server: allocate smbd_smb2_request on talloc_tos()Stefan Metzmacher2013-11-271-1/+3
| | | | | | | | This matches the behavior for smb1 requests and avoids an additional malloc() per request. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:smb2_server: use tevent_req_notify_callback() in ↵Stefan Metzmacher2013-11-271-0/+7
| | | | | | | | | | | smbd_smb2_request_pending_queue() If the request is already done we can avoid one iteration of tevent_loop_once(), which means we avoids one talloc_stackframe_pool/talloc_free pair. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:smb2_server: for performance reasons we use tevent_fd and readv/writev ↵Stefan Metzmacher2013-11-271-435/+377
| | | | | | | | | | | | | | | | | | | | | directly Going via tevent_req_create/talloc_free at multiple layer costs too much cpu cycles per request. I tested downloading a 16GB (sparse) file with smbclient -b1 -mNT1, and -mSMB2_02. Using smb2 max read = 64512, which means smb1 and smb2 will use the same read size. I build with -O3 -g and compared the results with valgrind --tool=callgrind. With -mNT1 the server uses about 2.000.000.000 cpu cycles. This patch reduces the userspace cpu cycles for -mSMB2_02 from about ~ 8.000.000.000 down to ~ 4.000.000.000. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:smb2_server: fix drain_socket error handlingStefan Metzmacher2013-11-271-3/+17
| | | | | | | | smbd_smb2_request_error_ex() should return NTSTATUS and the caller will terminate the connection. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd:smb2: fix error code when the header says the request is signed but we ↵Michael Adam2013-10-021-1/+1
| | | | | | | | | | | | | don't have a sesseion I.e. when the request is a session setup. We replied with ACCESS_DENIED, but windows expects USER_SESSION_DELETED Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Oct 2 22:07:44 CEST 2013 on sn-devel-104
* s3:smb2_server: don't rely on the SMB2_HDR_FLAG_SIGNED if signing is requiredStefan Metzmacher2013-10-021-1/+1
| | | | | | | | Windows (at least the test suites) may skip the SMB2_HDR_FLAG_SIGNED in a reauth session setup, but still provide a valid signature. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* Revert my accidental commit.Richard Sharpe2013-05-231-1/+1
| | | | | | | Signed-off-by: Richard Sharpe <rsharpe@samba.org> Autobuild-User(master): Richard Sharpe <sharpe@samba.org> Autobuild-Date(master): Thu May 23 06:53:17 CEST 2013 on sn-devel-104
* Make sure that if an smbd is exiting because of an error we let the user know.Richard Sharpe2013-05-211-1/+1
| | | | Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>
* Remove the compound_related_in_progress state from the smb2 global state.Jeremy Allison2013-05-071-11/+0
| | | | | | | | And also remove the restriction that we can't read a new request whilst we're in this state. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@samba.org>
* The core of the fix to allow opens to go async inside a compound request.Jeremy Allison2013-05-071-43/+53
| | | | | | | | This is only allowed for opens that cause an oplock break, otherwise it is not allowed. See [MS-SMB2].pdf note <194> on Section 3.3.5.2.7. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
* Move a variable into the area of code where it's used.Jeremy Allison2013-05-071-2/+2
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
* Ensure we don't try and cancel anything that is in a compound-related request.Jeremy Allison2013-05-071-0/+8
| | | | | | | Too hard to deal with splitting off the replies. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
* Add the internals of is_smb2_recvfile_write.Jeremy Allison2013-04-191-1/+37
| | | | | | | | This turns on the real receivefile detection, and completes the receivefile code path changes. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
* The guts of the receivefile code changes.Jeremy Allison2013-04-191-5/+60
| | | | | | | | | | | | | | | | If an incoming PDU might qualify, only read SMBD_SMB2_SHORT_RECEIVEFILE_WRITE_LEN = (SMB2_HEADER + SMB2_WRITE_BODY_LEN) bytes rather than the whole PDU. Next time we're called, use is_smb2_recvfile_write() to decide if this is an SMB2_WRITE that fit the receivefile criteria, otherwise just read the rest of the PDU. If we did do a short receivefile read, set up the smb2_req->smb1req->unread_bytes value to show what bytes remain in the TCP buffers. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
* Add stub static function that will turn on/off receivefile code path.Jeremy Allison2013-04-191-0/+5
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
* Add extra fields into struct smbd_smb2_request_read_state to support ↵Jeremy Allison2013-04-191-0/+3
| | | | | | | | | | receivefile. Initialize min_recv_size with the size that will trigger the receivefile write path. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
* Add utility function get_min_receive_file_size().Jeremy Allison2013-04-191-0/+11
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
* Allow smbd_smb2_request_error_ex() to cope with unread bytes on error.Jeremy Allison2013-04-191-0/+10
| | | | | | | Drain the socket if a RECVFILE write failed. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
* Fix bad SMB2 opcode reading in server.Jeremy Allison2013-04-021-5/+5
| | | | | | | | | | | | SMB2 opcodes are 16-bit values. We should *never* be reading them with IVAL(inhdr, SMB2_HDR_OPCODE), it should always be SVAL(inhdr, SMB2_HDR_OPCODE). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com> Autobuild-User(master): Richard Sharpe <sharpe@samba.org> Autobuild-Date(master): Tue Apr 2 07:28:48 CEST 2013 on sn-devel-104
* smb2_server: Fix typo in comment.Karolin Seeger2012-11-021-1/+1
| | | | | | | Karolin Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Nov 2 15:40:22 CET 2012 on sn-devel-104
* s3:smbd:smb2: fix a comment typo in the crediting code.Michael Adam2012-11-021-1/+1
| | | | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Nov 2 10:09:36 CET 2012 on sn-devel-104
* Fix bug #9214 - Bad user supplied SMB2 credit value can cause smbd to call ↵Jeremy Allison2012-10-031-1/+6
| | | | | | smb_panic. Terminate the connection cleanly instead.
* s3:smb2_server: avoid segfault in smbd_smb2_request_pending_queue()Stefan Metzmacher2012-09-221-2/+6
| | | | | | | | | | | | Because we should not call smbd_smb2_request_error() on an request that is still running. If the subreq implementes a cancel function, this should take care of triggering smbd_smb2_request_error. metze Signed-off-by: Michael Adam <obnox@samba.org>
* s3:smbd:smb2: simplify smbd_smb2_request_validate() and ↵Michael Adam2012-09-221-49/+3
| | | | | | | | | | | smbd_smb2_request_dispatch() removes unnneccary checks/assignments for compound_related and next_status and duplicate setting of error status. And remove (now) unused next_status from struct smbd_smb2_request. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
* s3:smbd:smb2: add check for session_status for compound requestsMichael Adam2012-09-221-3/+3
|
* s3:smb2_server: do the req->next_status check before the signing checksStefan Metzmacher2012-09-221-15/+15
| | | | | | | | Windows 2012 returns NT_STATUS_INVALID_PARAMETER to the smb2.compound.invalid1 test if that uses signing (instead of NT_STATUS_ACCESS_DENIED). metze
* s3:smb2_server: reset req->last_session_id and req->last_tid after using itStefan Metzmacher2012-09-221-0/+4
| | | | | | | | | | | | | | If we can find a valid session or tcon we'll set it after the lookup, but it need to make sure to reset it if we don't find the session. This fixes a problem where a compound unrelated request between related requests doesn't reset the session. If we have 3 requests in a compound chain, request 3 should never use the id's cached from request 1. It should only every inherit handles from request 2. metze
* s3: Compound requests should continue processing.Ira Cooper2012-09-221-3/+2
| | | | | | This patch addresses #9173. Signed-off-by: Michael Adam <obnox@samba.org>
* s3:smb2_server: fix usage of invalid memory in smb2_signing_check_pdu()Stefan Metzmacher2012-09-201-1/+1
| | | | | | | metze Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Sep 20 07:18:31 CEST 2012 on sn-devel-104
* s3:smb2_break: encrypt OPLOCK BREAK notificationsStefan Metzmacher2012-08-231-13/+80
| | | | | | | metze Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Aug 23 10:01:14 CEST 2012 on sn-devel-104