51 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
67 s =
format (s,
"0x%04x", p);
76 u32 max_header_bytes = va_arg (*args,
u32);
78 uword indent, header_bytes;
80 header_bytes =
sizeof (h[0]);
81 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
82 return format (s,
"gre header truncated");
88 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
96 max_header_bytes - header_bytes);
113 u16 * result = va_arg (*args,
u16 *);
133 u16 * result = va_arg (*args,
u16 *);
136 *result = clib_host_to_net_u16 ((
u16) *result);
143 u8 ** result = va_arg (*args,
u8 **);
151 h->
protocol = clib_host_to_net_u16 (p);
156 u32 n_bytes =
sizeof (h[0]);
171 return (GRE_PROTOCOL_ip4);
173 return (GRE_PROTOCOL_ip6);
175 return (GRE_PROTOCOL_mpls_unicast);
177 return (GRE_PROTOCOL_teb);
179 return (GRE_PROTOCOL_arp);
182 return (GRE_PROTOCOL_ip4);
189 const void *dst_address)
192 ip4_and_gre_header_t * h;
206 h = (ip4_and_gre_header_t*)rewrite;
209 h->ip4.ip_version_and_header_length = 0x45;
211 h->ip4.protocol = IP_PROTOCOL_GRE;
259 u32 * from, * to_next, n_left_from, n_left_to_next;
272 while (n_left_from > 0)
281 while (n_left_from > 0 && n_left_to_next > 0)
308 to_next, n_left_to_next,
339 u32 dev_instance = va_arg (*args,
u32);
340 return format (s,
"gre%d", dev_instance);
345 u32 dev_instance = va_arg (*args,
u32);
346 return format (s,
"teb-gre%d", dev_instance);
351 u32 dev_instance = va_arg (*args,
u32);
354 s =
format (s,
"GRE tunnel: id %d\n", dev_instance);
359 .name =
"GRE tunnel device",
374 .name =
"GRE TEB tunnel device",
399 char * protocol_name)
407 pi->
name = protocol_name;
422 memset (gm, 0,
sizeof (gm[0]));
441 #define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
static uword gre_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
uword * protocol_info_by_protocol
#define VNET_HW_INTERFACE_CLASS(x,...)
uword * tunnel_by_key
Hash mapping src/dst addr pair to tunnel.
static u8 * format_gre_tunnel_teb_name(u8 *s, va_list *args)
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
gre_protocol_t protocol
GRE protocol type in host byte order.
char * name
Name (a c string).
A GRE payload protocol registration.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define hash_set_mem(h, key, value)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
VNET_DEVICE_CLASS(gre_device_class)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, adj_midchain_flag_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
ip4_address_t tunnel_dst
The tunnel's destination/remote address.
vnet_main_t * vnet_get_main(void)
unformat_function_t * unformat_pg_edit
ip4_and_gre_header_t ip4_and_gre
#define VLIB_INIT_FUNCTION(x)
IPv4 and GRE header union.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static uword gre_interface_tx_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
TX function.
#define vlib_call_init_function(vm, x)
uword unformat_gre_header(unformat_input_t *input, va_list *args)
#define hash_create_string(elts, value_bytes)
void gre_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b0)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
A representation of a GRE tunnel.
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
u32 node_index
Node which handles this type.
void gre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
vnet_device_class_t gre_device_teb_class
format_function_t * format_buffer
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
uword * protocol_info_by_name
Hash tables mapping name/protocol to protocol info index.
static u8 * format_gre_tunnel_name(u8 *s, va_list *args)
static clib_error_t * gre_init(vlib_main_t *vm)
gre_main_t * gre_get_main(vlib_main_t *vm)
clib_error_t * ip_main_init(vlib_main_t *vm)
static u8 * format_gre_device(u8 *s, va_list *args)
#define clib_memcpy(a, b, c)
ip4_address_t tunnel_src
The tunnel's source/local address.
u32 adj_index_t
An index for adjacencies.
u8 * format_gre_header_with_length(u8 *s, va_list *args)
static clib_error_t * gre_input_init(vlib_main_t *vm)
u8 * format_gre_tx_trace(u8 *s, va_list *args)
#define hash_create(elts, value_bytes)
static u8 * gre_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
u32 next_index
Next index for this type.
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static int gre_proto_from_vnet_link(vnet_link_t link)
gre_tunnel_t * tunnels
pool of tunnel instances
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
vnet_hw_interface_class_t gre_hw_interface_class
#define VLIB_BUFFER_IS_TRACED
vlib_node_registration_t gre_input_node
(constructor) VLIB_REGISTER_NODE (gre_input_node)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vnet_device_class_t gre_device_class
VLIB_DEVICE_TX_FUNCTION_MULTIARCH(gre_device_class, gre_interface_tx)
clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static void add_protocol(gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
uword unformat_gre_protocol_host_byte_order(unformat_input_t *input, va_list *args)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
a point 2 point interface
u8 * format_gre_header(u8 *s, va_list *args)
unformat_function_t unformat_pg_gre_header
u8 * format_gre_protocol(u8 *s, va_list *args)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static uword gre_teb_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
gre_protocol_info_t * protocol_infos
GRE payload protocol registrations.
uword unformat_gre_protocol_net_byte_order(unformat_input_t *input, va_list *args)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)