Updated the diagnostic to print rules, their types and how many times they have been matched.
This commit is contained in:
@ -108,7 +108,7 @@ static FILTER_OBJECT MyObject = {
|
|||||||
* Rule types
|
* Rule types
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RT_UNDEFINED,
|
RT_UNDEFINED = 0x00,
|
||||||
RT_COLUMN,
|
RT_COLUMN,
|
||||||
RT_THROTTLE,
|
RT_THROTTLE,
|
||||||
RT_PERMISSION,
|
RT_PERMISSION,
|
||||||
@ -117,6 +117,17 @@ typedef enum {
|
|||||||
RT_CLAUSE
|
RT_CLAUSE
|
||||||
}ruletype_t;
|
}ruletype_t;
|
||||||
|
|
||||||
|
const char* rule_names[] = {
|
||||||
|
"RT_UNDEFINED",
|
||||||
|
"RT_COLUMN",
|
||||||
|
"RT_THROTTLE",
|
||||||
|
"RT_PERMISSION",
|
||||||
|
"RT_WILDCARD",
|
||||||
|
"RT_REGEX",
|
||||||
|
"RT_CLAUSE"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linked list of strings.
|
* Linked list of strings.
|
||||||
*/
|
*/
|
||||||
@ -155,6 +166,7 @@ typedef struct rule_t{
|
|||||||
ruletype_t type;
|
ruletype_t type;
|
||||||
skygw_query_op_t on_queries;
|
skygw_query_op_t on_queries;
|
||||||
bool allow;
|
bool allow;
|
||||||
|
int times_matched;
|
||||||
TIMERANGE* active;
|
TIMERANGE* active;
|
||||||
}RULE;
|
}RULE;
|
||||||
|
|
||||||
@ -1385,6 +1397,11 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue
|
|||||||
if(msg){
|
if(msg){
|
||||||
my_session->errmsg = msg;
|
my_session->errmsg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(matches){
|
||||||
|
rulelist->rule->times_matched++;
|
||||||
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,9 +1605,29 @@ static void
|
|||||||
diagnostic(FILTER *instance, void *fsession, DCB *dcb)
|
diagnostic(FILTER *instance, void *fsession, DCB *dcb)
|
||||||
{
|
{
|
||||||
FW_INSTANCE *my_instance = (FW_INSTANCE *)instance;
|
FW_INSTANCE *my_instance = (FW_INSTANCE *)instance;
|
||||||
|
RULELIST* rules;
|
||||||
|
int type;
|
||||||
|
|
||||||
if (my_instance)
|
if (my_instance)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "\t\tFirewall Filter\n");
|
spinlock_acquire(my_instance->lock);
|
||||||
|
rules = my_instance->rules;
|
||||||
|
|
||||||
|
dcb_printf(dcb, "Firewall Filter\n");
|
||||||
|
dcb_printf(dcb, "%-24s%-24s%-24s\n","Rule","Type","Times Matched");
|
||||||
|
while(rules){
|
||||||
|
if((int)rules->rule->type > 0 &&
|
||||||
|
(int)rules->rule->type < sizeof(rule_names)/sizeof(char**)){
|
||||||
|
type = (int)rules->rule->type;
|
||||||
|
}else{
|
||||||
|
type = 0;
|
||||||
|
}
|
||||||
|
dcb_printf(dcb,"%-24s%-24s%-24d\n",
|
||||||
|
rules->rule->name,
|
||||||
|
rule_names[type],
|
||||||
|
rules->rule->times_matched);
|
||||||
|
rules = rules->next;
|
||||||
|
}
|
||||||
|
spinlock_release(my_instance->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user