diff options
Diffstat (limited to 'src/vnet/classify/flow_classify.c')
-rw-r--r-- | src/vnet/classify/flow_classify.c | 108 |
1 files changed, 62 insertions, 46 deletions
diff --git a/src/vnet/classify/flow_classify.c b/src/vnet/classify/flow_classify.c index 6c067f55759..941a030f640 100644 --- a/src/vnet/classify/flow_classify.c +++ b/src/vnet/classify/flow_classify.c @@ -18,10 +18,10 @@ flow_classify_main_t flow_classify_main; static void vnet_flow_classify_feature_enable (vlib_main_t * vnm, - flow_classify_main_t * fcm, - u32 sw_if_index, - flow_classify_table_id_t tid, - int feature_enable) + flow_classify_main_t * fcm, + u32 sw_if_index, + flow_classify_table_id_t tid, + int feature_enable) { vnet_feature_config_main_t *vfcm; u8 arc; @@ -43,13 +43,14 @@ vnet_flow_classify_feature_enable (vlib_main_t * vnm, fcm->vnet_config_main[tid] = &vfcm->config_main; } -int vnet_set_flow_classify_intfc (vlib_main_t * vm, u32 sw_if_index, - u32 ip4_table_index, u32 ip6_table_index, - u32 is_add) +int +vnet_set_flow_classify_intfc (vlib_main_t * vm, u32 sw_if_index, + u32 ip4_table_index, u32 ip6_table_index, + u32 is_add) { - flow_classify_main_t * fcm = &flow_classify_main; - vnet_classify_main_t * vcm = fcm->vnet_classify_main; - u32 pct[FLOW_CLASSIFY_N_TABLES] = {ip4_table_index, ip6_table_index}; + flow_classify_main_t *fcm = &flow_classify_main; + vnet_classify_main_t *vcm = fcm->vnet_classify_main; + u32 pct[FLOW_CLASSIFY_N_TABLES] = { ip4_table_index, ip6_table_index }; u32 ti; /* Assume that we've validated sw_if_index in the API layer */ @@ -57,34 +58,36 @@ int vnet_set_flow_classify_intfc (vlib_main_t * vm, u32 sw_if_index, for (ti = 0; ti < FLOW_CLASSIFY_N_TABLES; ti++) { if (pct[ti] == ~0) - continue; + continue; if (pool_is_free_index (vcm->tables, pct[ti])) - return VNET_API_ERROR_NO_SUCH_TABLE; + return VNET_API_ERROR_NO_SUCH_TABLE; vec_validate_init_empty - (fcm->classify_table_index_by_sw_if_index[ti], sw_if_index, ~0); + (fcm->classify_table_index_by_sw_if_index[ti], sw_if_index, ~0); /* Reject any DEL operation with wrong sw_if_index */ if (!is_add && - (pct[ti] != fcm->classify_table_index_by_sw_if_index[ti][sw_if_index])) - { - clib_warning ("Non-existent intf_idx=%d with table_index=%d for delete", - sw_if_index, pct[ti]); - return VNET_API_ERROR_NO_SUCH_TABLE; - } + (pct[ti] != + fcm->classify_table_index_by_sw_if_index[ti][sw_if_index])) + { + clib_warning + ("Non-existent intf_idx=%d with table_index=%d for delete", + sw_if_index, pct[ti]); + return VNET_API_ERROR_NO_SUCH_TABLE; + } /* Return ok on ADD operaton if feature is already enabled */ if (is_add && - fcm->classify_table_index_by_sw_if_index[ti][sw_if_index] != ~0) - return 0; + fcm->classify_table_index_by_sw_if_index[ti][sw_if_index] != ~0) + return 0; vnet_flow_classify_feature_enable (vm, fcm, sw_if_index, ti, is_add); if (is_add) - fcm->classify_table_index_by_sw_if_index[ti][sw_if_index] = pct[ti]; + fcm->classify_table_index_by_sw_if_index[ti][sw_if_index] = pct[ti]; else - fcm->classify_table_index_by_sw_if_index[ti][sw_if_index] = ~0; + fcm->classify_table_index_by_sw_if_index[ti][sw_if_index] = ~0; } @@ -93,10 +96,10 @@ int vnet_set_flow_classify_intfc (vlib_main_t * vm, u32 sw_if_index, static clib_error_t * set_flow_classify_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) + unformat_input_t * input, + vlib_cli_command_t * cmd) { - vnet_main_t * vnm = vnet_get_main(); + vnet_main_t *vnm = vnet_get_main (); u32 sw_if_index = ~0; u32 ip4_table_index = ~0; u32 ip6_table_index = ~0; @@ -107,16 +110,16 @@ set_flow_classify_command_fn (vlib_main_t * vm, while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "interface %U", unformat_vnet_sw_interface, - vnm, &sw_if_index)) - ; + vnm, &sw_if_index)) + ; else if (unformat (input, "ip4-table %d", &ip4_table_index)) - idx_cnt++; + idx_cnt++; else if (unformat (input, "ip6-table %d", &ip6_table_index)) - idx_cnt++; + idx_cnt++; else if (unformat (input, "del")) - is_add = 0; + is_add = 0; else - break; + break; } if (sw_if_index == ~0) @@ -128,8 +131,8 @@ set_flow_classify_command_fn (vlib_main_t * vm, if (idx_cnt > 1) return clib_error_return (0, "Only one table index per API is allowed."); - rv = vnet_set_flow_classify_intfc(vm, sw_if_index, ip4_table_index, - ip6_table_index, is_add); + rv = vnet_set_flow_classify_intfc (vm, sw_if_index, ip4_table_index, + ip6_table_index, is_add); switch (rv) { @@ -145,6 +148,7 @@ set_flow_classify_command_fn (vlib_main_t * vm, return 0; } +/* *INDENT-OFF* */ VLIB_CLI_COMMAND (set_input_acl_command, static) = { .path = "set flow classify", .short_help = @@ -152,11 +156,12 @@ VLIB_CLI_COMMAND (set_input_acl_command, static) = { " [ip6-table <index>] [del]", .function = set_flow_classify_command_fn, }; +/* *INDENT-ON* */ static uword unformat_table_type (unformat_input_t * input, va_list * va) { - u32 * r = va_arg (*va, u32 *); + u32 *r = va_arg (*va, u32 *); u32 tid; if (unformat (input, "ip4")) @@ -169,14 +174,15 @@ unformat_table_type (unformat_input_t * input, va_list * va) *r = tid; return 1; } + static clib_error_t * show_flow_classify_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) + unformat_input_t * input, + vlib_cli_command_t * cmd) { - flow_classify_main_t * fcm = &flow_classify_main; + flow_classify_main_t *fcm = &flow_classify_main; u32 type = FLOW_CLASSIFY_N_TABLES; - u32 * vec_tbl; + u32 *vec_tbl; int i; if (unformat (input, "type %U", unformat_table_type, &type)) @@ -189,26 +195,36 @@ show_flow_classify_command_fn (vlib_main_t * vm, vec_tbl = fcm->classify_table_index_by_sw_if_index[type]; - if (vec_len(vec_tbl)) - vlib_cli_output (vm, "%10s%20s\t\t%s", "Intfc idx", "Classify table", - "Interface name"); + if (vec_len (vec_tbl)) + vlib_cli_output (vm, "%10s%20s\t\t%s", "Intfc idx", "Classify table", + "Interface name"); else vlib_cli_output (vm, "No tables configured."); for (i = 0; i < vec_len (vec_tbl); i++) { - if (vec_elt(vec_tbl, i) == ~0) - continue; + if (vec_elt (vec_tbl, i) == ~0) + continue; - vlib_cli_output (vm, "%10d%20d\t\t%U", i, vec_elt(vec_tbl, i), - format_vnet_sw_if_index_name, fcm->vnet_main, i); + vlib_cli_output (vm, "%10d%20d\t\t%U", i, vec_elt (vec_tbl, i), + format_vnet_sw_if_index_name, fcm->vnet_main, i); } return 0; } +/* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_flow_classify_command, static) = { .path = "show classify flow", .short_help = "show classify flow type [ip4|ip6]", .function = show_flow_classify_command_fn, }; +/* *INDENT-ON* */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ |