24 #if VALIDATION_SCAFFOLDING 40 vnet_classify_entry_t *
v, *save_v;
41 u32 active_elements = 0;
64 clib_warning (
"found %u expected %u elts", active_elements,
84 vec_add1 (cm->unformat_l2_next_index_fns, fn);
92 vec_add1 (cm->unformat_ip_next_index_fns, fn);
100 vec_add1 (cm->unformat_acl_next_index_fns, fn);
109 vec_add1 (cm->unformat_policer_next_index_fns, fn);
117 vec_add1 (cm->unformat_opaque_index_fns, fn);
123 u32 skip_n_vectors,
u32 match_n_vectors)
128 nbuckets = 1 << (
max_log2 (nbuckets));
131 memset (t, 0,
sizeof (*t));
143 #if USE_DLMALLOC == 0 162 u32 table_index,
int del_chain)
177 #if USE_DLMALLOC == 0 186 static vnet_classify_entry_t *
189 vnet_classify_entry_t *rv = 0;
214 memset (rv, 0xff, required_length);
233 vnet_classify_entry_t *
v;
236 vnet_classify_entry_t *working_copy;
238 int working_copy_length, required_length;
263 if (required_length > working_copy_length)
278 working_bucket.as_u64 = b->
as_u64;
281 b->
as_u64 = working_bucket.as_u64;
285 static vnet_classify_entry_t *
287 vnet_classify_entry_t * old_values,
u32 old_log2_pages,
290 vnet_classify_entry_t *new_values, *
v, *new_v;
291 int i, j, length_in_entries;
296 for (i = 0; i < length_in_entries; i++)
306 key_minus_skip = (
u8 *) v->key;
311 new_hash &= (1 << new_log2_pages) - 1;
320 clib_memcpy (new_v, v,
sizeof (vnet_classify_entry_t)
336 static vnet_classify_entry_t *
338 vnet_classify_entry_t * old_values,
339 u32 old_log2_pages,
u32 new_log2_pages)
341 vnet_classify_entry_t *new_values, *
v, *new_v;
342 int i, j, new_length_in_entries, old_length_in_entries;
349 for (i = 0; i < old_length_in_entries; i++)
355 for (; j < new_length_in_entries; j++)
361 clib_warning (
"BUG: linear rehash new entry not free!");
364 clib_memcpy (new_v, v,
sizeof (vnet_classify_entry_t)
419 vnet_classify_entry_t * add_v,
int is_add)
423 vnet_classify_entry_t *
v, *new_v, *save_new_v, *working_copy, *save_v;
429 u32 old_log2_pages, new_log2_pages;
432 int resplit_once = 0;
433 int mark_bucket_linear;
437 key_minus_skip = (
u8 *) add_v->key;
442 bucket_index = hash & (t->
nbuckets - 1);
447 while (__sync_lock_test_and_set (t->
writer_lock, 1))
460 clib_memcpy (v, add_v,
sizeof (vnet_classify_entry_t) +
482 limit *= (1 << b->log2_pages);
492 for (i = 0; i < limit; i++)
499 clib_memcpy (v, add_v,
sizeof (vnet_classify_entry_t) +
510 for (i = 0; i < limit; i++)
516 clib_memcpy (v, add_v,
sizeof (vnet_classify_entry_t) +
531 for (i = 0; i < limit; i++)
539 memset (v, 0xff,
sizeof (vnet_classify_entry_t) +
555 new_log2_pages = old_log2_pages + 1;
561 mark_bucket_linear = 0;
585 mark_bucket_linear = 1;
592 key_minus_skip = (
u8 *) add_v->key;
597 new_hash &= (1 << new_log2_pages) - 1;
600 if (mark_bucket_linear)
602 limit *= (1 << new_log2_pages);
606 for (i = 0; i < limit; i++)
612 clib_memcpy (new_v, add_v,
sizeof (vnet_classify_entry_t) +
650 }) classify_data_or_mask_t;
659 vnet_classify_entry_t *
670 vnet_classify_entry_t *e = va_arg (*args, vnet_classify_entry_t *);
673 (s,
"[%u]: next_index %d advance %d opaque %d action %d metadata %d\n",
675 e->opaque_index, e->action, e->metadata);
682 s =
format (s,
" hits %lld, last_heard %.2f\n",
683 e->hits, e->last_heard);
685 s =
format (s,
" entry is free\n");
693 int verbose = va_arg (*args,
int);
695 vnet_classify_entry_t *
v, *save_v;
697 u64 active_elements = 0;
705 s =
format (s,
"[%d]: empty\n", i);
711 s =
format (s,
"[%d]: heap offset %d, elts %d, %s\n", i,
728 s =
format (s,
" %d: empty\n",
734 s =
format (s,
" %d: %U\n",
743 s =
format (s,
" %lld active elements\n", active_elements);
756 u32 next_table_index,
759 u8 current_data_flag,
760 i16 current_data_offset,
761 int is_add,
int del_chain)
767 if (*table_index == ~0)
769 if (memory_size == 0)
770 return VNET_API_ERROR_INVALID_MEMORY_SIZE;
773 return VNET_API_ERROR_INVALID_VALUE;
781 *table_index = t - cm->tables;
797 #define foreach_tcp_proto_field \ 801 #define foreach_udp_proto_field \ 805 #define foreach_ip4_proto_field \ 818 u8 **maskp = va_arg (*args,
u8 **);
820 u8 found_something = 0;
830 #define _(a) else if (unformat (input, #a)) a=1; 837 #define _(a) found_something += a; 841 if (found_something == 0)
848 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a)); 859 u8 **maskp = va_arg (*args,
u8 **);
861 u8 found_something = 0;
871 #define _(a) else if (unformat (input, #a)) a=1; 878 #define _(a) found_something += a; 882 if (found_something == 0)
889 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a)); 905 u8 **maskp = va_arg (*args,
u8 **);
915 else if (
unformat (input,
"src_port"))
917 else if (
unformat (input,
"dst_port"))
941 u8 **maskp = va_arg (*args,
u8 **);
943 u8 found_something = 0;
957 else if (
unformat (input,
"hdr_length"))
966 #define _(a) else if (unformat (input, #a)) a=1; 973 #define _(a) found_something += a; 977 if (found_something == 0)
984 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a)); 1000 #define foreach_ip6_proto_field \ 1010 u8 **maskp = va_arg (*args,
u8 **);
1012 u8 found_something = 0;
1014 u32 ip_version_traffic_class_and_flow_label;
1016 #define _(a) u8 a=0; 1020 u8 traffic_class = 0;
1027 else if (
unformat (input,
"traffic-class"))
1029 else if (
unformat (input,
"flow-label"))
1035 else if (
unformat (input,
"proto"))
1038 #define _(a) else if (unformat (input, #a)) a=1; 1045 #define _(a) found_something += a; 1049 if (found_something == 0)
1056 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a)); 1060 ip_version_traffic_class_and_flow_label = 0;
1063 ip_version_traffic_class_and_flow_label |= 0xF0000000;
1066 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
1069 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
1072 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
1081 u8 **maskp = va_arg (*args,
u8 **);
1098 u8 **maskp = va_arg (*args,
u8 **);
1119 else if (
unformat (input,
"proto"))
1125 else if (
unformat (input,
"ignore-tag1"))
1127 else if (
unformat (input,
"ignore-tag2"))
1133 else if (
unformat (input,
"dot1q"))
1135 else if (
unformat (input,
"dot1ad"))
1140 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
1141 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
1144 if (tag1 || ignore_tag1 || cos1 || dot1q)
1146 if (tag2 || ignore_tag2 || cos2 || dot1ad)
1155 memset (mask + 6, 0xff, 6);
1168 mask[21] = mask[20] = 0xff;
1189 mask[16] = mask[17] = 0xff;
1198 mask[12] = mask[13] = 0xff;
1207 u8 **maskp = va_arg (*args,
u8 **);
1208 u32 *skipp = va_arg (*args,
u32 *);
1209 u32 *matchp = va_arg (*args,
u32 *);
1239 if (mask || l2 || l3 || l4)
1260 for (i = 0; i <
vec_len (mask); i++)
1265 *skipp = i /
sizeof (
u32x4);
1269 while (vec_len (mask) %
sizeof (
u32x4))
1274 for (i = match *
sizeof (
u32x4); i > 0; i -=
sizeof (
u32x4))
1277 if (*tmp || *(tmp + 1))
1284 _vec_len (mask) = match *
sizeof (
u32x4);
1295 #define foreach_l2_input_next \ 1297 _(ethernet, ETHERNET_INPUT) \ 1306 u32 *miss_next_indexp = va_arg (*args,
u32 *);
1312 for (i = 0; i <
vec_len (cm->unformat_l2_next_index_fns); i++)
1314 if (
unformat (input,
"%U", cm->unformat_l2_next_index_fns[i], &tmp))
1322 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;} 1335 *miss_next_indexp = next_index;
1339 #define foreach_l2_output_next \ 1346 u32 *miss_next_indexp = va_arg (*args,
u32 *);
1352 for (i = 0; i <
vec_len (cm->unformat_l2_next_index_fns); i++)
1354 if (
unformat (input,
"%U", cm->unformat_l2_next_index_fns[i], &tmp))
1362 if (unformat (input, #n)) { next_index = L2_OUTPUT_CLASSIFY_NEXT_##N; goto out;} 1375 *miss_next_indexp = next_index;
1379 #define foreach_ip_next \ 1386 u32 *miss_next_indexp = va_arg (*args,
u32 *);
1393 for (i = 0; i <
vec_len (cm->unformat_ip_next_index_fns); i++)
1395 if (
unformat (input,
"%U", cm->unformat_ip_next_index_fns[i], &tmp))
1403 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;} 1416 *miss_next_indexp = next_index;
1420 #define foreach_acl_next \ 1426 u32 *next_indexp = va_arg (*args,
u32 *);
1433 for (i = 0; i <
vec_len (cm->unformat_acl_next_index_fns); i++)
1435 if (
unformat (input,
"%U", cm->unformat_acl_next_index_fns[i], &tmp))
1443 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;} 1452 else if (
unformat (input,
"%d", &tmp))
1461 *next_indexp = next_index;
1468 u32 *next_indexp = va_arg (*args,
u32 *);
1475 for (i = 0; i <
vec_len (cm->unformat_policer_next_index_fns); i++)
1478 (input,
"%U", cm->unformat_policer_next_index_fns[i], &tmp))
1494 *next_indexp = next_index;
1507 u32 table_index = ~0;
1508 u32 next_table_index = ~0;
1509 u32 miss_next_index = ~0;
1512 u32 current_data_flag = 0;
1513 int current_data_offset = 0;
1523 else if (
unformat (input,
"del-chain"))
1528 else if (
unformat (input,
"buckets %d", &nbuckets))
1530 else if (
unformat (input,
"skip %d", &skip))
1532 else if (
unformat (input,
"match %d", &match))
1534 else if (
unformat (input,
"table %d", &table_index))
1537 &mask, &skip, &match))
1539 else if (
unformat (input,
"memory-size %uM", &tmp))
1540 memory_size = tmp << 20;
1541 else if (
unformat (input,
"memory-size %uG", &tmp))
1542 memory_size = tmp << 30;
1543 else if (
unformat (input,
"next-table %d", &next_table_index))
1561 else if (
unformat (input,
"current-data-flag %d", ¤t_data_flag))
1564 if (
unformat (input,
"current-data-offset %d", ¤t_data_offset))
1571 if (is_add && mask == 0 && table_index == ~0)
1574 if (is_add && skip == ~0 && table_index == ~0)
1577 if (is_add && match == ~0 && table_index == ~0)
1580 if (!is_add && table_index == ~0)
1584 skip, match, next_table_index,
1585 miss_next_index, &table_index,
1586 current_data_flag, current_data_offset,
1602 .path =
"classify table",
1604 "classify table [miss-next|l2-miss_next|acl-miss-next <next_index>]" 1605 "\n mask <mask-value> buckets <nn> [skip <n>] [match <n>]" 1606 "\n [current-data-flag <n>] [current-data-offset <n>] [table <n>]" 1607 "\n [memory-size <nn>[M][G]] [next-table <n>]" 1608 "\n [del] [del-chain]",
1617 int verbose = va_arg (*args,
int);
1618 u32 index = va_arg (*args,
u32);
1623 s =
format (s,
"%10s%10s%10s%10s",
"TableIdx",
"Sessions",
"NextTbl",
1624 "NextNode", verbose ?
"Details" :
"");
1634 s =
format (s,
"\n nbuckets %d, skip %d match %d flag %d offset %d",
1656 u32 match_index = ~0;
1663 if (
unformat (input,
"index %d", &match_index))
1665 else if (
unformat (input,
"verbose %d", &verbose))
1667 else if (
unformat (input,
"verbose"))
1676 if (match_index == ~0 || (match_index == t - cm->tables))
1677 vec_add1 (indices, t - cm->tables);
1685 for (i = 0; i <
vec_len (indices); i++)
1687 verbose, indices[i]);
1699 .path =
"show classify tables",
1700 .short_help =
"show classify tables [index <nn>]",
1708 u8 **matchp = va_arg (*args,
u8 **);
1710 u8 *proto_header = 0;
1718 if (
unformat (input,
"src_port %d", &src_port))
1720 else if (
unformat (input,
"dst_port %d", &dst_port))
1726 h.
src_port = clib_host_to_net_u16 (src_port);
1727 h.
dst_port = clib_host_to_net_u16 (dst_port);
1729 memcpy (proto_header, &h,
sizeof (h));
1731 *matchp = proto_header;
1739 u8 **matchp = va_arg (*args,
u8 **);
1754 int fragment_id = 0;
1755 u32 fragment_id_val;
1763 if (
unformat (input,
"version %d", &version_val))
1765 else if (
unformat (input,
"hdr_length %d", &hdr_length_val))
1771 else if (
unformat (input,
"proto %d", &proto_val))
1773 else if (
unformat (input,
"tos %d", &tos_val))
1775 else if (
unformat (input,
"length %d", &length_val))
1777 else if (
unformat (input,
"fragment_id %d", &fragment_id_val))
1779 else if (
unformat (input,
"ttl %d", &ttl_val))
1781 else if (
unformat (input,
"checksum %d", &checksum_val))
1787 if (version + hdr_length + src +
dst + proto + tos + length + fragment_id
1788 + ttl + checksum == 0)
1820 ip->
length = clib_host_to_net_u16 (length_val);
1826 ip->
checksum = clib_host_to_net_u16 (checksum_val);
1835 u8 **matchp = va_arg (*args,
u8 **);
1840 u8 traffic_class = 0;
1841 u32 traffic_class_val;
1848 int payload_length = 0;
1849 u32 payload_length_val;
1852 u32 ip_version_traffic_class_and_flow_label;
1856 if (
unformat (input,
"version %d", &version_val))
1858 else if (
unformat (input,
"traffic_class %d", &traffic_class_val))
1860 else if (
unformat (input,
"flow_label %d", &flow_label_val))
1866 else if (
unformat (input,
"proto %d", &proto_val))
1868 else if (
unformat (input,
"payload_length %d", &payload_length_val))
1870 else if (
unformat (input,
"hop_limit %d", &hop_limit_val))
1876 if (version + traffic_class + flow_label + src +
dst + proto +
1877 payload_length + hop_limit == 0)
1896 ip_version_traffic_class_and_flow_label = 0;
1899 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
1902 ip_version_traffic_class_and_flow_label |=
1903 (traffic_class_val & 0xFF) << 20;
1906 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
1909 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
1924 u8 **matchp = va_arg (*args,
u8 **);
1942 u8 *tagp = va_arg (*args,
u8 *);
1947 tagp[0] = (tag >> 8) & 0x0F;
1948 tagp[1] = tag & 0xFF;
1958 u8 **matchp = va_arg (*args,
u8 **);
1985 else if (
unformat (input,
"proto %U",
1992 else if (
unformat (input,
"ignore-tag1"))
1994 else if (
unformat (input,
"ignore-tag2"))
1996 else if (
unformat (input,
"cos1 %d", &cos1_val))
1998 else if (
unformat (input,
"cos2 %d", &cos2_val))
2003 if ((src + dst + proto + tag1 + tag2 +
2004 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
2007 if (tag1 || ignore_tag1 || cos1)
2009 if (tag2 || ignore_tag2 || cos2)
2023 match[19] = tag2_val[1];
2024 match[18] = tag2_val[0];
2026 match[18] |= (cos2_val & 0x7) << 5;
2029 match[21] = proto_val & 0xff;
2030 match[20] = proto_val >> 8;
2034 match[15] = tag1_val[1];
2035 match[14] = tag1_val[0];
2038 match[14] |= (cos1_val & 0x7) << 5;
2044 match[15] = tag1_val[1];
2045 match[14] = tag1_val[0];
2048 match[17] = proto_val & 0xff;
2049 match[16] = proto_val >> 8;
2052 match[14] |= (cos1_val & 0x7) << 5;
2058 match[18] |= (cos2_val & 0x7) << 5;
2060 match[14] |= (cos1_val & 0x7) << 5;
2063 match[13] = proto_val & 0xff;
2064 match[12] = proto_val >> 8;
2076 u8 **matchp = va_arg (*args,
u8 **);
2077 u32 table_index = va_arg (*args,
u32);
2112 if (match || l2 || l3 || l4)
2157 u8 action,
u32 metadata,
int is_add)
2160 vnet_classify_entry_5_t _max_e __attribute__ ((aligned (16)));
2161 vnet_classify_entry_t *e;
2165 return VNET_API_ERROR_NO_SUCH_TABLE;
2169 e = (vnet_classify_entry_t *) & _max_e;
2170 e->next_index = hit_next_index;
2171 e->opaque_index = opaque_index;
2172 e->advance = advance;
2186 e->metadata = metadata;
2196 e->key[i] &= t->
mask[i];
2203 return VNET_API_ERROR_NO_SUCH_ENTRY;
2214 u32 table_index = ~0;
2215 u32 hit_next_index = ~0;
2216 u64 opaque_index = ~0;
2243 else if (
unformat (input,
"policer-hit-next %U",
2246 else if (
unformat (input,
"opaque-index %lld", &opaque_index))
2249 cm, &match, table_index))
2251 else if (
unformat (input,
"advance %d", &advance))
2253 else if (
unformat (input,
"table-index %d", &table_index))
2255 else if (
unformat (input,
"action set-ip4-fib-id %d", &metadata))
2257 else if (
unformat (input,
"action set-ip6-fib-id %d", &metadata))
2259 else if (
unformat (input,
"action set-sr-policy-index %d", &metadata))
2264 for (i = 0; i <
vec_len (cm->unformat_opaque_index_fns); i++)
2266 if (
unformat (input,
"%U", cm->unformat_opaque_index_fns[i],
2276 if (table_index == ~0)
2279 if (is_add && match == 0)
2284 opaque_index, advance,
2285 action, metadata, is_add);
2294 "vnet_classify_add_del_session returned %d",
2303 .path =
"classify session",
2305 "classify session [hit-next|l2-hit-next|" 2306 "acl-hit-next <next_index>|policer-hit-next <policer_name>]" 2307 "\n table-index <nn> match [hex] [l2] [l3 ip4] [opaque-index <index>]" 2308 "\n [action set-ip4-fib-id|set-ip6-fib-id|set-sr-policy-index <n>] [del]",
2316 u64 *opaquep = va_arg (*args,
u64 *);
2332 u32 *next_indexp = va_arg (*args,
u32 *);
2334 u32 next_index = ~0;
2337 cm->vlib_main, &node_index))
2343 cm->vlib_main, &node_index))
2351 *next_indexp = next_index;
2359 u32 *next_indexp = va_arg (*args,
u32 *);
2364 cm->vlib_main, &node_index))
2370 cm->vlib_main, &node_index))
2378 *next_indexp = next_index;
2386 u32 *next_indexp = va_arg (*args,
u32 *);
2391 cm->vlib_main, &node_index))
2396 *next_indexp = next_index;
2406 u32 *next_indexp = va_arg (*args,
u32 *);
2411 cm->vlib_main, &node_index))
2416 *next_indexp = next_index;
2490 classify_data_or_mask_t *mask, *data;
2493 u8 *mp = 0, *dp = 0;
2500 mask = (classify_data_or_mask_t *) mp;
2501 data = (classify_data_or_mask_t *) dp;
2504 memset (&mask->ip.src_address, 0xff, 4);
2506 tmp = clib_host_to_net_u32 (tm->
src.
as_u32);
2511 ep->
addr.
as_u32 = clib_host_to_net_u32 (tmp);
2526 vlib_cli_output (vm,
"Initialize: add %d (approx. half of %d sessions)...",
2529 for (i = 0; i < tm->
sessions / 2; i++)
2533 data->ip.src_address.as_u32 = ep->
addr.
as_u32;
2565 data->ip.src_address.as_u32 = ep->
addr.
as_u32;
2572 is_add ?
"add" :
"del",
2586 "%s[%d]: %U returned %d", is_add ?
"add" :
"del",
2599 vnet_classify_entry_t *e;
2605 data->ip.src_address.as_u32 = ep->
addr.
as_u32;
2610 (
u8 *) data, hash, 0 );
2613 clib_warning (
"Couldn't find %U index %d which should be present",
2618 key_minus_skip = (
u8 *) e->key;
2667 tm->
src.
as_u32 = clib_net_to_host_u32 (0x0100000A);
2669 tm->
seed = 0xDEADDABE;
2678 if (
unformat (input,
"sessions %d", &tmp))
2685 else if (
unformat (input,
"memory-size %uM", &tmp))
2687 else if (
unformat (input,
"memory-size %uG", &tmp))
2691 else if (
unformat (input,
"verbose"))
2696 else if (
unformat (input,
"churn-test"))
2717 .path =
"test classify",
2719 "test classify [src <ip>] [sessions <nn>] [buckets <nn>] [seed <nnn>]\n" 2720 " [memory-size <nn>[M|G]]\n" 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)
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)
vnet_main_t * vnet_get_main(void)
classify_data_or_mask_t * mask
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)
static void vnet_classify_entry_claim_resource(vnet_classify_entry_t *e)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
for(i=1;i<=collision_buckets;i++)
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
static clib_error_t * test_classify_churn(test_classify_main_t *tm)
void vnet_classify_register_unformat_acl_next_index_fn(unformat_function_t *fn)
struct _tcp_header tcp_header_t
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
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)
vnet_classify_main_t * classify_main
memset(h->entries, 0, sizeof(h->entries[0])*entries)
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 vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define foreach_ip4_proto_field
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)
u8 * format_mheap(u8 *s, va_list *va)
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.
static test_classify_main_t test_classify_main
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)
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.
static vnet_classify_entry_t * split_and_rehash_linear(vnet_classify_table_t *t, vnet_classify_entry_t *old_values, u32 old_log2_pages, u32 new_log2_pages)
void vnet_classify_register_unformat_opaque_index_fn(unformat_function_t *fn)
vl_api_address_union_t src_address
static vnet_classify_entry_t * vnet_classify_entry_at_index(vnet_classify_table_t *t, vnet_classify_entry_t *e, u32 index)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
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).
static vnet_classify_entry_t * split_and_rehash(vnet_classify_table_t *t, vnet_classify_entry_t *old_values, u32 old_log2_pages, u32 new_log2_pages)
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
Adjacency to drop this packet.
static uword unformat_acl_next_node(unformat_input_t *input, va_list *args)
DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked)
static_always_inline uword vlib_get_thread_index(void)
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)
classify_data_or_mask_t * data
static void * clib_mem_set_heap(void *heap)
static uword unformat_ip_next_node(unformat_input_t *input, va_list *args)
static void vnet_classify_entry_free(vnet_classify_table_t *t, vnet_classify_entry_t *v, u32 log2_pages)
u8 * format_classify_table(u8 *s, va_list *args)
#define clib_warning(format, 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)
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
#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)
static void clib_mem_free(void *p)
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
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
static void vnet_classify_entry_release_resource(vnet_classify_entry_t *e)
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
DLMALLOC_EXPORT size_t destroy_mspace(mspace msp)
static void * clib_mem_alloc_aligned(uword size, uword align)
static u32 random_u32(u32 *seed)
32-bit random number generator
#define foreach_l2_output_next
#define foreach_l2_input_next
int * working_copy_lengths
#define CLIB_MEMORY_BARRIER()
void vnet_classify_register_unformat_policer_next_index_fn(unformat_function_t *fn)
vlib_node_registration_t ip6_classify_node
(constructor) VLIB_REGISTER_NODE (ip6_classify_node)
#define foreach_tcp_proto_field
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vnet_classify_entry_t ** freelists
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
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)
vnet_classify_table_t * table