summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-04-04 00:35:37 -0700
committerDamjan Marion <dmarion@me.com>2019-04-04 10:27:26 +0000
commit1aa35576ec00ba2acc103c444cd8598d7d3b5dbd (patch)
tree5b9dee0044f2c67fb7275d8de278649bf940a3b3 /src/plugins
parent070fd4b046265e7aabe3f9e226e769441db18d79 (diff)
GBP: Counters per-contract
Change-Id: I28bb9e3d3ea3a99a9e24801ef5241a0099186108 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gbp/gbp.api8
-rw-r--r--src/plugins/gbp/gbp_api.c17
-rw-r--r--src/plugins/gbp/gbp_contract.c34
-rw-r--r--src/plugins/gbp/gbp_contract.h16
4 files changed, 62 insertions, 13 deletions
diff --git a/src/plugins/gbp/gbp.api b/src/plugins/gbp/gbp.api
index b55d8a86466..b0b284fcc3e 100644
--- a/src/plugins/gbp/gbp.api
+++ b/src/plugins/gbp/gbp.api
@@ -308,13 +308,19 @@ typedef gbp_contract
vl_api_gbp_rule_t rules[n_rules];
};
-manual_print autoreply define gbp_contract_add_del
+manual_print define gbp_contract_add_del
{
u32 client_index;
u32 context;
u8 is_add;
vl_api_gbp_contract_t contract;
};
+define gbp_contract_add_del_reply
+{
+ u32 context;
+ i32 retval;
+ u32 stats_index;
+};
define gbp_contract_dump
{
diff --git a/src/plugins/gbp/gbp_api.c b/src/plugins/gbp/gbp_api.c
index 76f0b218a19..f6d25dd81a6 100644
--- a/src/plugins/gbp/gbp_api.c
+++ b/src/plugins/gbp/gbp_api.c
@@ -325,12 +325,7 @@ gbp_bridge_domain_flags_from_api (vl_api_gbp_bridge_domain_flags_t a)
if (a & GBP_BD_API_FLAG_DO_NOT_LEARN)
g |= GBP_BD_FLAG_DO_NOT_LEARN;
- if (a & GBP_BD_API_FLAG_UU_FWD_DROP)
- g |= GBP_BD_FLAG_UU_FWD_DROP;
- if (a & GBP_BD_API_FLAG_MCAST_DROP)
- g |= GBP_BD_FLAG_MCAST_DROP;
- if (a & GBP_BD_API_FLAG_UCAST_ARP)
- g |= GBP_BD_FLAG_UCAST_ARP;
+
return (g);
}
@@ -934,6 +929,7 @@ vl_api_gbp_contract_add_del_t_handler (vl_api_gbp_contract_add_del_t * mp)
{
vl_api_gbp_contract_add_del_reply_t *rmp;
u16 *allowed_ethertypes;
+ u32 stats_index;
index_t *rules;
int ii, rv = 0;
u8 n_et;
@@ -962,14 +958,19 @@ vl_api_gbp_contract_add_del_t_handler (vl_api_gbp_contract_add_del_t * mp)
rv = gbp_contract_update (ntohs (mp->contract.sclass),
ntohs (mp->contract.dclass),
ntohl (mp->contract.acl_index),
- rules, allowed_ethertypes);
+ rules, allowed_ethertypes, &stats_index);
}
else
rv = gbp_contract_delete (ntohs (mp->contract.sclass),
ntohs (mp->contract.dclass));
out:
- REPLY_MACRO (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE);
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE,
+ ({
+ rmp->stats_index = htonl (stats_index);
+ }));
+ /* *INDENT-ON* */
}
static int
diff --git a/src/plugins/gbp/gbp_contract.c b/src/plugins/gbp/gbp_contract.c
index e4ac611b16e..552201a684b 100644
--- a/src/plugins/gbp/gbp_contract.c
+++ b/src/plugins/gbp/gbp_contract.c
@@ -40,6 +40,17 @@ gbp_next_hop_t *gbp_next_hop_pool;
#define GBP_CONTRACT_DBG(...) \
vlib_log_notice (gc_logger, __VA_ARGS__);
+/* Adjacency packet/byte counters indexed by adjacency index. */
+vlib_combined_counter_main_t gbp_contract_permit_counters = {
+ .name = "gbp-contracts-permit",
+ .stat_segment_name = "/net/gbp/contract/permit",
+};
+
+vlib_combined_counter_main_t gbp_contract_drop_counters = {
+ .name = "gbp-contracts-drop",
+ .stat_segment_name = "/net/gbp/contract/drop",
+};
+
index_t
gbp_rule_alloc (gbp_rule_action_t action,
gbp_hash_mode_t hash_mode, index_t * nhs)
@@ -435,7 +446,9 @@ gbp_contract_mk_lbs (index_t * guis)
int
gbp_contract_update (sclass_t sclass,
sclass_t dclass,
- u32 acl_index, index_t * rules, u16 * allowed_ethertypes)
+ u32 acl_index,
+ index_t * rules,
+ u16 * allowed_ethertypes, u32 * stats_index)
{
gbp_main_t *gm = &gbp_main;
u32 *acl_vec = NULL;
@@ -471,6 +484,11 @@ gbp_contract_update (sclass_t sclass,
gc->gc_key = key;
gci = gc - gbp_contract_pool;
hash_set (gbp_contract_db.gc_hash, key.as_u32, gci);
+
+ vlib_validate_combined_counter (&gbp_contract_drop_counters, gci);
+ vlib_zero_combined_counter (&gbp_contract_drop_counters, gci);
+ vlib_validate_combined_counter (&gbp_contract_permit_counters, gci);
+ vlib_zero_combined_counter (&gbp_contract_permit_counters, gci);
}
GBP_CONTRACT_DBG ("update: %U", format_gbp_contract, gci);
@@ -489,6 +507,8 @@ gbp_contract_update (sclass_t sclass,
gm->acl_plugin.set_acl_vec_for_context (gc->gc_lc_index, acl_vec);
vec_free (acl_vec);
+ *stats_index = gci;
+
return (0);
}
@@ -539,7 +559,7 @@ gbp_contract_cli (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
sclass_t sclass = SCLASS_INVALID, dclass = SCLASS_INVALID;
- u32 acl_index = ~0;
+ u32 acl_index = ~0, stats_index;
u8 add = 1;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
@@ -565,7 +585,8 @@ gbp_contract_cli (vlib_main_t * vm,
if (add)
{
- gbp_contract_update (sclass, dclass, acl_index, NULL, NULL);
+ gbp_contract_update (sclass, dclass, acl_index,
+ NULL, NULL, &stats_index);
}
else
{
@@ -606,6 +627,7 @@ u8 *
format_gbp_contract (u8 * s, va_list * args)
{
index_t gci = va_arg (*args, index_t);
+ vlib_counter_t counts;
gbp_contract_t *gc;
index_t *gui;
u16 *et;
@@ -627,6 +649,12 @@ format_gbp_contract (u8 * s, va_list * args)
if (0 != host_et)
s = format (s, "0x%x, ", host_et);
}
+
+ vlib_get_combined_counter (&gbp_contract_drop_counters, gci, &counts);
+ s = format (s, "\n drop:[%Ld:%Ld]", counts.packets, counts.bytes);
+ vlib_get_combined_counter (&gbp_contract_permit_counters, gci, &counts);
+ s = format (s, "\n permit:[%Ld:%Ld]", counts.packets, counts.bytes);
+
s = format (s, "]");
return (s);
diff --git a/src/plugins/gbp/gbp_contract.h b/src/plugins/gbp/gbp_contract.h
index dff1b445061..c6e9721848e 100644
--- a/src/plugins/gbp/gbp_contract.h
+++ b/src/plugins/gbp/gbp_contract.h
@@ -18,6 +18,16 @@
#include <plugins/gbp/gbp_types.h>
+#define foreach_gbp_policy_error \
+ _(ALLOW_NO_SCLASS, "allow-no-sclass") \
+ _(ALLOW_INTRA, "allow-intra-sclass") \
+ _(ALLOW_A_BIT, "allow-a-bit-set") \
+ _(ALLOW_CONTRACT, "allow-contract") \
+ _(DROP_CONTRACT, "drop-contract") \
+ _(DROP_ETHER_TYPE, "drop-ether-type") \
+ _(DROP_NO_CONTRACT, "drop-no-contract") \
+ _(DROP_NO_DCLASS, "drop-no-dclass")
+
/**
* The key for an Contract
*/
@@ -141,7 +151,8 @@ typedef struct gbp_contract_db_t_
extern int gbp_contract_update (sclass_t sclass,
sclass_t dclass,
u32 acl_index,
- index_t * rules, u16 * allowed_ethertypes);
+ index_t * rules,
+ u16 * allowed_ethertypes, u32 * stats_index);
extern int gbp_contract_delete (sclass_t sclass, sclass_t dclass);
extern index_t gbp_rule_alloc (gbp_rule_action_t action,
@@ -189,6 +200,9 @@ gbp_rule_get (index_t gui)
return (pool_elt_at_index (gbp_rule_pool, gui));
}
+extern vlib_combined_counter_main_t gbp_contract_permit_counters;
+extern vlib_combined_counter_main_t gbp_contract_drop_counters;
+
#endif
/*