|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
46 s =
format (s,
"SYN_FILTER4: next index %d, %s",
57 #define foreach_syn_filter_error \
58 _(THROTTLED, "TCP SYN packet throttle drops") \
59 _(OK, "TCP SYN packets passed")
63 #define _(sym,str) SYN_FILTER_ERROR_##sym,
70 #define _(sym,string) string,
89 u32 ok_syn_packets = 0;
96 u8 *c0 = 0, *c1 = 0, *c2 = 0, *c3 = 0;
102 if (
now >
rt->next_reset)
105 rt->next_reset =
now +
rt->reset_interval;
116 u32 bi0, bi1, bi2, bi3;
118 u32 next0, next1, next2, next3;
121 u32 not_a_syn0 = 1, not_a_syn1 = 1, not_a_syn2 = 1, not_a_syn3 = 1;
122 u64 hash0, hash1, hash2, hash3;
145 to_next[0] = bi0 =
from[0];
146 to_next[1] = bi1 =
from[1];
147 to_next[2] = bi2 =
from[2];
148 to_next[3] = bi3 =
from[3];
174 if (ip0->
protocol != IP_PROTOCOL_TCP)
188 c0 = &
rt->syn_counts[hash0 & (_vec_len (
rt->syn_counts) - 1)];
192 b0->
error =
node->errors[SYN_FILTER_ERROR_THROTTLED];
200 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
211 if (ip1->
protocol != IP_PROTOCOL_TCP)
225 c1 = &
rt->syn_counts[hash1 & (_vec_len (
rt->syn_counts) - 1)];
229 b1->
error =
node->errors[SYN_FILTER_ERROR_THROTTLED];
237 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
248 if (ip2->
protocol != IP_PROTOCOL_TCP)
262 c2 = &
rt->syn_counts[hash2 & (_vec_len (
rt->syn_counts) - 1)];
266 b2->
error =
node->errors[SYN_FILTER_ERROR_THROTTLED];
274 && (b2->
flags & VLIB_BUFFER_IS_TRACED)))
285 if (ip3->
protocol != IP_PROTOCOL_TCP)
299 c3 = &
rt->syn_counts[hash3 & (_vec_len (
rt->syn_counts) - 1)];
303 b3->
error =
node->errors[SYN_FILTER_ERROR_THROTTLED];
311 && (b3->
flags & VLIB_BUFFER_IS_TRACED)))
320 to_next, n_left_to_next,
322 next0, next1, next2, next3);
352 if (ip0->
protocol != IP_PROTOCOL_TCP)
366 c0 = &
rt->syn_counts[hash0 & (_vec_len (
rt->syn_counts) - 1)];
370 b0->
error =
node->errors[SYN_FILTER_ERROR_THROTTLED];
379 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
390 to_next, n_left_to_next,
398 SYN_FILTER_ERROR_OK, ok_syn_packets);
399 return frame->n_vectors;
405 .name =
"syn-filter-4",
406 .vector_size =
sizeof (
u32),
426 .arc_name =
"ip4-local",
427 .node_name =
"syn-filter-4",
432 #ifndef CLIB_MARCH_VARIANT
442 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
447 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
464 rt->reset_interval = 0.1;
481 int enable_disable = 1;
505 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
507 (0,
"Invalid interface, only works on physical ports");
510 case VNET_API_ERROR_UNIMPLEMENTED:
512 "Device driver doesn't support redirection");
515 case VNET_API_ERROR_INVALID_VALUE:
518 case VNET_API_ERROR_INVALID_VALUE_2:
531 .path =
"ip syn filter",
532 .short_help =
"ip syn filter <interface-name> [disable]",
vnet_config_main_t config_main
vnet_sw_interface_type_t type
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
nat44_ei_hairpin_src_next_t next_index
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static char * syn_filter4_error_strings[]
struct _tcp_header tcp_header_t
@ VLIB_NODE_TYPE_INTERNAL
vlib_main_t vlib_node_runtime_t * node
#define clib_error_return(e, args...)
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define foreach_vlib_main()
VNET_FEATURE_INIT(syn_filter_4, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_NODE_FN(node)
vnet_main_t * vnet_get_main(void)
#define VLIB_NODE_FLAG_TRACE
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
vnet_feature_config_main_t * cm
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define foreach_syn_filter_error
#define VLIB_CLI_COMMAND(x,...)
static u64 clib_xxhash(u64 key)
vnet_feature_main_t feature_main
struct _vlib_node_registration vlib_node_registration_t
vnet_sw_interface_t * sw_interfaces
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
static u8 * format_syn_filter4_trace(u8 *s, va_list *args)
#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.
vlib_node_registration_t syn_filter4_node
(constructor) VLIB_REGISTER_NODE (syn_filter4_node)
unformat_function_t unformat_vnet_sw_interface
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
static clib_error_t * syn_filter_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int syn_filter_enable_disable(u32 sw_if_index, int enable_disable)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define VNET_FEATURES(...)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_interface_output_runtime_t * rt
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
static vlib_cli_command_t sr_content_command
(constructor) VLIB_CLI_COMMAND (sr_content_command)
static f64 vlib_time_now(vlib_main_t *vm)
vnet_feature_config_main_t * feature_config_mains
feature config main objects
static_always_inline void clib_prefetch_store(void *p)
@ VNET_SW_INTERFACE_TYPE_HARDWARE
vnet_feature_arc_registration_t vnet_feat_arc_ip4_local
vl_api_interface_index_t sw_if_index
#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).
struct _vnet_feature_arc_registration vnet_feature_arc_registration_t
feature registration object
vl_api_fib_path_type_t type
vnet_interface_main_t interface_main
static void * ip4_next_header(ip4_header_t *i)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)