490 Commits

Author SHA1 Message Date
Niclas Antti
f5615cc174 MXS-2555 Add support for unix sockets to LocalClient 2019-06-19 15:31:34 +03:00
Niclas Antti
2343326ecc MXS-2555 Add execute_kill version, that kills all but a given mysql_thread_id
NOTE: This does not work whit unix scokets. The reason is that LocalClient
assumes network sockets. TODO: to add unix socket support.
2019-06-19 15:31:34 +03:00
Niclas Antti
56e5c417c1 MXS-2555 uncrustify mysql_common.cc, and a minor bug fix in smartrouter.cc 2019-06-19 15:31:34 +03:00
Markus Mäkelä
7dde0edb54
Clean up unexpected error handling in readwritesplit
By using the Error class, the code can be cleaned up and simplified.
2019-06-14 15:18:01 +03:00
Markus Mäkelä
c819271cab
Merge branch '2.3' into develop 2019-06-14 09:40:19 +03:00
Markus Mäkelä
2accfad329
Handle trailing unexpected ERR packets
RWBackend did not expect that a resultset and an unexpected ERR packet
could be stored in the same buffer. This can happen for example if a
server shuts down immediately after the resultset is sent.
2019-06-14 08:12:02 +03:00
Markus Mäkelä
8311dba654
Send the OK outside the KILL functions
By sending the OK for the KILL commands outside the function, they can be
used to kill connections that do not expect responses.
2019-06-13 16:44:26 +03:00
Markus Mäkelä
1f46f1bfca
Merge branch '2.3' into develop 2019-06-12 12:24:07 +03:00
Markus Mäkelä
bb92d61a1b
Fix KILL command packet boundary detection
If a packet with a KILL query was followed with another packet in the same
network buffer, the code wouldn't work as it expected to receive only one
packet at a time.
2019-06-12 12:20:26 +03:00
Johan Wikman
a2b046a482 MXS-2512 Use typenames consistently 2019-06-11 09:44:27 +03:00
Johan Wikman
b09a4e676d MXS-2512 Do not recalculate information that exists
As the end of the error packet is known, it is better to pass
around an iterator to that instead of recalculating it.
2019-06-11 09:44:27 +03:00
Johan Wikman
b222a17ed9 MXS-2512 Update error information in additional place
An error may be returned directly or as part of a result set.
Both cases must be handled.
2019-06-11 09:44:27 +03:00
Johan Wikman
aa9b6cb8c5 MXS-2512 Store received error during backend processing
If a server returns an error, it will be retained inside RWBackend
so that it later is accessible without having to parse the GWBUF
again.
2019-06-11 09:44:27 +03:00
Esa Korhonen
4efa9dbeea Remove maxscale/alloc.h
The remaining contents were moved to maxbase/alloc.h.
2019-06-10 14:11:25 +03:00
Esa Korhonen
655e5fab5b Move length-encoded integer/string functions to maxsql 2019-06-07 11:32:46 +03:00
Markus Mäkelä
44d1b821c3
Merge branch '2.3' into develop 2019-06-03 13:54:55 +03:00
Markus Mäkelä
c219187a1e
Merge branch '2.2' into 2.3 2019-06-03 13:27:57 +03:00
Markus Mäkelä
d68f66fede
MXS-2538: Send master charset in the handshake packet
By iterating over the servers and sending the master's charset we are
guaranteed a "known good" charset. This also solves the problem where a
deactivated server reference would be used as the charset and server
version source.
2019-05-31 23:01:18 +03:00
Markus Mäkelä
e9c652555d
MXS-2538: Fix hang on unknown KILL
Unknown KILL commands are now forwarded as-is to the routers.
2019-05-31 14:01:16 +03:00
Markus Mäkelä
3af66f3309
MXS-2483: Take SSLProvider into use
Servers and listeners now have a SSLProvider member variable that is used
for all SSL related tasks.
2019-05-24 15:33:17 +03:00
Markus Mäkelä
8a4b58d52c
MXS-2483: Move SSL configuration into SSLConfig
This way the configuration information can be accessed without the
SSLContext.
2019-05-24 15:33:17 +03:00
Markus Mäkelä
5b55864b06
MXS-2483: Store listener SSLContext in unique_ptr
Also removed some unnecessary checks for session->listener: The Session
constructor takes the listener as an argument.
2019-05-24 10:05:43 +03:00
Markus Mäkelä
3b8e28392e
MXS-2483: Make server SSL private
The old server_ssl member is now renamed and private. The ssl_context and
set_ssl_context methods provide access to it.
2019-05-24 10:05:42 +03:00
Markus Mäkelä
7eff7f8e9e
Remove unused function in mysql_common.cc 2019-05-24 10:05:15 +03:00
Markus Mäkelä
397fc97d07
Only count actual failures as auth failures
If the authentication process fails due to an inability to start a
session, it should not be counted towards the number of failed
authentication attempts.
2019-05-24 10:05:15 +03:00
Markus Mäkelä
0c19d1ea03
Fix debug assertion in mysql_backend
The backend read function used a NULL GWBUF with gwbuf_length.
2019-05-21 13:15:20 +03:00
Markus Mäkelä
76399200f4
Fix assertion on client SSL read
When SSL is enabled, the protocol seems to get zero byte reads which
result in a null GWBUF being passed to gwbuf_length.
2019-05-20 15:46:52 +03:00
Markus Mäkelä
1197bd40db
MXS-2483: Move unwanted SSL code to mysql_client.cc
The code was only used by mysql_client.cc and should therefore be located
in it.
2019-05-20 15:45:18 +03:00
Johan Wikman
0f714e9ad4 MXS-2495 Cleanup GWBUF interface
All GWBUF macros that address a single link in a chain are now
simple wrappers for equivalent gwbuf_link-functions.

Next step is to drop the macros and replace their use with calls
to the functions.
2019-05-20 09:57:37 +03:00
Johan Wikman
4ed8726ccf Fix merge bug 2019-05-14 14:01:16 +03:00
Johan Wikman
c09617cd82 Merge branch '2.3' into develop 2019-05-14 12:33:50 +03:00
Marko
22a9e20f1f MXS-1957 Change the default authenticators to MariaDB aliases
Using MySQLAuth or MySQLBackendAuth causes warning to be logged.
2019-05-13 15:35:09 +03:00
Marko
50fef6f361 MXS-1957 Add MariaDBAuth alias 2019-05-13 15:35:09 +03:00
Esa Korhonen
a3bb61486d Move server_set_status and server_clear_status to monitor
The operation goes through monitor code so should be in the according file.
2019-05-10 14:37:35 +03:00
Markus Mäkelä
b10fc196a1
Fix maxinfo/maxadmin debug assertion
Both services could write to a DCB from a worker that doesn't own it.
2019-05-10 11:23:10 +03:00
Markus Mäkelä
6625c1296b
Format authenticator and protocol modules 2019-05-10 10:31:12 +03:00
Markus Mäkelä
0e0342e657
Merge branch '2.3' into develop 2019-05-08 10:38:39 +03:00
Markus Mäkelä
a652b6bd5b
Add advance(int) to mxs::Buffer iterators
This makes iterating over packets in buffers faster while still
maintaining the requirements for forward iterators. Not using operator+=
makes it clear that this is not a random access iterator.
2019-05-08 10:33:27 +03:00
Markus Mäkelä
6caa8e55b0
MXS-2414: Send error when host is blocked
If a connection attempt is not accepted due to the host being blocked, the
protocol can now return an error message that is sent to the client. Only
mariadb_client implements this as it is the only one who calls the auth
failure methods in the first place.
2019-04-30 14:49:35 +03:00
Markus Mäkelä
cf86b0cb7e
MXS-2414: Prototype connection attempt throttling
The RateLimit class stores authentication failure data mapped by the
client IP addresses. The authentication failures are limited
per thread. The limits are still hard-coded and at least the number of
failures should be made configurable.

The simplest, most maintainable and acceptably efficient implementation
for DDoS protection is a thread-local unordered_map. The unwanted
side-effect of "scaling" of the number of allowed authentication failures
is unlikely to be problematic in most use-cases.

As the blocking of a host is only temporary, the behavior differs from the
one in the MariaDB server. This allows the number of failures to be set to
a much lower value negating some of the problems caused by the relatively
simple implementation.
2019-04-30 14:49:35 +03:00
Markus Mäkelä
4186f39616
Merge branch '2.3' into develop 2019-04-23 12:11:09 +03:00
Markus Mäkelä
24fc82e160
Move large query processing inside RWBackend
The knowledge of which function to call can be internal to RWBackend. This
make the use of the class easier as one can simply write to the backend.
2019-04-18 13:58:34 +03:00
Markus Mäkelä
03dc969cf2
Fix use-after-free in LocalClient
If the DCB was closed before the handshake for the LocalCliet connection
was received, the gw_decode_mysql_server_handshake would use the closed
DCB to log the connection ID. Clearing out the pointer prevents it.
2019-04-17 16:33:27 +03:00
Markus Mäkelä
d3bfe0a712
Fix handling of large result packets
The RWBackend didn't know to skip the tail end of large packets.
2019-04-17 11:16:16 +03:00
Markus Mäkelä
70450ce881
MXS-2349: Add support for UNIX domain sockets
Added core functionality for UNIX domain sockets in servers. Currently the
address parameter accepts them both but a separate `socket` parameter is
needed.
2019-04-16 11:52:37 +03:00
Markus Mäkelä
21b4cc3944
Merge branch '2.3' into develop 2019-04-15 15:13:50 +03:00
Markus Mäkelä
bd54efbb3f
Fix skip_encoded_int
A single byte integer wasn't skipped.
2019-04-15 12:18:30 +03:00
Markus Mäkelä
f6bd9fefa4
Move assertion after error message
Logging the internal state before the assertion makes it easier to figure
out why the assertion failed in the first place.
2019-04-15 12:07:48 +03:00
Markus Mäkelä
b3399dccc4
Remove useless templates from RWBackend functions
There's no need for templates as the code is only used with one
type. Changed the code to use std::advance as that might avoid a copy of
the iterator.
2019-04-12 16:31:43 +03:00
Markus Mäkelä
c643f9bc8d
Merge branch '2.3' into develop 2019-04-12 13:23:49 +03:00