53 "[%d] %U (src) %U (dst) payload %U outer_fib_index %d",
126 sw_if_index = adj->rewrite_header.sw_if_index;
242 u32 hw_if_index, sw_if_index;
249 if (~0 == outer_fib_index)
250 return VNET_API_ERROR_NO_SUCH_FIB;
255 return VNET_API_ERROR_INVALID_VALUE;
258 memset (t, 0,
sizeof (*t));
297 memset (address, 0,
sizeof (address));
313 return VNET_API_ERROR_INVALID_REGISTRATION;
390 *sw_if_indexp = sw_if_index;
407 return VNET_API_ERROR_NO_SUCH_ENTRY;
432 *sw_if_indexp = sw_if_index;
487 u32 outer_fib_id = 0;
506 else if (
unformat (line_input,
"outer-fib-id %d", &outer_fib_id))
508 else if (
unformat (line_input,
"teb"))
524 if (memcmp (&src, &dst,
sizeof(src)) == 0)
530 memset (a, 0,
sizeof (*a));
546 case VNET_API_ERROR_INVALID_VALUE:
549 case VNET_API_ERROR_NO_SUCH_FIB:
565 .path =
"create gre tunnel",
566 .short_help =
"create gre tunnel src <addr> dst <addr> " 567 "[outer-fib-id <fib>] [teb] [del]",
595 vlib_cli_output (vm,
"%U", format_gre_tunnel, t);
609 .path =
"show gre tunnel",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
static void gre_tunnel_db_add(const gre_tunnel_t *t)
Recursive resolution source.
#define hash_set(h, key, value)
fib_node_index_t fib_entry_index
The FIB entry sourced by the tunnel for its destination prefix.
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define hash_unset(h, key)
static u8 * format_gre_tunnel(u8 *s, va_list *args)
static int vnet_gre_tunnel_add(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
void fib_node_init(fib_node_t *node, fib_node_type_t type)
uword * tunnel_by_key
Hash mapping src/dst addr pair to tunnel.
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
static void gre_tunnel_restack(gre_tunnel_t *gt)
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 outer_fib_index
The FIB in which the src.dst address are present.
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static adj_walk_rc_t gre_adj_walk_cb(adj_index_t ai, void *ctx)
Call back when restacking all adjacencies on a GRE interface.
static gre_tunnel_t * gre_tunnel_db_find(const ip4_address_t *src, const ip4_address_t *dst, u32 out_fib_index)
#define STRUCT_OFFSET_OF(t, f)
void fib_node_deinit(fib_node_t *node)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
#define VNET_HW_INTERFACE_FLAG_LINK_UP
format_function_t format_vnet_sw_if_index_name
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
ip4_address_t tunnel_dst
The tunnel's destination/remote address.
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
clib_error_t * gre_interface_init(vlib_main_t *vm)
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
enum gre_tunnel_tyoe_t_ gre_tunnel_type_t
The GRE tunnel type.
static fib_node_t * gre_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
adj_index_t l2_adj_index
an L2 tunnel always rquires an L2 midchain.
u16 fp_len
The mask length.
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
#define GRE_TUNNEL_TYPE_NAMES
static clib_error_t * create_gre_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
#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.
A representation of a GRE tunnel.
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
u32 * free_gre_tunnel_hw_if_indices[GRE_TUNNEL_N_TYPES]
Free vlib hw_if_indices.
static void gre_tunnel_db_remove(const gre_tunnel_t *t)
static gre_tunnel_t * gre_tunnel_from_fib_node(fib_node_t *node)
#define pool_put(P, E)
Free an object E in pool P.
void gre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
vnet_device_class_t gre_device_teb_class
vlib_simple_counter_main_t * sw_if_counters
fib_node_type_t fn_type
The node's type.
An node in the FIB graph.
static u64 gre_mk_key(const ip4_address_t *src, const ip4_address_t *dst, u32 out_fib_index)
clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
static clib_error_t * show_gre_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a 'special' entry to the FIB.
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
#define clib_memcpy(a, b, c)
ip4_address_t tunnel_src
The tunnel's source/local address.
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
u32 fib_node_index_t
A typedef of a node index.
static u32 ip4_fib_index_from_table_id(u32 table_id)
u32 adj_index_t
An index for adjacencies.
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk the neighbour Adjacencies on a given interface.
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
static u8 * format_gre_tunnel_type(u8 *s, va_list *args)
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
static fib_node_back_walk_rc_t gre_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node.
void adj_nbr_midchain_stack(adj_index_t adj_index, const dpo_id_t *next)
adj_nbr_midchain_stack
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
gre_tunnel_t * tunnels
pool of tunnel instances
#define clib_error_report(e)
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
vnet_hw_interface_class_t gre_hw_interface_class
static vlib_main_t * vlib_get_main(void)
u32 l2_tx_arc
on a L2 tunnel this is the VLIB arc from the L2-tx to the l2-midchain
fib_node_t node
Linkage into the FIB object graph.
vnet_device_class_t gre_device_class
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Transparent Ethernet Bridging - the tunnel is in L2 mode.
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
A FIB graph nodes virtual function table.
ip4_main_t ip4_main
Global ip4 main structure.
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
u32 per_packet_overhead_bytes
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
int vnet_gre_add_del_tunnel(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
static int vnet_gre_tunnel_delete(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
static const char * gre_tunnel_type_names[]
const ip46_address_t zero_addr
static void gre_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
static uword pool_elts(void *v)
Number of active elements in a pool.