36 s =
format (s,
"[%d] instance %d src %U dst %U fib-idx %d sw-if-idx %d ",
129 sw_if_index = adj->rewrite_header.sw_if_index;
176 u32 outer_fib_index,
u32 * sw_if_indexp)
191 return VNET_API_ERROR_IF_ALREADY_EXISTS;
204 return VNET_API_ERROR_INSTANCE_IN_USE;
223 { 0xd0, 0x0b, 0xee, 0xd0, (
u8) (t_idx >> 8), (
u8) t_idx };
226 address, &hw_if_index, 0);
230 return VNET_API_ERROR_INVALID_REGISTRATION;
318 u32 outer_fib_index,
u32 * sw_if_indexp)
328 return VNET_API_ERROR_NO_SUCH_ENTRY;
379 if (~0 == outer_fib_index)
380 return VNET_API_ERROR_NO_SUCH_FIB;
383 return VNET_API_ERROR_INVALID_SESSION_ID;
452 else if (
unformat (line_input,
"instance %d", &instance))
478 else if (
unformat (line_input,
"outer-fib-id %d", &outer_fib_id))
480 else if (
unformat (line_input,
"teb"))
482 else if (
unformat (line_input,
"erspan %d", &session_id))
498 if ((ipv4_set && memcmp (&src.ip4, &dst.ip4, sizeof (src.ip4)) == 0) ||
499 (ipv6_set && memcmp (&src.ip6, &dst.ip6, sizeof (src.ip6)) == 0))
505 if (ipv4_set && ipv6_set)
508 if ((ipv4_set && memcmp (&dst.ip4, &
zero_addr.ip4, sizeof (dst.ip4)) == 0)
510 && memcmp (&dst.ip6, &
zero_addr.ip6, sizeof (dst.ip6)) == 0))
542 case VNET_API_ERROR_IF_ALREADY_EXISTS:
545 case VNET_API_ERROR_NO_SUCH_FIB:
549 case VNET_API_ERROR_NO_SUCH_ENTRY:
552 case VNET_API_ERROR_INVALID_SESSION_ID:
556 case VNET_API_ERROR_INSTANCE_IN_USE:
573 .path =
"create gre tunnel",
574 .short_help =
"create gre tunnel src <addr> dst <addr> [instance <n>] " 575 "[outer-fib-id <fib>] [teb | erspan <session-id>] [del]",
605 vlib_cli_output (vm,
"%U", format_gre_tunnel, t);
621 .path =
"show gre tunnel",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vnet_set_interface_output_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Set interface output node - for interface registered without its output/tx nodes created because its ...
fib_protocol_t fp_proto
protocol type
uword * seq_num_by_key
Hash mapping tunnel src/dst addr and fib-idx to sequence number.
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
static void gre_tunnel_db_add(gre_tunnel_t *t, gre_tunnel_key_t *key)
vlib_node_registration_t gre4_input_node
(constructor) VLIB_REGISTER_NODE (gre4_input_node)
#define hash_set(h, key, value)
uword * tunnel_by_key6
Hash mapping to tunnels with ipv6 src/dst addr.
#define hash_unset(h, key)
Transparent Ethernet Bridging - the tunnel is in L2 mode.
void ip6_register_protocol(u32 protocol, u32 node_index)
static u8 * format_gre_tunnel(u8 *s, va_list *args)
vnet_main_t * vnet_get_main(void)
static gre_tunnel_t * gre_tunnel_db_find(const vnet_gre_tunnel_add_del_args_t *a, u32 outer_fib_index, gre_tunnel_key_t *key)
void adj_midchain_delegate_stack(adj_index_t ai, u32 fib_index, const fib_prefix_t *pfx)
create/attach a midchain delegate and stack it on the prefix passed
static void gre_tunnel_restack(gre_tunnel_t *gt)
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.
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.
#define hash_set_mem(h, key, value)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
void ip4_register_protocol(u32 protocol, u32 node_index)
static int vnet_gre_tunnel_add(vnet_gre_tunnel_add_del_args_t *a, u32 outer_fib_index, u32 *sw_if_indexp)
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.
#define clib_memcpy(d, s, n)
static void gre_tunnel_db_remove(gre_tunnel_t *t)
Hash key for GRE header seq number generation for ERSPAN encap.
enum gre_tunnel_type_t_ gre_tunnel_type_t
The GRE tunnel type.
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.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
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)
#define clib_error_return(e, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
adj_index_t l2_adj_index
an L2 tunnel always rquires an L2 midchain.
u16 fp_len
The mask length.
ip46_address_t tunnel_src
The tunnel's source/local address.
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)
uword * tunnel_by_key4
Hash mapping to tunnels with ipv4 src/dst addr.
#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.
A representation of a GRE tunnel.
#define hash_unset_mem(h, key)
vlib_node_registration_t gre_encap_node
(constructor) VLIB_REGISTER_NODE (gre_encap_node)
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
static u32 ip6_fib_index_from_table_id(u32 table_id)
#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)
#define GTK_SESSION_ID_MAX
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 with alignment A.
static clib_error_t * show_gre_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
gre_sn_t * gre_sn
GRE header sequence number (SN) used for ERSPAN type 2 header, must be bumped automically to be threa...
static void gre_mk_key4(ip4_address_t src, ip4_address_t dst, u32 fib_index, u8 ttype, u16 session_id, gre_tunnel_key4_t *key)
Used for GRE header seq number generation for ERSPAN encap.
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.
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
#define VLIB_CLI_COMMAND(x,...)
static int vnet_gre_tunnel_delete(vnet_gre_tunnel_add_del_args_t *a, u32 outer_fib_index, u32 *sw_if_indexp)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
int vnet_gre_tunnel_add_del(vnet_gre_tunnel_add_del_args_t *a, u32 *sw_if_indexp)
gre_tunnel_t * tunnels
pool of tunnel instances
static void clib_mem_free(void *p)
#define clib_error_report(e)
Union of the two possible key types.
static void * clib_mem_alloc(uword size)
vnet_hw_interface_class_t gre_hw_interface_class
static void gre_mk_key6(const ip6_address_t *src, const ip6_address_t *dst, u32 fib_index, u8 ttype, u16 session_id, gre_tunnel_key6_t *key)
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_device_class_t gre_device_class
ERSPAN type 2 - the tunnel is for port mirror SPAN output.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
static void hash_set_mem_alloc(uword **h, void *key, uword v)
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
#define hash_get_mem(h, key)
static void hash_unset_mem_free(uword **h, void *key)
gre_tunnel_key_t * key
The hash table's key stored in separate memory since the tunnel_t memory can realloc.
ip4_main_t ip4_main
Global ip4 main structure.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
vlib_node_registration_t gre6_input_node
(constructor) VLIB_REGISTER_NODE (gre6_input_node)
fib_prefix_t tunnel_dst
The tunnel's destination/remote address.
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.
#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,...)
u32 * fib_index_by_sw_if_index
u16 session_id
ERSPAN type 2 session ID, least significant 10 bits of u16.
static void gre_mk_sn_key(const gre_tunnel_t *gt, gre_sn_key_t *key)
static const char * gre_tunnel_type_names[]
const ip46_address_t zero_addr
vl_api_fib_path_nh_proto_t proto
static uword pool_elts(void *v)
Number of active elements in a pool.