28 #define _(sym,string) string, 47 #define GBP_CONTRACT_DBG(...) \ 48 vlib_log_notice (gc_logger, __VA_ARGS__); 52 .
name =
"gbp-contracts-permit",
53 .stat_segment_name =
"/net/gbp/contract/permit",
57 .
name =
"gbp-contracts-drop",
58 .stat_segment_name =
"/net/gbp/contract/drop",
73 return (gu - gbp_rule_pool);
101 return (gnh - gbp_next_hop_pool);
162 s =
format (s,
"%U, %U, %U EP:%d",
177 #define _(v,a) case GBP_RULE_##v: return (format (s, "%s", a)); 182 return (
format (s,
"unknown"));
192 #define _(v,a) case GBP_HASH_MODE_##v: return (format (s, "%s", a)); 197 return (
format (s,
"unknown"));
207 #define _(v,a) case GBP_POLICY_NODE_##v: return (format (s, "%s", a)); 212 return (
format (s,
"unknown"));
229 case GBP_RULE_PERMIT:
232 case GBP_RULE_REDIRECT:
252 &gu->
gu_dpo[pnode][fproto], 8);
268 old_ai = gnh->
gnh_ai[fproto];
274 gnh - gbp_next_hop_pool);
279 ETHERNET_TYPE_IP4 : ETHERNET_TYPE_IP6));
297 switch (gu_hash_mode)
299 case GBP_HASH_MODE_SRC_IP:
301 case GBP_HASH_MODE_DST_IP:
303 case GBP_HASH_MODE_SYMMETRIC:
321 u32 policy_nodes[] = {
354 dproto, gnh->
gnh_ai[fproto]);
488 gm->
acl_plugin.register_user_module (
"GBP ACL",
"src-epg",
"dst-epg");
561 return (VNET_API_ERROR_NO_SUCH_ENTRY);
592 else if (
unformat (input,
"scope %d", &scope))
594 else if (
unformat (input,
"sclass %d", &sclass))
596 else if (
unformat (input,
"dclass %d", &dclass))
598 else if (
unformat (input,
"acl-index %d", &acl_index))
632 .path =
"gbp contract",
634 "gbp contract [del] src-epg <ID> dst-epg <ID> acl-index <ACL>",
660 s =
format (s,
"[%d] %U: acl-index:%d",
663 s =
format (s,
"\n rules:");
669 s =
format (s,
"\n allowed-ethertypes:");
673 int host_et = clib_net_to_host_u16 (*et);
675 s =
format (s,
"0x%x, ", host_et);
679 s =
format (s,
"\n stats:");
702 if (
unformat (input,
"src %d", &src))
704 else if (
unformat (input,
"dst %d", &dst))
750 .path =
"show gbp contract",
751 .short_help =
"show gbp contract [src <SRC>] [dst <DST>]\n",
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
static clib_error_t * gbp_contract_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u16 * gc_allowed_ethertypes
An ethertype whitelist.
void dpo_stack_from_node(u32 child_node_index, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child parent relationship.
static int gbp_contract_next_hop_resolve(index_t gui, index_t gnhi)
#define IP_FLOW_HASH_SYMMETRIC
static void gbp_contract_rules_free(index_t *rules)
#define vec_foreach_index(var, v)
Iterate over vector indices.
u32 gb_uu_fwd_sw_if_index
The BD's MAC spine-proxy interface (optional)
void gbp_route_domain_unlock(index_t index)
#define hash_set(h, key, value)
static gbp_endpoint_t * gbp_endpoint_get(index_t gbpei)
Get the endpoint from a port/interface.
A Group Based Policy Endpoint.
fib_node_index_t path_index
The index of the FIB path.
gbp_contract_key_t gc_key
source and destination EPGs
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
const mac_address_t * gbp_route_domain_get_local_mac(void)
gbp_next_hop_t * gbp_next_hop_pool
#define hash_unset(h, key)
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
static fib_node_t * gbp_next_hop_get_node(fib_node_index_t index)
static void gbp_contract_mk_lb(index_t gui, fib_protocol_t fproto)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
#define pool_foreach(VAR, POOL)
Iterate through pool.
gbp_contract_t * gbp_contract_pool
void fib_node_init(fib_node_t *node, fib_node_type_t type)
static int dpo_id_is_valid(const dpo_id_t *dpoi)
Return true if the DPO object is valid, i.e.
vlib_log_class_t gc_logger
gbp_contract_db_t gbp_contract_db
Single contract DB instance.
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
A bridge Domain Representation.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Combined counter to hold both packets and byte differences.
static_always_inline void mac_address_copy(mac_address_t *dst, const mac_address_t *src)
static clib_error_t * gbp_contract_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_registration_t gbp_policy_port_node
(constructor) VLIB_REGISTER_NODE (gbp_policy_port_node)
char * gbp_contract_error_strings[]
EPG src,dst pair to ACL mapping table, aka contract DB.
static gbp_rule_t * gbp_rule_get(index_t gui)
static gbp_bridge_domain_t * gbp_bridge_domain_get(index_t i)
u8 * format_gbp_rule_action(u8 *s, va_list *args)
adj_index_t adj_nbr_add_or_lock_w_rewrite(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index, u8 *rewrite)
Add (and lock) a new or lock an existing neighbour adjacency.
fib_node_type_t fib_node_register_new_type(const fib_node_vft_t *vft)
Create a new FIB node type and Register the function table for it.
static u8 * format_gbp_next_hop(u8 *s, va_list *args)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
u32 gbp_itf_get_sw_if_index(gbp_itf_hdl_t hdl)
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
void gbp_bridge_domain_unlock(index_t gbdi)
static_always_inline void mac_address_to_bytes(const mac_address_t *mac, u8 *bytes)
#define VLIB_INIT_FUNCTION(x)
description fragment has unexpected format
#define clib_error_return(e, args...)
void load_balance_multipath_update(const dpo_id_t *dpo, const load_balance_path_t *raw_nhs, load_balance_flags_t flags)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
uword * gc_hash
We can form a u64 key from the pair, so use a simple hash table.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
static_always_inline void ip46_address_copy(ip46_address_t *dst, const ip46_address_t *src)
counter_t packets
packet counter
static void gbp_contract_resolve(index_t *guis)
#define IP_FLOW_HASH_DST_ADDR
index_t * gc_rules
The ACL to apply for packets from the source to the destination EPG.
int gbp_contract_delete(gbp_scope_t scope, sclass_t sclass, sclass_t dclass)
sclass_t gck_src
source and destination EPGs for which the ACL applies
load-balancing over a choice of [un]equal cost paths
static void gbp_contract_mk_lbs(index_t *guis)
#define pool_put(P, E)
Free an object E in pool P.
u8 * format_gbp_contract(u8 *s, va_list *args)
gbp_rule_action_t gu_action
static void gbp_contract_rule_resolve(index_t gui)
vl_api_gbp_next_hop_t nhs[8]
fib_node_type_t fn_type
The node's type.
static u8 * format_gbp_policy_node(u8 *s, va_list *args)
An node in the FIB graph.
int gbp_endpoint_update_and_lock(gbp_endpoint_src_t src, u32 sw_if_index, const ip46_address_t *ips, const mac_address_t *mac, index_t gbdi, index_t grdi, sclass_t sclass, gbp_endpoint_flags_t flags, const ip46_address_t *tun_src, const ip46_address_t *tun_dst, u32 *handle)
u32 gbp_endpoint_child_add(index_t gei, fib_node_type_t type, fib_node_index_t index)
static u8 * format_gbp_hash_mode(u8 *s, va_list *args)
enum gbp_hash_mode_t_ gbp_hash_mode_t
static void gbp_next_hop_last_lock_gone(fib_node_t *node)
format_function_t format_ip46_address
static void gbp_contract_mk_adj(gbp_next_hop_t *gnh, fib_protocol_t fproto)
int gbp_contract_update(gbp_scope_t scope, sclass_t sclass, sclass_t dclass, u32 acl_index, index_t *rules, u16 *allowed_ethertypes, u32 *stats_index)
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
u8 * format_gbp_bridge_domain(u8 *s, va_list *args)
static flow_hash_config_t gbp_contract_mk_lb_hp(gbp_hash_mode_t gu_hash_mode)
#define vec_free(V)
Free vector's memory (no header).
u32 fib_node_index_t
A typedef of a node index.
dpo_id_t gu_dpo[GBP_POLICY_N_NODES][FIB_PROTOCOL_IP_MAX]
DPO of the load-balance object used to redirect.
#define IP_FLOW_HASH_PROTO
static clib_error_t * acl_plugin_exports_init(acl_plugin_methods_t *m)
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
vlib_main_t vlib_node_runtime_t * node
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
vl_api_gbp_rule_t rules[n_rules]
#define FOR_EACH_GBP_POLICY_NODE(pnode)
#define pool_put_index(p, i)
Free pool element with given index.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_node_registration_t ip4_gbp_policy_dpo_node
(constructor) VLIB_REGISTER_NODE (ip4_gbp_policy_dpo_node)
static gbp_next_hop_t * gbp_next_hop_get(index_t gui)
index_t gbp_rule_alloc(gbp_rule_action_t action, gbp_hash_mode_t hash_mode, index_t *nhs)
static fib_node_back_walk_rc_t gbp_next_hop_back_walk_notify(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
static u8 * format_gbp_contract_key(u8 *s, va_list *args)
fib_node_type_t gbp_next_hop_fib_type
static gbp_contract_t * gbp_contract_get(index_t gci)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject.
static gbp_next_hop_t * gbp_next_hop_from_fib_node(fib_node_t *node)
enum gbp_rule_action_t_ gbp_rule_action_t
counter_t bytes
byte counter
#define GBP_CONTRACT_DBG(...)
#define foreach_gbp_contract_error
#define FIB_NODE_INDEX_INVALID
vl_api_mac_event_action_t action
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 path_weight
weight for the path.
acl_plugin_methods_t acl_plugin
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
static void gbp_contract_mk_one_lb(index_t gui)
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
char * name
The counter collection's name.
gbp_rule_t * gbp_rule_pool
One path from an [EU]CMP set that the client wants to add to a load-balance object.
A collection of combined counters.
static clib_error_t * gbp_contract_init(vlib_main_t *vm)
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Group Base Policy (GBP) defines:
A FIB graph nodes virtual function table.
#define IP_FLOW_HASH_SRC_ADDR
Flow hash configuration.
enum gbp_policy_node_t_ gbp_policy_node_t
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
gbp_hash_mode_t gu_hash_mode
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
u8 * format_mac_address_t(u8 *s, va_list *args)
index_t gnh_ai[FIB_PROTOCOL_IP_MAX]
vl_api_address_t ips[n_ips]
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
u16 allowed_ethertypes[16]
void gbp_contract_walk(gbp_contract_cb_t cb, void *ctx)
vlib_node_registration_t ip6_gbp_policy_dpo_node
(constructor) VLIB_REGISTER_NODE (ip6_gbp_policy_dpo_node)
static u8 * format_gbp_rule(u8 *s, va_list *args)
index_t gbp_next_hop_alloc(const ip46_address_t *ip, index_t grd, const mac_address_t *mac, index_t gbd)
void gbp_endpoint_child_remove(index_t gei, u32 sibling)
A Group Based Policy Contract.
void gbp_rule_free(index_t gui)
int(* gbp_contract_cb_t)(gbp_contract_t *gbpe, void *ctx)