133 Commits

Author SHA1 Message Date
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
Esa Korhonen
4efa9dbeea Remove maxscale/alloc.h
The remaining contents were moved to maxbase/alloc.h.
2019-06-10 14:11:25 +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ä
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ä
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ä
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
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
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ä
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ä
c643f9bc8d
Merge branch '2.3' into develop 2019-04-12 13:23:49 +03:00
Markus Mäkelä
05515cca16
MXS-2259: Limit size of client reads
Given the assumption that queries are rarely 16MB long and that
realistically the only time that happens is during a large dump of data,
we can limit the size of a single read to at most one MariaDB/MySQL packet
at a time. This change allows the network throttling to engage a lot
sooner and reduces the maximum overshoot of throtting to 16MB.
2019-04-05 22:48:16 +03:00
Markus Mäkelä
db97c3343d
MXS-1951: Move worker selection into Listener
The worker to which the client DCB is assigned to is now chosen by the
Listener. This makes the protocol code simpler which is always a good
thing.
2019-03-28 16:34:12 +02:00
Esa Korhonen
2f634264dc Merge branch '2.3' into develop 2019-03-22 13:39:52 +02:00
Esa Korhonen
fadbdc7514 Merge branch '2.2' into 2.3 2019-03-22 12:11:24 +02:00
Esa Korhonen
9236ace077 MXS-2355 If client is using the wrong authenticator, attempt a switch
Some SQL clients may default to a different authentication plugin than
"mysql_native_password". Since this is the only one supported by MySQL-
authenticator, the client is instructed to swap its plugin.
2019-03-21 17:07:09 +02:00
Markus Mäkelä
1c3a5bda83
Merge branch '2.3' into develop 2019-03-11 12:29:56 +02:00
Markus Mäkelä
5c5c6630bf
Fix retain_last_statements
If multiple statements were stored in a single buffer only one of them
would get registered.
2019-03-08 14:45:18 +02:00
Markus Mäkelä
ebbb8a771c
Merge branch '2.3' into develop 2019-01-17 10:55:27 +02:00
Markus Mäkelä
a469ef83b6
MXS-2217: Pick DCB owner before adding to epoll
There is a race condition between the addition of the DCB into epoll and
the execution of the event that initiates the protocol pointer for the DCB
and sends the handshake to the client. If a hangup event would occur
before the handshake would be sent, it would be possible that the DCB
would get freed before the code that sends the handshake is executed.

By picking the worker who owns the DCB before the DCB is placed into the
owner's epoll instance, we make sure no events arrive on the DCB while the
control is transferred from the accepting worker to the owning
worker.
2019-01-17 10:35:49 +02:00
Esa Korhonen
d4674faa7d Convert maxscale/query_classifier.h to .hh
The header was not merged with queryclassifier.hh since the latter
does not include the former.
2019-01-15 18:18:39 +02:00
Esa Korhonen
45bfbbdd9e Convert maxscale/protocol.h to .hh 2019-01-15 17:26:26 +02:00
Esa Korhonen
b0663f0b29 Convert maxscale/ssl.h to .hh 2019-01-15 17:12:32 +02:00
Esa Korhonen
684ec3288b Rename and cleanup authenticator.h 2019-01-14 15:07:33 +02:00
Markus Mäkelä
f0f9c21d1c
Merge branch '2.3' into develop 2019-01-07 10:54:42 +02:00
Esa Korhonen
09aa54720d MXS-2220 Read server version using public methods
Version related fields have been removed from the public class.
2019-01-03 11:23:14 +02:00
Markus Mäkelä
26da72a41f
Merge branch '2.2' into 2.3 2019-01-03 09:23:16 +02:00
Markus Mäkelä
8f0e4a3034
MXS-2232: Fix version string prefix check
The prefix was always added even when the original version would've been
acceptable. For example, a version string of 5.5.40 would get converted to
5.5.5-5.5.40 which is quite confusing for older client applications.
2019-01-02 19:29:48 +02:00
Markus Mäkelä
04dd05b262
MXS-2231: Move TLS handshake code into MariaDBClient
The code is now in the correct place and TLS connections with all
authenticators should now work.
2019-01-02 19:29:41 +02:00
Markus Mäkelä
20fe9b9dca
MXS-2196: Rename session states
Minor renaming of the session state enum values. Also exposed the session
state stringification function in the public header and removed the
stringification macro.
2018-12-13 13:27:45 +02:00
Johan Wikman
c0c9a9858d MXS-2197 Rename maxscale/log.h to maxscale/log.hh
In files either include maxscale/log.hh or remove include entirelly
as maxscale/ccdefs.hh includes it.
2018-12-10 12:58:17 +02:00
Markus Mäkelä
77477d9648
MXS-2196: Rename dcb_role_t to DCB::Role 2018-12-05 15:30:44 +02:00
Esa Korhonen
9f721f725e MXS-2205 Convert maxscale/protocol/mysql.h to .hh 2018-12-05 11:12:20 +02:00
Esa Korhonen
d96a7dedc5 MXS-2205 Convert maxscale/poll.h to .hh 2018-12-04 14:51:02 +02:00
Markus Mäkelä
43c33e9f4a
MXS-2196: Allocate a session before allocating DCBs
Allocating the session before a DCB guarantees that at no point will a DCB
have a null session. This further clarifies the concept of the session and
also allows the listener reference to be moved there.

Ideally, the session itself would allocate and assign the client DCB but
since the Listener is the only one who does it, it's acceptable for now.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
692127a2cb
MXS-2196: Remove the dummy session
As each connection now immediately gets a session the dummy session is no
longer required. The next step would be to combine parts of the session
and the client DCB into one entity. This would prevent the possibility of
a client DCB with no associated session. Backend DCBs are different as
they can move from one session to another when the persistent connection
pool is in use.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
da9816b7e7
MXS-2196: Always allocate a session
Whenever a client DCB is accepted, a session for it is allocated. This
simplifies the handling of shared data between DCBs by allowing it to be
placed inside the session object. Currently, the data is stashed away in
the client DCB.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
3791fdded7
MXS-2196: Pass client DCB to MXS_PROTOCOL::accept
By doing the actual accepting of the new DCB in the core, the protocol
modules can only do the actual protocol level work. This removes some of
the redundant code that was in the protocol modules.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
e46104c32a
MXS-2196: Use Listener in MXS_PROTOCOL::accept 2018-12-04 11:50:43 +02:00
Markus Mäkelä
7a87ff9ce1
MXS-2196: Remove redundant DCB member variables
The variables held duplicate information already present in other parts of
the system.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
694d4a4003
MXS-2196: Make DCB a C++ struct
Allocating DCB with new allows the use of C++ objects in the DCB
struct. Also the explicit poll field can be replaced by inheriting from
MXB_POLL_DATA.
2018-12-04 11:50:43 +02:00