24 #if VALIDATION_SCAFFOLDING 38 vnet_classify_entry_t *
v, * save_v;
39 u32 active_elements = 0;
62 clib_warning (
"found %u expected %u elts", active_elements,
74 vec_add1 (cm->unformat_l2_next_index_fns, fn);
81 vec_add1 (cm->unformat_ip_next_index_fns, fn);
89 vec_add1 (cm->unformat_acl_next_index_fns, fn);
97 vec_add1 (cm->unformat_policer_next_index_fns, fn);
104 vec_add1 (cm->unformat_opaque_index_fns, fn);
116 nbuckets = 1 << (
max_log2 (nbuckets));
119 memset(t, 0,
sizeof (*t));
145 u32 table_index,
int del_chain)
165 static vnet_classify_entry_t *
168 vnet_classify_entry_t * rv = 0;
170 vnet_classify_entry_##size##_t * rv##size = 0; 188 vec_validate_aligned \ 189 (rv##size, ((1<<log2_pages)*t->entries_per_page) - 1, \ 190 CLIB_CACHE_LINE_BYTES); \ 191 rv = (vnet_classify_entry_t *) rv##size; \ 215 memset (rv, 0xff, sizeof (*rv##size) * vec_len(rv)); \ 229 vnet_classify_entry_t *
v)
239 v->next_free = t->
freelists[free_list_index];
246 vnet_classify_entry_t *
v;
249 vnet_classify_entry_t * working_copy;
251 vnet_classify_entry_##size##_t * working_copy##size = 0; 280 working_copy##size = (void *) working_copy; \ 281 vec_validate_aligned \ 282 (working_copy##size, \ 283 ((1<<b->log2_pages)*t->entries_per_page) - 1, \ 284 CLIB_CACHE_LINE_BYTES); \ 285 working_copy = (void *) working_copy##size; \ 305 clib_memcpy (working_copy, v, \ 306 sizeof (vnet_classify_entry_##size##_t) \ 307 * (1<<b->log2_pages) \ 308 * (t->entries_per_page)); \ 317 working_bucket.as_u64 = b->
as_u64;
320 b->
as_u64 = working_bucket.as_u64;
324 static vnet_classify_entry_t *
326 vnet_classify_entry_t * old_values,
329 vnet_classify_entry_t * new_values, *
v, * new_v;
347 key_minus_skip = (
u8 *) v->key;
352 new_hash &= (1<<new_log2_pages) - 1;
361 clib_memcpy (new_v, v,
sizeof (vnet_classify_entry_t)
379 vnet_classify_entry_t * add_v,
384 vnet_classify_entry_t *
v, * new_v, * save_new_v, * working_copy, * save_v;
395 key_minus_skip = (
u8 *) add_v->key;
400 bucket_index = hash & (t->
nbuckets-1);
405 while (__sync_lock_test_and_set (t->
writer_lock, 1))
418 clib_memcpy (v, add_v,
sizeof (vnet_classify_entry_t) +
449 clib_memcpy (v, add_v,
sizeof (vnet_classify_entry_t) +
465 clib_memcpy (v, add_v,
sizeof (vnet_classify_entry_t) +
484 memset (v, 0xff,
sizeof (vnet_classify_entry_t) +
513 key_minus_skip = (
u8 *) add_v->key;
526 clib_memcpy (new_v, add_v,
sizeof (vnet_classify_entry_t) +
556 }) classify_data_or_mask_t;
563 vnet_classify_entry_t *
573 vnet_classify_entry_t * e = va_arg (*args, vnet_classify_entry_t *);
576 (s,
"[%u]: next_index %d advance %d opaque %d action %d metadata %d\n",
578 e->opaque_index, e->action, e->metadata);
585 s =
format (s,
" hits %lld, last_heard %.2f\n",
586 e->hits, e->last_heard);
588 s =
format (s,
" entry is free\n");
595 int verbose = va_arg (*args,
int);
597 vnet_classify_entry_t *
v, * save_v;
599 u64 active_elements = 0;
607 s =
format (s,
"[%d]: empty\n", i);
613 s =
format (s,
"[%d]: heap offset %d, len %d\n", i,
629 s =
format (s,
" %d: empty\n",
635 s =
format (s,
" %d: %U\n",
644 s =
format (s,
" %lld active elements\n", active_elements);
655 u32 next_table_index,
658 u8 current_data_flag,
659 i16 current_data_offset,
667 if (*table_index == ~0)
669 if (memory_size == 0)
670 return VNET_API_ERROR_INVALID_MEMORY_SIZE;
673 return VNET_API_ERROR_INVALID_VALUE;
681 *table_index = t - cm->tables;
697 #define foreach_tcp_proto_field \ 701 #define foreach_udp_proto_field \ 705 #define foreach_ip4_proto_field \ 717 u8 ** maskp = va_arg (*args,
u8 **);
719 u8 found_something = 0;
729 #define _(a) else if (unformat (input, #a)) a=1; 736 #define _(a) found_something += a; 740 if (found_something == 0)
747 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a)); 757 u8 ** maskp = va_arg (*args,
u8 **);
759 u8 found_something = 0;
769 #define _(a) else if (unformat (input, #a)) a=1; 776 #define _(a) found_something += a; 780 if (found_something == 0)
787 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a)); 801 u8 ** maskp = va_arg (*args,
u8 **);
802 u16 src_port = 0, dst_port = 0;
811 else if (
unformat (input,
"src_port"))
813 else if (
unformat (input,
"dst_port"))
819 if (!src_port && !dst_port)
836 u8 ** maskp = va_arg (*args,
u8 **);
838 u8 found_something = 0;
852 else if (
unformat (input,
"hdr_length"))
861 #define _(a) else if (unformat (input, #a)) a=1; 868 #define _(a) found_something += a; 872 if (found_something == 0)
879 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a)); 895 #define foreach_ip6_proto_field \ 904 u8 ** maskp = va_arg (*args,
u8 **);
906 u8 found_something = 0;
908 u32 ip_version_traffic_class_and_flow_label;
914 u8 traffic_class = 0;
921 else if (
unformat (input,
"traffic-class"))
923 else if (
unformat (input,
"flow-label"))
932 #define _(a) else if (unformat (input, #a)) a=1; 939 #define _(a) found_something += a; 943 if (found_something == 0)
950 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a)); 954 ip_version_traffic_class_and_flow_label = 0;
957 ip_version_traffic_class_and_flow_label |= 0xF0000000;
960 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
963 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
966 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
974 u8 ** maskp = va_arg (*args,
u8 **);
989 u8 ** maskp = va_arg (*args,
u8 **);
1009 else if (
unformat (input,
"proto"))
1015 else if (
unformat (input,
"ignore-tag1"))
1017 else if (
unformat (input,
"ignore-tag2"))
1023 else if (
unformat (input,
"dot1q"))
1025 else if (
unformat (input,
"dot1ad"))
1030 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
1031 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
1034 if (tag1 || ignore_tag1 || cos1 || dot1q)
1036 if (tag2 || ignore_tag2 || cos2 || dot1ad)
1042 memset (mask, 0xff, 6);
1045 memset (mask + 6, 0xff, 6);
1058 mask[21] = mask [20] = 0xff;
1079 mask[16] = mask [17] = 0xff;
1088 mask[12] = mask [13] = 0xff;
1098 u8 ** maskp = va_arg (*args,
u8 **);
1099 u32 * skipp = va_arg (*args,
u32 *);
1100 u32 * matchp = va_arg (*args,
u32 *);
1128 if (mask || l2 || l3 || l4)
1149 for (i = 0; i <
vec_len (mask); i++)
1154 *skipp = i /
sizeof(
u32x4);
1158 while (vec_len (mask) %
sizeof (
u32x4))
1163 for (i = match*
sizeof(
u32x4); i > 0; i-=
sizeof(
u32x4))
1166 if (*tmp || *(tmp+1))
1173 _vec_len (mask) = match *
sizeof(
u32x4);
1184 #define foreach_l2_input_next \ 1186 _(ethernet, ETHERNET_INPUT) \ 1194 u32 * miss_next_indexp = va_arg (*args,
u32 *);
1200 for (i = 0; i <
vec_len (cm->unformat_l2_next_index_fns); i++)
1202 if (
unformat (input,
"%U", cm->unformat_l2_next_index_fns[i], &tmp))
1210 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;} 1223 *miss_next_indexp = next_index;
1227 #define foreach_l2_output_next \ 1233 u32 * miss_next_indexp = va_arg (*args,
u32 *);
1239 for (i = 0; i <
vec_len (cm->unformat_l2_next_index_fns); i++)
1241 if (
unformat (input,
"%U", cm->unformat_l2_next_index_fns[i], &tmp))
1249 if (unformat (input, #n)) { next_index = L2_OUTPUT_CLASSIFY_NEXT_##N; goto out;} 1262 *miss_next_indexp = next_index;
1266 #define foreach_ip_next \ 1272 u32 * miss_next_indexp = va_arg (*args,
u32 *);
1279 for (i = 0; i <
vec_len (cm->unformat_ip_next_index_fns); i++)
1281 if (
unformat (input,
"%U", cm->unformat_ip_next_index_fns[i], &tmp))
1289 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;} 1302 *miss_next_indexp = next_index;
1306 #define foreach_acl_next \ 1311 u32 * next_indexp = va_arg (*args,
u32 *);
1318 for (i = 0; i <
vec_len (cm->unformat_acl_next_index_fns); i++)
1320 if (
unformat (input,
"%U", cm->unformat_acl_next_index_fns[i], &tmp))
1328 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;} 1337 else if (
unformat (input,
"%d", &tmp))
1346 *next_indexp = next_index;
1352 u32 * next_indexp = va_arg (*args,
u32 *);
1359 for (i = 0; i <
vec_len (cm->unformat_policer_next_index_fns); i++)
1361 if (
unformat (input,
"%U", cm->unformat_policer_next_index_fns[i], &tmp))
1377 *next_indexp = next_index;
1391 u32 table_index = ~0;
1392 u32 next_table_index = ~0;
1393 u32 miss_next_index = ~0;
1396 u32 current_data_flag = 0;
1397 int current_data_offset = 0;
1406 else if (
unformat (input,
"del-chain"))
1411 else if (
unformat (input,
"buckets %d", &nbuckets))
1413 else if (
unformat (input,
"skip %d", &skip))
1415 else if (
unformat (input,
"match %d", &match))
1417 else if (
unformat (input,
"table %d", &table_index))
1420 cm, &mask, &skip, &match))
1422 else if (
unformat (input,
"memory-size %uM", &tmp))
1423 memory_size = tmp<<20;
1424 else if (
unformat (input,
"memory-size %uG", &tmp))
1425 memory_size = tmp<<30;
1426 else if (
unformat (input,
"next-table %d", &next_table_index))
1440 else if (
unformat (input,
"current-data-flag %d", ¤t_data_flag))
1442 else if (
unformat (input,
"current-data-offset %d", ¤t_data_offset))
1449 if (is_add && mask == 0 && table_index == ~0)
1452 if (is_add && skip == ~0 && table_index == ~0)
1455 if (is_add && match == ~0 && table_index == ~0)
1458 if (!is_add && table_index == ~0)
1462 skip, match, next_table_index, miss_next_index, &table_index,
1463 current_data_flag, current_data_offset, is_add, del_chain);
1477 .path =
"classify table",
1479 "classify table [miss-next|l2-miss_next|acl-miss-next <next_index>]" 1480 "\n mask <mask-value> buckets <nn> [skip <n>] [match <n>]" 1481 "\n [current-data-flag <n>] [current-data-offset <n>] [table <n>]" 1482 "\n [del] [del-chain]",
1489 int verbose = va_arg (*args,
int);
1490 u32 index = va_arg (*args,
u32);
1495 s =
format (s,
"%10s%10s%10s%10s",
"TableIdx",
"Sessions",
"NextTbl",
1496 "NextNode", verbose ?
"Details" :
"");
1506 s =
format (s,
"\n nbuckets %d, skip %d match %d flag %d offset %d",
1527 u32 match_index = ~0;
1534 if (
unformat (input,
"index %d", &match_index))
1536 else if (
unformat (input,
"verbose %d", &verbose))
1538 else if (
unformat (input,
"verbose"))
1546 if (match_index == ~0 || (match_index == t - cm->tables))
1547 vec_add1 (indices, t - cm->tables);
1554 for (i = 0; i <
vec_len (indices); i++)
1556 verbose, indices[i]);
1567 .path =
"show classify tables",
1568 .short_help =
"show classify tables [index <nn>]",
1574 u8 ** matchp = va_arg (*args,
u8 **);
1576 u8 * proto_header = 0;
1584 if (
unformat (input,
"src_port %d", &src_port))
1586 else if (
unformat (input,
"dst_port %d", &dst_port))
1592 h.
src_port = clib_host_to_net_u16(src_port);
1593 h.
dst_port = clib_host_to_net_u16(dst_port);
1595 memcpy(proto_header, &h,
sizeof(h));
1597 *matchp = proto_header;
1604 u8 ** matchp = va_arg (*args,
u8 **);
1611 int src = 0, dst = 0;
1619 int fragment_id = 0;
1620 u32 fragment_id_val;
1628 if (
unformat (input,
"version %d", &version_val))
1630 else if (
unformat (input,
"hdr_length %d", &hdr_length_val))
1636 else if (
unformat (input,
"proto %d", &proto_val))
1638 else if (
unformat (input,
"tos %d", &tos_val))
1640 else if (
unformat (input,
"length %d", &length_val))
1642 else if (
unformat (input,
"fragment_id %d", &fragment_id_val))
1644 else if (
unformat (input,
"ttl %d", &ttl_val))
1646 else if (
unformat (input,
"checksum %d", &checksum_val))
1652 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
1653 + ttl + checksum == 0)
1685 ip->
length = clib_host_to_net_u16 (length_val);
1691 ip->
checksum = clib_host_to_net_u16 (checksum_val);
1699 u8 ** matchp = va_arg (*args,
u8 **);
1704 u8 traffic_class = 0;
1705 u32 traffic_class_val;
1708 int src = 0, dst = 0;
1712 int payload_length = 0;
1713 u32 payload_length_val;
1716 u32 ip_version_traffic_class_and_flow_label;
1720 if (
unformat (input,
"version %d", &version_val))
1722 else if (
unformat (input,
"traffic_class %d", &traffic_class_val))
1724 else if (
unformat (input,
"flow_label %d", &flow_label_val))
1730 else if (
unformat (input,
"proto %d", &proto_val))
1732 else if (
unformat (input,
"payload_length %d", &payload_length_val))
1734 else if (
unformat (input,
"hop_limit %d", &hop_limit_val))
1740 if (version + traffic_class + flow_label + src + dst + proto +
1741 payload_length + hop_limit == 0)
1760 ip_version_traffic_class_and_flow_label = 0;
1763 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
1766 ip_version_traffic_class_and_flow_label |= (traffic_class_val & 0xFF) << 20;
1769 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
1772 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
1786 u8 ** matchp = va_arg (*args,
u8 **);
1802 u8 * tagp = va_arg (*args,
u8 *);
1807 tagp[0] = (tag>>8) & 0x0F;
1808 tagp[1] = tag & 0xFF;
1817 u8 ** matchp = va_arg (*args,
u8 **);
1842 else if (
unformat (input,
"proto %U",
1849 else if (
unformat (input,
"ignore-tag1"))
1851 else if (
unformat (input,
"ignore-tag2"))
1853 else if (
unformat (input,
"cos1 %d", &cos1_val))
1855 else if (
unformat (input,
"cos2 %d", &cos2_val))
1860 if ((src + dst + proto + tag1 + tag2 +
1861 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
1864 if (tag1 || ignore_tag1 || cos1)
1866 if (tag2 || ignore_tag2 || cos2)
1880 match[19] = tag2_val[1];
1881 match[18] = tag2_val[0];
1883 match [18] |= (cos2_val & 0x7) << 5;
1886 match[21] = proto_val & 0xff;
1887 match[20] = proto_val >> 8;
1891 match [15] = tag1_val[1];
1892 match [14] = tag1_val[0];
1895 match [14] |= (cos1_val & 0x7) << 5;
1901 match [15] = tag1_val[1];
1902 match [14] = tag1_val[0];
1905 match[17] = proto_val & 0xff;
1906 match[16] = proto_val >> 8;
1909 match [14] |= (cos1_val & 0x7) << 5;
1915 match [18] |= (cos2_val & 0x7) << 5;
1917 match [14] |= (cos1_val & 0x7) << 5;
1920 match[13] = proto_val & 0xff;
1921 match[12] = proto_val >> 8;
1932 u8 ** matchp = va_arg (*args,
u8 **);
1933 u32 table_index = va_arg (*args,
u32);
1966 if (match || l2 || l3 || l4)
2013 vnet_classify_entry_5_t _max_e __attribute__((aligned (16)));
2014 vnet_classify_entry_t * e;
2018 return VNET_API_ERROR_NO_SUCH_TABLE;
2022 e = (vnet_classify_entry_t *)&_max_e;
2023 e->next_index = hit_next_index;
2024 e->opaque_index = opaque_index;
2025 e->advance = advance;
2041 e->key[i] &= t->
mask[i];
2045 return VNET_API_ERROR_NO_SUCH_ENTRY;
2056 u32 table_index = ~0;
2057 u32 hit_next_index = ~0;
2058 u64 opaque_index = ~0;
2081 else if (
unformat (input,
"policer-hit-next %U",
2084 else if (
unformat (input,
"opaque-index %lld", &opaque_index))
2087 cm, &match, table_index))
2089 else if (
unformat (input,
"advance %d", &advance))
2091 else if (
unformat (input,
"table-index %d", &table_index))
2093 else if (
unformat (input,
"action set-ip4-fib-id %d", &metadata))
2095 else if (
unformat (input,
"action set-ip6-fib-id %d", &metadata))
2100 for (i = 0; i <
vec_len (cm->unformat_opaque_index_fns); i++)
2102 if (
unformat (input,
"%U", cm->unformat_opaque_index_fns[i],
2112 if (table_index == ~0)
2115 if (is_add && match == 0)
2120 opaque_index, advance,
2121 action, metadata, is_add);
2137 .path =
"classify session",
2139 "classify session [hit-next|l2-hit-next|" 2140 "acl-hit-next <next_index>|policer-hit-next <policer_name>]" 2141 "\n table-index <nn> match [hex] [l2] [l3 ip4] [opaque-index <index>]" 2142 "\n [action set-ip4-fib-id <n>] [action set-ip6-fib-id <n>] [del]",
2149 u64 * opaquep = va_arg (*args,
u64 *);
2155 *opaquep = sw_if_index;
2165 u32 * next_indexp = va_arg (*args,
u32 *);
2167 u32 next_index = ~0;
2170 cm->vlib_main, &node_index))
2176 cm->vlib_main, &node_index))
2184 *next_indexp = next_index;
2192 u32 * next_indexp = va_arg (*args,
u32 *);
2197 cm->vlib_main, &node_index))
2203 cm->vlib_main, &node_index))
2211 *next_indexp = next_index;
2219 u32 * next_indexp = va_arg (*args,
u32 *);
2224 cm->vlib_main, &node_index))
2229 *next_indexp = next_index;
2239 u32 * next_indexp = va_arg (*args,
u32 *);
2244 cm->vlib_main, &node_index))
2249 *next_indexp = next_index;
2295 classify_data_or_mask_t * mask;
2296 classify_data_or_mask_t * data;
2297 u8 *mp = 0, *dp = 0;
2299 vnet_classify_entry_t * e;
2302 u32 table_index = ~0;
2308 src.
as_u32 = clib_net_to_host_u32 (0x0100000A);
2311 if (
unformat (input,
"sessions %d", &sessions))
2315 else if (
unformat (input,
"buckets %d", &buckets))
2317 else if (
unformat (input,
"memory-size %uM", &tmp))
2318 memory_size = tmp<<20;
2319 else if (
unformat (input,
"memory-size %uG", &tmp))
2320 memory_size = tmp<<30;
2323 else if (
unformat (input,
"table %d", &table_index))
2332 mask = (classify_data_or_mask_t *) mp;
2333 data = (classify_data_or_mask_t *) dp;
2335 data->ip.src_address.as_u32 = src.
as_u32;
2338 memset (&mask->ip.src_address, 0xff, 4);
2342 if (table_index != ~0)
2367 for (i = 0; i < sessions; i++)
2378 tmp = clib_net_to_host_u32 (data->ip.src_address.as_u32) + 1;
2379 data->ip.src_address.as_u32 = clib_net_to_host_u32 (tmp);
2392 for (i = 0; i < sessions; i++)
2394 u8 * key_minus_skip;
2403 ASSERT (e->opaque_index == (i+100));
2405 key_minus_skip = (
u8 *)e->key;
2416 tmp = clib_net_to_host_u32 (data->ip.src_address.as_u32) + 1;
2417 data->ip.src_address.as_u32 = clib_net_to_host_u32 (tmp);
2431 .path =
"test classify",
2433 "test classify [src <ip>] [sessions <nn>] [buckets <nn>] [table <nn>] [del]",
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
vnet_classify_entry_t ** working_copies
void clib_mem_validate(void)
uword unformat_classify_mask(unformat_input_t *input, va_list *args)
sll srl srl sll sra u16x4 i
void rogue(vnet_classify_table_t *t)
static clib_error_t * show_classify_tables_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define CLASSIFY_ACTION_SET_IP4_FIB_INDEX
static vnet_classify_entry_t * vnet_classify_find_entry_inline(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
void * mheap_alloc(void *memory, uword size)
#define VNET_CLASSIFY_ENTRY_FREE
static u8 * format_vnet_classify_table(u8 *s, va_list *args)
uword unformat_vlan_tag(unformat_input_t *input, va_list *args)
static clib_error_t * classify_table_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define foreach_ip6_proto_field
void vnet_classify_register_unformat_acl_next_index_fn(unformat_function_t *fn)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
u8 * format_mheap(u8 *s, va_list *va)
static uword min_log2(uword x)
vlib_node_registration_t ip4_classify_node
(constructor) VLIB_REGISTER_NODE (ip4_classify_node)
uword unformat_l2_output_next_index(unformat_input_t *input, va_list *args)
Adjacency to drop this packet.
vnet_main_t * vnet_get_main(void)
void mv(vnet_classify_table_t *t)
vlib_node_registration_t l2_input_classify_node
(constructor) VLIB_REGISTER_NODE (l2_input_classify_node)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
int vnet_classify_add_del(vnet_classify_table_t *t, vnet_classify_entry_t *add_v, int is_add)
static clib_error_t * classify_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat_l2_mask(unformat_input_t *input, va_list *args)
vlib_node_registration_t l2_output_classify_node
(constructor) VLIB_REGISTER_NODE (l2_output_classify_node)
static uword unformat_l2_input_next_node(unformat_input_t *input, va_list *args)
uword unformat_classify_match(unformat_input_t *input, va_list *args)
vnet_classify_table_t * vnet_classify_new_table(vnet_classify_main_t *cm, u8 *mask, u32 nbuckets, u32 memory_size, u32 skip_n_vectors, u32 match_n_vectors)
#define foreach_ip4_proto_field
#define clib_warning(format, args...)
#define CLASSIFY_ACTION_SET_IP6_FIB_INDEX
static uword unformat_opaque_sw_if_index(unformat_input_t *input, va_list *args)
static int vnet_classify_entry_is_free(vnet_classify_entry_t *e)
int vnet_classify_add_del_session(vnet_classify_main_t *cm, u32 table_index, u8 *match, u32 hit_next_index, u32 opaque_index, i32 advance, u8 action, u32 metadata, int is_add)
static u64 vnet_classify_hash_packet_inline(vnet_classify_table_t *t, u8 *h)
uword unformat_l4_match(unformat_input_t *input, va_list *args)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword unformat_ip4_mask(unformat_input_t *input, va_list *args)
uword unformat_l2_input_next_index(unformat_input_t *input, va_list *args)
uword unformat_ip6_mask(unformat_input_t *input, va_list *args)
uword os_get_cpu_number(void)
void vnet_classify_delete_table_index(vnet_classify_main_t *cm, u32 table_index, int del_chain)
#define pool_put(P, E)
Free an object E in pool P.
void vnet_classify_register_unformat_opaque_index_fn(unformat_function_t *fn)
static vnet_classify_entry_t * vnet_classify_entry_at_index(vnet_classify_table_t *t, vnet_classify_entry_t *e, u32 index)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
uword unformat_policer_next_index(unformat_input_t *input, va_list *args)
vlib_node_registration_t ip4_inacl_node
(constructor) VLIB_REGISTER_NODE (ip4_inacl_node)
#define foreach_udp_proto_field
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
uword unformat_udp_mask(unformat_input_t *input, va_list *args)
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
static u8 * format_classify_entry(u8 *s, va_list *args)
uword unformat_l2_match(unformat_input_t *input, va_list *args)
vnet_classify_bucket_t saved_bucket
static uword unformat_acl_next_node(unformat_input_t *input, va_list *args)
vlib_node_registration_t ip6_inacl_node
(constructor) VLIB_REGISTER_NODE (ip6_inacl_node)
#define vec_free(V)
Free vector's memory (no header).
uword unformat_acl_next_index(unformat_input_t *input, va_list *args)
static void * clib_mem_set_heap(void *heap)
static uword unformat_ip_next_node(unformat_input_t *input, va_list *args)
u8 * format_classify_table(u8 *s, va_list *args)
#define clib_memcpy(a, b, c)
uword unformat_l3_match(unformat_input_t *input, va_list *args)
uword unformat_ip4_match(unformat_input_t *input, va_list *args)
typedef CLIB_PACKED(struct{ethernet_header_t eh;ip4_header_t ip;})
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static clib_error_t * vnet_classify_init(vlib_main_t *vm)
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
static uword unformat_l2_output_next_node(unformat_input_t *input, va_list *args)
static void make_working_copy(vnet_classify_table_t *t, vnet_classify_bucket_t *b)
uword unformat_l3_mask(unformat_input_t *input, va_list *args)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
uword unformat_ip6_match(unformat_input_t *input, va_list *args)
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
#define vec_append(v1, v2)
Append v2 after v1.
uword unformat_ip_next_index(unformat_input_t *input, va_list *args)
vnet_classify_main_t vnet_classify_main
int vnet_classify_add_del_table(vnet_classify_main_t *cm, u8 *mask, u32 nbuckets, u32 memory_size, u32 skip, u32 match, u32 next_table_index, u32 miss_next_index, u32 *table_index, u8 current_data_flag, i16 current_data_offset, int is_add, int del_chain)
static int vnet_classify_entry_is_busy(vnet_classify_entry_t *e)
static clib_error_t * test_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat_tcp_mask(unformat_input_t *input, va_list *args)
uword unformat_ethernet_type_host_byte_order(unformat_input_t *input, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vnet_classify_bucket_t * buckets
void vnet_classify_register_unformat_ip_next_index_fn(unformat_function_t *fn)
static uword max_log2(uword x)
uword unformat_l4_mask(unformat_input_t *input, va_list *args)
#define vec_append_aligned(v1, v2, align)
Append v2 after v1.
volatile u32 * writer_lock
static vnet_classify_entry_t * vnet_classify_entry_alloc(vnet_classify_table_t *t, u32 log2_pages)
unformat_function_t unformat_vlib_node
static void vnet_classify_entry_free(vnet_classify_table_t *t, vnet_classify_entry_t *v)
static void * clib_mem_alloc_aligned(uword size, uword align)
#define foreach_l2_output_next
#define foreach_l2_input_next
#define CLIB_MEMORY_BARRIER()
void vnet_classify_register_unformat_policer_next_index_fn(unformat_function_t *fn)
#define clib_error_return(e, args...)
vlib_node_registration_t ip6_classify_node
(constructor) VLIB_REGISTER_NODE (ip6_classify_node)
#define foreach_tcp_proto_field
#define CLIB_CACHE_LINE_BYTES
vnet_classify_entry_t ** freelists
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
static vnet_classify_entry_t * split_and_rehash(vnet_classify_table_t *t, vnet_classify_entry_t *old_values, u32 new_log2_pages)
void vnet_classify_register_unformat_l2_next_index_fn(unformat_function_t *fn)
static vnet_classify_entry_t * vnet_classify_get_entry(vnet_classify_table_t *t, uword offset)