Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add value to classify entry #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 17 additions & 42 deletions src/plugins/acl/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#include <vpp/app/version.h>

#include <vnet/ethernet/ethernet_types_api.h>
#include <vnet/ip/format.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/ip/ip_types_api.h>

#include <vlibapi/api.h>
#include <vlibmemory/api.h>
Expand All @@ -37,6 +34,7 @@
#include <acl/acl.api_types.h>

#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
#include "manual_fns.h"

#include "fa_node.h"
#include "public_inlines.h"
Expand Down Expand Up @@ -134,26 +132,6 @@ print_cli_and_reset (vlib_main_t * vm, u8 * out0)

typedef void (*acl_vector_print_func_t) (vlib_main_t * vm, u8 * out0);

static inline u8 *
format_acl_action (u8 * s, u8 action)
{
switch (action)
{
case 0:
s = format (s, "deny");
break;
case 1:
s = format (s, "permit");
break;
case 2:
s = format (s, "permit+reflect");
break;
default:
s = format (s, "action %d", action);
}
return (s);
}

static void
acl_print_acl_x (acl_vector_print_func_t vpr, vlib_main_t * vm,
acl_main_t * am, int acl_index)
Expand Down Expand Up @@ -651,16 +629,16 @@ acl_interface_set_inout_acl_list (acl_main_t * am, u32 sw_if_index,


u32 **pinout_lc_index_by_sw_if_index =
is_input ? &am->input_lc_index_by_sw_if_index : &am->
output_lc_index_by_sw_if_index;
is_input ? &am->
input_lc_index_by_sw_if_index : &am->output_lc_index_by_sw_if_index;

u32 ***pinout_acl_vec_by_sw_if_index =
is_input ? &am->input_acl_vec_by_sw_if_index : &am->
output_acl_vec_by_sw_if_index;
is_input ? &am->
input_acl_vec_by_sw_if_index : &am->output_acl_vec_by_sw_if_index;

u32 ***pinout_sw_if_index_vec_by_acl =
is_input ? &am->input_sw_if_index_vec_by_acl : &am->
output_sw_if_index_vec_by_acl;
is_input ? &am->
input_sw_if_index_vec_by_acl : &am->output_sw_if_index_vec_by_acl;

vec_validate ((*pinout_acl_vec_by_sw_if_index), sw_if_index);

Expand Down Expand Up @@ -735,9 +713,7 @@ acl_interface_set_inout_acl_list (acl_main_t * am, u32 sw_if_index,
{
if (~0 != (*pinout_lc_index_by_sw_if_index)[sw_if_index])
{
acl_plugin.
put_lookup_context_index ((*pinout_lc_index_by_sw_if_index)
[sw_if_index]);
acl_plugin.put_lookup_context_index ((*pinout_lc_index_by_sw_if_index)[sw_if_index]);
(*pinout_lc_index_by_sw_if_index)[sw_if_index] = ~0;
}
}
Expand Down Expand Up @@ -774,8 +750,8 @@ acl_interface_add_del_inout_acl (u32 sw_if_index, u8 is_add, u8 is_input,
: VNET_API_ERROR_ACL_IN_USE_OUTBOUND;

u32 ***pinout_acl_vec_by_sw_if_index =
is_input ? &am->input_acl_vec_by_sw_if_index : &am->
output_acl_vec_by_sw_if_index;
is_input ? &am->
input_acl_vec_by_sw_if_index : &am->output_acl_vec_by_sw_if_index;
int rv = 0;
if (is_add)
{
Expand Down Expand Up @@ -1320,7 +1296,7 @@ macip_create_classify_tables (acl_main_t * am, u32 macip_acl_index)
/* add session to table mvec[match_type_index].table_index; */
vnet_classify_add_del_session (cm, tag_table,
mask, a->rules[i].is_permit ? ~0 : 0,
i, 0, action, metadata, 1);
i, 0, action, metadata, 0, 1);
clib_memset (&mask[12], 0, sizeof (mask) - 12);
}

Expand Down Expand Up @@ -1366,7 +1342,7 @@ macip_create_classify_tables (acl_main_t * am, u32 macip_acl_index)
4);
vnet_classify_add_del_session (cm, tag_table, mask,
a->rules[i].is_permit ? ~0 : 0,
i, 0, action, metadata, 1);
i, 0, action, metadata, 0, 1);
}
}
if (macip_permit_also_egress (a->rules[i].is_permit))
Expand Down Expand Up @@ -1419,7 +1395,7 @@ macip_create_classify_tables (acl_main_t * am, u32 macip_acl_index)
vnet_classify_add_del_session (cm, tag_table,
mask,
a->rules[i].is_permit ? ~0 : 0,
i, 0, action, metadata, 1);
i, 0, action, metadata, 0, 1);
// clib_memset (&mask[12], 0, sizeof (mask) - 12);
}

Expand Down Expand Up @@ -1459,9 +1435,9 @@ macip_create_classify_tables (acl_main_t * am, u32 macip_acl_index)

vnet_classify_add_del_session (cm, tag_table,
mask,
a->rules[i].
is_permit ? ~0 : 0, i, 0,
action, metadata, 1);
a->
rules[i].is_permit ? ~0 : 0,
i, 0, action, metadata, 0, 1);
}
}
}
Expand Down Expand Up @@ -2304,8 +2280,7 @@ static void
if (~0 != am->macip_acl_by_sw_if_index[sw_if_index])
{
send_macip_acl_interface_list_details (am, reg, sw_if_index,
am->
macip_acl_by_sw_if_index
am->macip_acl_by_sw_if_index
[sw_if_index],
mp->context);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vlib/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ typedef union
u32 total_length_not_including_first_buffer;

/**< More opaque data, see ../vnet/vnet/buffer.h */
u32 opaque2[14];
u32 opaque2[16];

/** start of buffer headroom */
CLIB_ALIGN_MARK (headroom, 64);
Expand All @@ -191,7 +191,7 @@ typedef union
#endif
} vlib_buffer_t;

STATIC_ASSERT_SIZEOF (vlib_buffer_t, 128 + VLIB_BUFFER_PRE_DATA_SIZE);
STATIC_ASSERT_SIZEOF (vlib_buffer_t, 192 + VLIB_BUFFER_PRE_DATA_SIZE);
STATIC_ASSERT (VLIB_BUFFER_PRE_DATA_SIZE % CLIB_CACHE_LINE_BYTES == 0,
"VLIB_BUFFER_PRE_DATA_SIZE must be divisible by cache line size");

Expand Down
5 changes: 4 additions & 1 deletion src/vnet/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ typedef struct
u32 flags;
} snat;

u32 unused[6];
u64 value;
u32 unused[6]; // This is not really unused because ipsec uses this data.
// See vnet/ipsec/esp.h. Another unused member variable
// must be defined here for future use.
};
} vnet_buffer_opaque_t;

Expand Down
1 change: 1 addition & 0 deletions src/vnet/classify/classify.api
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ autoreply define classify_add_del_session
vl_api_classify_action_t action [default=0];
u32 metadata [default=0];
u32 match_len;
u64 value;
u8 match[match_len];
};

Expand Down
4 changes: 3 additions & 1 deletion src/vnet/classify/classify_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static void vl_api_classify_add_del_session_t_handler
u32 table_index, hit_next_index, opaque_index, metadata, match_len;
i32 advance;
u8 action;
u64 value;
vnet_classify_table_t *t;

table_index = ntohl (mp->table_index);
Expand All @@ -160,6 +161,7 @@ static void vl_api_classify_add_del_session_t_handler
action = mp->action;
metadata = ntohl (mp->metadata);
match_len = ntohl (mp->match_len);
value = mp->value;

if (pool_is_free_index (cm->tables, table_index))
{
Expand All @@ -177,7 +179,7 @@ static void vl_api_classify_add_del_session_t_handler

rv = vnet_classify_add_del_session
(cm, table_index, mp->match, hit_next_index, opaque_index,
advance, action, metadata, mp->is_add);
advance, action, metadata, value, mp->is_add);

out:
REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
Expand Down
2 changes: 1 addition & 1 deletion src/vnet/classify/flow_classify_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ flow_classify_inline (vlib_main_t * vm,
{
misses++;
vnet_classify_add_del_session (vcm, table_index0,
h0, ~0, 0, 0, 0, 0, 1);
h0, ~0, 0, 0, 0, 0, 0, 1);
/* increment counter */
vnet_classify_find_entry (t0, h0, hash0, now);
}
Expand Down
2 changes: 2 additions & 0 deletions src/vnet/classify/ip_classify.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ ip_classify_inline (vlib_main_t * vm,
{
vnet_buffer (b0)->l2_classify.opaque_index
= e0->opaque_index;
vnet_buffer (b0)->value = e0->value;
vlib_buffer_advance (b0, e0->advance);
next0 = (e0->next_index < node->n_next_nodes) ?
e0->next_index : next0;
Expand All @@ -262,6 +263,7 @@ ip_classify_inline (vlib_main_t * vm,
{
vnet_buffer (b0)->l2_classify.opaque_index
= e0->opaque_index;
vnet_buffer (b0)->value = e0->value;
vlib_buffer_advance (b0, e0->advance);
next0 = (e0->next_index < node->n_next_nodes) ?
e0->next_index : next0;
Expand Down
8 changes: 6 additions & 2 deletions src/vnet/classify/vnet_classify.c
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,7 @@ classify_filter_command_fn (vlib_main_t * vm,
0 /* advance */ ,
0 /* action */ ,
0 /* metadata */ ,
0 /* value */,
1 /* is_add */ );

vec_free (match_vector);
Expand Down Expand Up @@ -2673,7 +2674,8 @@ vnet_classify_add_del_session (vnet_classify_main_t * cm,
u32 hit_next_index,
u32 opaque_index,
i32 advance,
u8 action, u32 metadata, int is_add)
u8 action, u32 metadata, u64 value,
int is_add)
{
vnet_classify_table_t *t;
vnet_classify_entry_5_t _max_e __attribute__ ((aligned (16)));
Expand All @@ -2693,6 +2695,7 @@ vnet_classify_add_del_session (vnet_classify_main_t * cm,
e->last_heard = 0;
e->flags = 0;
e->action = action;
e->value = value;
if (e->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX)
e->metadata = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4,
metadata,
Expand Down Expand Up @@ -2737,6 +2740,7 @@ classify_session_command_fn (vlib_main_t * vm,
i32 advance = 0;
u32 action = 0;
u32 metadata = 0;
u64 value = 0;
int i, rv;

while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
Expand Down Expand Up @@ -2801,7 +2805,7 @@ classify_session_command_fn (vlib_main_t * vm,
rv = vnet_classify_add_del_session (cm, table_index, match,
hit_next_index,
opaque_index, advance,
action, metadata, is_add);
action, metadata, value, is_add);

switch (rv)
{
Expand Down
5 changes: 4 additions & 1 deletion src/vnet/classify/vnet_classify.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ typedef CLIB_PACKED(struct _vnet_classify_entry {
u64 opaque_count;
};

u64 value;

/* Really only need 1 bit */
u8 flags;
#define VNET_CLASSIFY_ENTRY_FREE (1<<0)
Expand Down Expand Up @@ -509,7 +511,8 @@ int vnet_classify_add_del_session (vnet_classify_main_t * cm,
u32 hit_next_index,
u32 opaque_index,
i32 advance,
u8 action, u32 metadata, int is_add);
u8 action, u32 metadata, u64 value,
int is_add);

int vnet_classify_add_del_table (vnet_classify_main_t * cm,
u8 * mask,
Expand Down