26 }) ip4_and_gre_header_t;
30 ip4_and_gre_header_t ip4_and_gre;
55 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
71 s =
format (s,
"0x%04x", p);
80 u32 max_header_bytes = va_arg (*args,
u32);
82 uword indent, header_bytes;
84 header_bytes =
sizeof (h[0]);
85 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
86 return format (s,
"gre header truncated");
92 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
100 max_header_bytes - header_bytes);
117 u16 * result = va_arg (*args,
u16 *);
137 u16 * result = va_arg (*args,
u16 *);
140 *result = clib_host_to_net_u16 ((
u16) *result);
147 u8 ** result = va_arg (*args,
u8 **);
155 h->
protocol = clib_host_to_net_u16 (p);
160 u32 n_bytes =
sizeof (h[0]);
174 uword max_rewrite_bytes)
184 #ifdef THINGS_WORKED_AS_ONE_MIGHT_LIKE 185 ip4_and_gre_header_t * h = rewrite;
188 if (max_rewrite_bytes <
sizeof (h[0]))
192 #define _(a,b) case VNET_L3_PACKET_TYPE_##a: protocol = GRE_PROTOCOL_##b; break 200 memset (h, 0,
sizeof (*h));
201 h->ip4.ip_version_and_header_length = 0x45;
203 h->ip4.protocol = IP_PROTOCOL_GRE;
204 h->gre.protocol = clib_host_to_net_u16 (protocol);
206 return sizeof (h[0]);
217 u32 * from, * to_next, n_left_from, n_left_to_next;
230 while (n_left_from > 0)
239 while (n_left_from >= 4 && n_left_to_next >= 2)
244 u32 bi0, next0, bi1, next1;
245 __attribute__((unused))
u8 error0, error1;
246 u16 gre_protocol0, gre_protocol1;
287 gre_protocol0 = clib_net_to_host_u16 (0x800);
290 0x86DD : gre_protocol0;
293 gre_protocol1 = clib_net_to_host_u16 (0x800);
296 0x86DD : gre_protocol1;
311 ip0 = &h0->ip4_and_gre.ip4;
312 h0->ip4_and_gre.gre.
protocol = gre_protocol0;
317 ip1 = &h1->ip4_and_gre.ip4;
318 h1->ip4_and_gre.gre.
protocol = gre_protocol1;
337 error0 = GRE_ERROR_NONE;
338 error1 = GRE_ERROR_NONE;
346 to_next, n_left_to_next,
347 bi0, bi1, next0, next1);
350 while (n_left_from > 0 && n_left_to_next > 0)
356 __attribute__((unused))
u8 error0;
359 bi0 = to_next[0] = from[0];
369 gre_protocol0 = clib_net_to_host_u16 (0x800);
372 0x86DD : gre_protocol0;
381 ip0 = &h0->ip4_and_gre.ip4;
382 h0->ip4_and_gre.gre.
protocol = gre_protocol0;
393 error0 = GRE_ERROR_NONE;
406 to_next, n_left_to_next,
432 u32 dev_instance = va_arg (*args,
u32);
433 return format (s,
"gre%d", dev_instance);
438 u32 dev_instance = va_arg (*args,
u32);
441 s =
format (s,
"GRE tunnel: id %d\n", dev_instance);
446 .name =
"GRE tunnel device",
467 char * protocol_name)
475 pi->
name = protocol_name;
490 memset (gm, 0,
sizeof (gm[0]));
509 #define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
VNET_HW_INTERFACE_CLASS(gre_hw_interface_class)
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
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
uword * protocol_info_by_protocol
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
#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)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
VNET_DEVICE_CLASS(gre_device_class)
always_inline gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
vnet_main_t * vnet_get_main(void)
unformat_function_t * unformat_pg_edit
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define vlib_call_init_function(vm, x)
uword unformat_gre_header(unformat_input_t *input, va_list *args)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define hash_create_string(elts, value_bytes)
#define pool_elt_at_index(p, i)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
always_inline void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
format_function_t * format_buffer
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
always_inline u16 ip4_header_checksum(ip4_header_t *i)
uword * protocol_info_by_name
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)
#define CLIB_PREFETCH(addr, size, type)
static u8 * format_gre_device(u8 *s, va_list *args)
static uword gre_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
#define clib_memcpy(a, b, c)
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)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
typedef CLIB_PACKED(struct{ip4_header_t ip4;gre_header_t gre;})
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)
vnet_device_class_t gre_device_class
#define GRE_OUTPUT_NEXT_LOOKUP
static void add_protocol(gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
uword unformat_gre_protocol_host_byte_order(unformat_input_t *input, va_list *args)
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)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
gre_protocol_info_t * protocol_infos
#define CLIB_CACHE_LINE_BYTES
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.
uword runtime_data[(128-1 *sizeof(vlib_node_function_t *)-1 *sizeof(vlib_error_t *)-11 *sizeof(u32)-5 *sizeof(u16))/sizeof(uword)]
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)