35 #define foreach_mactime_error \ 36 _(OK, "Permitted packets") \ 37 _(STATIC_DROP, "Static drop packets") \ 38 _(RANGE_DROP, "Range drop packets") \ 39 _(QUOTA_DROP, "Data quota drop packets") \ 40 _(DROP_10001, "Dropped UDP DST-port 10001") 44 #define _(sym,str) MACTIME_ERROR_##sym, 51 #define _(sym,string) string, 71 s =
format (s,
"MACTIME: src mac %U device %s result %s\n",
83 u32 n_left_from, *from, *to_next;
109 while (n_left_from > 0)
115 while (n_left_from > 0 && n_left_to_next > 0)
123 int has_dynamic_range_allow = 0;
155 if (clib_bihash_search_8_8 (lut, &kv, &kv) < 0)
168 device_index0 = kv.
value;
179 &device_current_count);
183 b0->
error = node->
errors[MACTIME_ERROR_QUOTA_DROP];
200 b0->
error = node->
errors[MACTIME_ERROR_STATIC_DROP];
216 if (ip->
protocol != IP_PROTOCOL_UDP)
218 if (clib_net_to_host_u16 (udp->
dst_port) == 10001 ||
219 clib_net_to_host_u16 (udp->
dst_port) == 9603)
222 b0->
error = node->
errors[MACTIME_ERROR_DROP_10001];
248 has_dynamic_range_allow = 1;
251 if (now >= start0 && now <= end0)
260 b0->
error = node->
errors[MACTIME_ERROR_RANGE_DROP];
264 else if (has_dynamic_range_allow)
269 b0->
error = node->
errors[MACTIME_ERROR_QUOTA_DROP];
299 b0->
error = node->
errors[MACTIME_ERROR_STATIC_DROP];
315 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
334 to_next, n_left_to_next,
342 MACTIME_ERROR_OK, packets_ok);
358 .vector_size =
sizeof (
u32),
387 .name =
"mactime-tx",
388 .vector_size =
sizeof (
u32),
vnet_config_main_t config_main
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vlib_combined_counter_main_t drop_counters
static char * mactime_error_strings[]
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
#define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW_QUOTA
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
#define clib_memcpy_fast(a, b, c)
Combined counter to hold both packets and byte differences.
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW
clib_timebase_range_t * ranges
static f64 clib_timebase_now(clib_timebase_t *tb)
#define foreach_mactime_error
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
mactime_main_t mactime_main
vlib_combined_counter_main_t allow_counters
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
vlib_node_registration_t mactime_tx_node
(constructor) VLIB_REGISTER_NODE (mactime_tx_node)
u32 node_index
Node index.
#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)
static uword mactime_tx_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define MACTIME_DEVICE_FLAG_DROP_UDP_10001
#define VLIB_REGISTER_NODE(x,...)
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
f64 clib_timebase_find_sunday_midnight(f64 start_time)
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
8 octet key, 8 octet key value pair
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.
#define MACTIME_DEVICE_FLAG_STATIC_DROP
Always drop packets from this device.
mactime_device_t * devices
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u8 output_feature_arc_index
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
clib_bihash_8_8_t lookup_table
void mactime_send_create_entry_message(u8 *mac_address)
Create a lookup table entry for the indicated mac address.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
counter_t bytes
byte counter
static u8 * format_mactime_trace(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static uword mactime_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_tx)
#define MACTIME_DEVICE_FLAG_STATIC_ALLOW
static uword mactime_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u8 * format_mac_address(u8 *s, va_list *args)
vlib_node_registration_t mactime_node
(constructor) VLIB_REGISTER_NODE (mactime_node)
#define MACTIME_DEVICE_FLAG_DYNAMIC_DROP
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
static_always_inline vnet_feature_config_main_t * vnet_feature_get_config_main(u16 arc)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.