6552 Commits

Author SHA1 Message Date
Markus Mäkelä
f156b1e4ee Add minimum and maximum values for integer parameters
The defined integer values can be used to give a default value the maximum
for its type.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
11ab4575c3 Use module parameters in ccrfilter and luafilter
The ccrfilter and luafilter now use the module parameters.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
180ed1616a Add configuration test
The test validates, parses and creates configuration parameters for
modules.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
56ecdc219b Refactor config.c functions for testing
To test the configuration validation and default value generation, the
functions needed to be refactored to allow parameters to be passed
directly to the function.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
eef0619865 Add default parameters to created monitors
When a monitor is created at runtime, it also needs to have the default
parameters. Ideally, this would be done when the monitor is allocated but
because of the way the configuration is processed, we need to do it after
user defined parameters are added.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
72ea3ad453 Fix improper use of monitorStart
Some uses of monitorStart didn't pass the monitor parameters to the
function call. This caused runtime configuration of monitors to not have
any parameters as they never got their parameters.
2017-01-09 14:17:33 +02:00
Johan Wikman
75c257327e Fix G++ 4.4 issue
G++ 4.4 on CentOS6 seems to get confused by direct inheritance
from templates. Worked around by introducing typedef.
2017-01-09 13:17:49 +02:00
MassimilianoPinto
7c13b56e74 Fix compilation error on CentOS6
Fix compilation error on CentOS6
2017-01-09 12:07:18 +01:00
Johan Wikman
c3ddc3ac22 Cleanup server.h
- All (but the printing/debug functions) are now in snake_case.
- Functions made const correct.
- All function prototypes now have named arguments.

Documentation still to be moved, and file possibly split into
include/mascale/server.h and server/core/maxscale/server.h
2017-01-09 12:14:46 +02:00
Esa Korhonen
1b8742781b MXS-804 Handle hosts of form ip/netmask
Previously, these were discarded. This patch adds a function to
"merge" the mask to the ip so that it's in the form which
normalize_hostname expects (using % as wildcard). Only simple masks
with 255:s and 0:s are accepted. Any other combinations may leave
the hostname in a garbled state which will cause it to be discarded
later.
2017-01-09 10:05:35 +02:00
Johan Wikman
9ba06f7c07 Fix merge issues 2017-01-09 09:37:11 +02:00
Johan Wikman
e7981c9d67 Masking: Handle NULL values properly 2017-01-09 09:26:43 +02:00
Johan Wikman
8127454f24 Masking: Add possibility to reload rules 2017-01-09 09:26:43 +02:00
Johan Wikman
ad4cc7bbac Masking: Add matching and rewriting functionality
This change now ties the pieces together and implements tha
functionality required of the masking filter. Note thought that
this is still work in progress and changes will follow.
2017-01-09 09:25:26 +02:00
Johan Wikman
224d0bcb35 Masking: Add proper rule matching and data rewriting 2017-01-09 09:25:26 +02:00
Johan Wikman
f74d267766 Add helper classes for MySQL protocol handling
- LEncInt     : Class for dealing with length encoded integers
- LEncString  : Class for dealing with length encoded strings
- ComPacket   : Base-class for all packet classes.
- ComRequest  : Base-class for all requests.
- ComResponse : Base-class for all responses.
- ComQueryResponse
- ComQueryResponse::ColumnDef
- ComQueryResponse::Row

Common to these all is that they are very thin, and basically only
make it easier to what anyway needs to be done, if the equivalent
is used by directly accessing the packet buffer.

Now these are private for the masking filter, but may be moved under
masxcale/include if/when the general usefulness has been established.
2017-01-09 09:25:26 +02:00
Johan Wikman
c25c0d688b Masking: Add startup handling to masking filter
- Process parameters
- Create config
- Load rules
2017-01-09 09:25:26 +02:00
Johan Wikman
171eb3f690 Provide backdoor to Buffer::iterator 2017-01-09 09:19:59 +02:00
Johan Wikman
dc87663c95 Masking: Add MaskingRules
MXS-910: Initial implementation of rule handling, now only the
parsing of JSON file and the building of corresponding objects.
Rudimentary testing.
2017-01-09 09:19:59 +02:00
Johan Wikman
0b4c379539 Add Closer, partial RAII class
Closer is a template using which C-style resources can be managed
in a C++ context where exceptions can occur. By placing a C resource
in a Closer instance, it is certain the resource will be freed when
the closing scope is exited irrespective of whether that occurs due
to the normal control flow, due to a return statement or an exception
having been thrown.

To be used with Closer, the CloserTraits template must be specialized
for the type in question. With this change specializations are provided
for FILE*, json_t*, pcre_code* and pcre2_match_data*.
2017-01-09 09:19:59 +02:00
Johan Wikman
482fbe6400 qc: Implement qc_get_function_info for qc_mysqlembedded
MXS-1070

Now both qc_mysqlembedded and qc_sqlite return the same stuff
for the same statement, and both include also operators in
addition to pure functions. Whether that is the right approach,
is still subject to debate.

However, if we want to make it possible to disable e.g. the
use of concat as in "select concat(a) from t", where a is a string,
to prevent the bypassing of the masking filter, then conceptually
it should be possible to prevent "select a+0 from t", where a is an
int, as well.
2017-01-09 09:17:38 +02:00
Johan Wikman
0d561df880 QC: Implement qc_get_function_info for qc_sqlite 2017-01-09 09:17:38 +02:00
Johan Wikman
d078f56dc5 qc: Reveal function usage
MXS-1070

Just interface changes. Implementation follow in separate changes.
2017-01-09 09:17:38 +02:00
Johan Wikman
2d849e0ab2 Remove MySQL dependency from gateway.cc
The MySQL initialization is now performed by the MySQLClient module.
2017-01-09 09:16:35 +02:00
Johan Wikman
8fc5bdc2f1 Perform query classifier initialization implicitly
The setting up and the initialization of the query classifier has
now been separated. The gateway explicitly sets up the query
classifier (i.e. chooses which one to use and what arguments to
provide), but the actual initialization is performed as part of
the general module initialization.
2017-01-09 09:16:35 +02:00
Johan Wikman
530c0e9617 QC: Setup and initialization separated
This is in preparation for using the general process/thread
initialization mechanism.
2017-01-09 09:16:35 +02:00
Markus Mäkelä
a0181133fe Only install /var/lib/maxscale for core package
All RPM packages tried to install the /var/lib/maxscale directory when
they shouldn't have.
2017-01-05 22:42:56 +02:00
Markus Mäkelä
915eeabe25 Use module parameters for cache filter
The cache filter now uses the module parameters. Due to the relative path
support for the `rules` parameter, it is still manually parsed.

The `storage_options` list is also manually parsed. The core could
possible parse simple comma separated lists and return them as a string
array. This should be done in a later commit.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
6a64de649b Increate parameter limit to 64
Modules can now declare up to 64 parameters.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
2611f9a701 Give parameters as CONFIG_PARAMETER for FILTER::createInstance
The filters should use the same configuration parameters as other modules
use. This allows them to use the common configuration management functions
to get values from it.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
e75cdb2ceb Use module parameters in schemarouter
The schemarouter now accepts all router_options values as parameters.

Also fixed a mistake in the documentation where the router options section
was listed twice.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
34a8694b34 Use module parameters for readwritesplit
The parameters that readwritesplit uses now use the new system. This
removes the need for the qualified parameter processing found in config.c.

All values for router_options are now also accepted as parameters. The
router_options is deprecated and support for it will be removed in a
future version.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
f1fa982dc6 Remove qualified configuration parameters
The parameters were only used by readwritesplit. These can be substituted
with the new module parameters.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
ae31e3b0b5 Only add default value if none is provided
The default parameter values should only be added if the configuration
doesn't have that parameter.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
9fa2de29d9 Return enum values as integers instead of strings
If the enums are converted to the acutual enum values before they are
returned, this removes the need for the modules to process the enum
strings to enum values. This allows modules to use enumerations with
minimal effort.
2017-01-05 19:51:22 +02:00
Johan Wikman
03391748ee Call [process|thread] [init|finish] functions of modules
The process initialization function was also renamed from init to
process_init.
2017-01-05 16:17:50 +02:00
Johan Wikman
a2a38f952a Add [process|thread] [init|finish] functions to modules
The MXS_MODULDE object now contains optinal pointers for functions
to be called att process and thread startup and shutdown. Since the
functions were added to the end, strictly speaking, all structures
would not have needed to have been modified, but better to be
explicit. In a subsequent change, these will be called.

C++ does not support flexible arrays, so for the time being C++
modules are restricted to 10 parameters. Better approach is to
factor out the parameters to a separate array and then just store
a pointer to that array in MXS_MODULE.
2017-01-05 14:44:02 +02:00
Johan Wikman
6a695c9407 Provide access to modules
With the provided functions it is possible to iterate over all loaded
modules or over all modules of a specific type.
2017-01-05 14:37:01 +02:00
Johan Wikman
2abe956056 Rename GWPROTOCOL to MXS_PROTOCOL 2017-01-05 14:36:44 +02:00
Johan Wikman
19ce28a43a Rename gw_protocol.h to protocol.h 2017-01-05 14:36:44 +02:00
Markus Mäkelä
1c8a4b13b9 Name variables the same way as the parameters
The variables now use the actual option and parameter names. This should
help make the code more readable and easier to understand in relation to
the used options.
2017-01-05 14:18:56 +02:00
Markus Mäkelä
410ba7726e Copy avrorouter options to parameters
The avrorouter router_options values can now also be defined as
parameters. This should make the configuration definition a lot cleaner.
2017-01-05 10:50:02 +02:00
Markus Mäkelä
257cb5c209 Add path and service module parameter types
The path type is validated if the module requested path
validation. Service checks can be done both on startup and at
runtime. This allows dynamic changes to module parameters to be validated
without a configuration context.
2017-01-05 10:48:58 +02:00
Markus Mäkelä
e0ad6188ad Add module parameter options
The options allow the modules to impose type specific restrictions on the
parameters. This can be used to offload file permission and mandatory
parameter checks to the core.
2017-01-05 10:48:58 +02:00
Markus Mäkelä
2b50ce6548 Create defines for default directories
This allows the default directories to be used in initializers where
constant expressions are required.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
4c008844ca Always include maxscale/cdefs.h first
Two headers didn't include the file.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
2e074f4eb4 Introduce common SQLite header
The header declares the missing v2 handle closing function for older
versions of SQLite.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
5a290cb0b8 Use module parameters in monitors
All monitors now declare the parameters that they use. This allows the
core to check the validity of the parameters before they are passed to the
monitor. It also simplifies the processing of the parameters as they are
guaranteed to be valid.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
cefc253e2c Check configuration with declared parameters
The declared parameters are now used to check whether the configuration is
valid. As the filters and monitors don't use the new declarations, the
code needs to be commented out. Once the parameter processing has been
migrated to the new system, the code can be enabled.
2017-01-05 09:58:10 +02:00
Markus Mäkelä
f7c6accaa0 Load default configuration values for modules
Filters, monitors and routers can now declare parameters and those
parameters will always be present. Currently, this removes the need to
parse simple values like booleans and integers.

Some of the more common parameter types could be added in the future
e.g. paths to files.
2017-01-05 09:58:10 +02:00