X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fclassify%2Fvnet_classify.c;h=bf030241f68bc3951cc887ebcc7febf33c8faf2d;hb=104112f2d412a4576b5e0d3bbb20665d2b5bd615;hp=de11a107ef037573795fae1edcf39042aba4b304;hpb=71a70d73f34f7c057dd95dbca39fb8e602087a75;p=vpp.git diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c index de11a107ef0..bf030241f68 100755 --- a/src/vnet/classify/vnet_classify.c +++ b/src/vnet/classify/vnet_classify.c @@ -147,13 +147,9 @@ vnet_classify_new_table (vnet_classify_main_t * cm, t->skip_n_vectors = skip_n_vectors; t->entries_per_page = 2; -#if USE_DLMALLOC == 0 - t->mheap = mheap_alloc (0 /* use VM */ , memory_size); -#else t->mheap = create_mspace (memory_size, 1 /* locked */ ); /* classifier requires the memory to be contiguous, so can not expand. */ mspace_disable_expand (t->mheap); -#endif vec_validate_aligned (t->buckets, nbuckets - 1, CLIB_CACHE_LINE_BYTES); oldheap = clib_mem_set_heap (t->mheap); @@ -180,12 +176,7 @@ vnet_classify_delete_table_index (vnet_classify_main_t * cm, vec_free (t->mask); vec_free (t->buckets); -#if USE_DLMALLOC == 0 - mheap_free (t->mheap); -#else destroy_mspace (t->mheap); -#endif - pool_put (cm->tables, t); } @@ -1697,6 +1688,7 @@ classify_filter_command_fn (vlib_main_t * vm, int current_data_offset = 0; u32 sw_if_index = ~0; int pkt_trace = 0; + int pcap = 0; int i; vnet_classify_table_t *t; u8 *mask = 0; @@ -1709,13 +1701,16 @@ classify_filter_command_fn (vlib_main_t * vm, { if (unformat (input, "del")) is_add = 0; - else if (unformat (input, "pcap %=", &sw_if_index, 0)) - ; + else if (unformat (input, "pcap %=", &pcap, 1)) + sw_if_index = 0; else if (unformat (input, "trace")) pkt_trace = 1; else if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) - ; + { + if (sw_if_index == 0) + return clib_error_return (0, "Local interface not supported..."); + } else if (unformat (input, "buckets %d", &nbuckets)) ; else if (unformat (input, "mask %U", unformat_classify_mask, @@ -1728,9 +1723,6 @@ classify_filter_command_fn (vlib_main_t * vm, break; } - if (sw_if_index == 0) - return clib_error_return (0, "Local interface not supported..."); - if (is_add && mask == 0 && table_index == ~0) return clib_error_return (0, "Mask required"); @@ -1740,9 +1732,13 @@ classify_filter_command_fn (vlib_main_t * vm, if (is_add && match == ~0 && table_index == ~0) return clib_error_return (0, "match count required"); - if (sw_if_index == ~0 && pkt_trace == 0) + if (sw_if_index == ~0 && pkt_trace == 0 && pcap == 0) return clib_error_return (0, "Must specify trace, pcap or interface..."); + if (pkt_trace && pcap) + return clib_error_return + (0, "Packet trace and pcap are mutually exclusive..."); + if (pkt_trace && sw_if_index != ~0) return clib_error_return (0, "Packet trace filter is per-system"); @@ -2069,7 +2065,6 @@ show_classify_filter_command_fn (vlib_main_t * vm, if (verbose) { - u8 *s = 0; u32 table_index; for (j = 0; j < vec_len (set->table_indices); j++) @@ -2086,8 +2081,7 @@ show_classify_filter_command_fn (vlib_main_t * vm, } else { - u8 *s = 0; - table_index = set->table_indices[0]; + table_index = set->table_indices ? set->table_indices[0] : ~0; if (table_index != ~0) s = format (s, " %u", table_index); @@ -2949,13 +2943,11 @@ vnet_classify_init (vlib_main_t * vm) vnet_classify_register_unformat_acl_next_index_fn (unformat_acl_next_node); /* Filter set 0 is grounded... */ - pool_get (cm->filter_sets, set); + pool_get_zero (cm->filter_sets, set); set->refcnt = 0x7FFFFFFF; - vec_validate (set->table_indices, 0); - set->table_indices[0] = ~0; /* Initialize the pcap filter set */ vec_validate (cm->filter_set_by_sw_if_index, 0); - cm->filter_set_by_sw_if_index[0] = ~0; + cm->filter_set_by_sw_if_index[0] = 0; /* Initialize the packet tracer filter set */ vlib_global_main.trace_filter.trace_filter_set_index = ~0;