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);
}
{
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;
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
#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)
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;
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);
gm->acl_plugin.set_acl_vec_for_context (gc->gc_lc_index, acl_vec);
vec_free (acl_vec);
+ *stats_index = gci;
+
return (0);
}
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)
if (add)
{
- gbp_contract_update (sclass, dclass, acl_index, NULL, NULL);
+ gbp_contract_update (sclass, dclass, acl_index,
+ NULL, NULL, &stats_index);
}
else
{
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;
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);
#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
*/
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,
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
/*