}
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)
+vnet_classify_new_table (vnet_classify_main_t *cm, const u8 *mask,
+ u32 nbuckets, u32 memory_size, u32 skip_n_vectors,
+ u32 match_n_vectors)
{
vnet_classify_table_t *t;
void *oldheap;
nbuckets = 1 << (max_log2 (nbuckets));
- pool_get_aligned (cm->tables, t, CLIB_CACHE_LINE_BYTES);
- clib_memset (t, 0, sizeof (*t));
+ pool_get_aligned_zero (cm->tables, t, CLIB_CACHE_LINE_BYTES);
vec_validate_aligned (t->mask, match_n_vectors - 1, sizeof (u32x4));
clib_memcpy_fast (t->mask, mask, match_n_vectors * sizeof (u32x4));
fib_table_lock (e->metadata, FIB_PROTOCOL_IP6, FIB_SOURCE_CLASSIFY);
break;
case CLASSIFY_ACTION_SET_METADATA:
+ case CLASSIFY_ACTION_NONE:
break;
}
}
fib_table_unlock (e->metadata, FIB_PROTOCOL_IP6, FIB_SOURCE_CLASSIFY);
break;
case CLASSIFY_ACTION_SET_METADATA:
+ case CLASSIFY_ACTION_NONE:
break;
}
}
-int
-vnet_classify_add_del (vnet_classify_table_t * t,
- vnet_classify_entry_t * add_v, int is_add)
+static int
+vnet_classify_add_del (vnet_classify_table_t *t, vnet_classify_entry_t *add_v,
+ int is_add)
{
u32 bucket_index;
vnet_classify_bucket_t *b, tmp_b;
}
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,
+vnet_classify_add_del_table (vnet_classify_main_t *cm, const 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)
{
vnet_classify_table_t *t;
else if (unformat (input, "dst_port"))
dst_port = 0xFFFF;
else
- return 0;
+ break;
}
if (!src_port && !dst_port)
break;
}
+ found_something = version + hdr_length;
#define _(a) found_something += a;
foreach_ip4_proto_field;
#undef _
* Put the table index where device drivers can find them.
* This table index will be either a valid table or a ~0 to clear it.
*/
- cm->classify_table_index_by_sw_if_index[sw_if_index] = table_index;
+ if (vec_len (cm->classify_table_index_by_sw_if_index) > sw_if_index)
+ cm->classify_table_index_by_sw_if_index[sw_if_index] = table_index;
if (sw_if_index > 0)
{
vnet_hw_interface_t *hi;
break;
}
- if (is_add && mask == 0 && table_index == ~0)
+ if (is_add && mask == 0)
err = clib_error_return (0, "Mask required");
- else if (is_add && skip == ~0 && table_index == ~0)
+ else if (is_add && skip == ~0)
err = clib_error_return (0, "skip count required");
- else if (is_add && match == ~0 && table_index == ~0)
+ else if (is_add && match == ~0)
err = clib_error_return (0, "match count required");
else if (sw_if_index == ~0 && pkt_trace == 0 && pcap == 0)
table_index = classify_get_pcap_chain (cm, sw_if_index);
if (table_index != ~0)
- table_index = classify_lookup_chain (table_index, mask, skip, match);
+ {
+ /*
+ * look for a compatible table in the existing chain
+ * - if a compatible table is found, table_index is updated with it
+ * - if not, table_index is updated to ~0 (aka nil) and because of that
+ * we are going to create one (see below). We save the original head
+ * in next_table_index so we can chain it with the newly created
+ * table
+ */
+ next_table_index = table_index;
+ table_index = classify_lookup_chain (table_index, mask, skip, match);
+ }
/*
* When no table is found, make one.
*/
if (table_index == ~0)
{
+ u32 new_head_index;
+
/*
* Matching table wasn't found, so create a new one at the
* head of the next_table_index chain.
*/
- next_table_index = table_index;
- table_index = ~0;
-
rv = vnet_classify_add_del_table (cm, mask, nbuckets, memory_size,
skip, match, next_table_index,
miss_next_index, &table_index,
/*
* Reorder tables such that masks are most-specify to least-specific.
*/
- table_index = classify_sort_table_chain (cm, table_index);
+ new_head_index = classify_sort_table_chain (cm, table_index);
/*
* Put first classifier table in chain in a place where
* other data structures expect to find and use it.
*/
if (pkt_trace)
- classify_set_trace_chain (cm, table_index);
+ classify_set_trace_chain (cm, new_head_index);
else
- classify_set_pcap_chain (cm, sw_if_index, table_index);
+ classify_set_pcap_chain (cm, sw_if_index, new_head_index);
}
vec_free (mask);
};
/* *INDENT-ON* */
-
-
-
-static u8 *
-format_vnet_classify_table (u8 * s, va_list * args)
+u8 *
+format_vnet_classify_table (u8 *s, va_list *args)
{
vnet_classify_main_t *cm = va_arg (*args, vnet_classify_main_t *);
int verbose = va_arg (*args, int);
else if (unformat (input, "dst_port %d", &dst_port))
;
else
- return 0;
+ break;
}
h.src_port = clib_host_to_net_u16 (src_port);
}
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)
+vnet_classify_add_del_session (vnet_classify_main_t *cm, u32 table_index,
+ const u8 *match, u32 hit_next_index,
+ u32 opaque_index, i32 advance, u8 action,
+ u16 metadata, int is_add)
{
vnet_classify_table_t *t;
vnet_classify_entry_5_t _max_e __attribute__ ((aligned (16)));