diff options
author | Florin Coras <fcoras@cisco.com> | 2017-10-17 00:03:13 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2017-10-28 19:56:39 +0000 |
commit | 1c7104514cd40d2377caca36cf40c13b791bc5aa (patch) | |
tree | 2b95bb11dd8658e826ad8cb3fe4d399adbab7e01 /src/vnet/session/session_api.c | |
parent | ae5a02f8235b9a243df09b42e932ae5f238e366b (diff) |
session: rules tables
This introduces 5-tuple lookup tables that may be used to implement
custom session layer actions at connection establishment time (session
layer perspective).
The rules table build mask-match-action lookup trees that for a given
5-tuple key return the action for the first longest match. If rules
overlap, ordering is established by tuple longest match with the
following descending priority: remote ip, local ip, remote port, local
port.
At this time, the only match action supported is to forward packets to
the application identified by the action.
Change-Id: Icbade6fac720fa3979820d50cd7d6137f8b635c3
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/session_api.c')
-rwxr-xr-x | src/vnet/session/session_api.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index 181312cc952..32ef34b0952 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -16,9 +16,10 @@ #include <vnet/vnet.h> #include <vlibmemory/api.h> #include <vnet/session/application.h> +#include <vnet/session/application_interface.h> +#include <vnet/session/session_rules_table.h> #include <vnet/vnet_msg_enum.h> -#include "application_interface.h" #define vl_typedefs /* define message structures */ #include <vnet/vnet_all_api_h.h> @@ -52,6 +53,7 @@ _(UNBIND_SOCK, unbind_sock) \ _(CONNECT_SOCK, connect_sock) \ _(SESSION_ENABLE_DISABLE, session_enable_disable) \ _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \ +_(SESSION_RULE_ADD_DEL, session_rule_add_del) \ static int send_add_segment_callback (u32 api_client_index, const u8 * segment_name, @@ -778,6 +780,42 @@ done: REPLY_MACRO (VL_API_APP_NAMESPACE_ADD_DEL_REPLY); } +static void +vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp) +{ + vl_api_session_rule_add_del_reply_t *rmp; + session_rule_add_del_args_t args; + session_rule_table_add_del_args_t *table_args = &args.table_args; + clib_error_t *error; + u8 fib_proto; + int rv = 0; + + fib_proto = mp->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6; + + table_args->lcl.fp_len = mp->lcl_plen; + table_args->lcl.fp_proto = fib_proto; + table_args->rmt.fp_len = mp->rmt_plen; + table_args->rmt.fp_proto = fib_proto; + table_args->lcl_port = clib_net_to_host_u16 (mp->lcl_port); + table_args->rmt_port = clib_net_to_host_u16 (mp->rmt_port); + table_args->action_index = clib_net_to_host_u32 (mp->action_index); + table_args->is_add = mp->is_add; + args.appns_index = clib_net_to_host_u32 (mp->appns_index); + args.scope = mp->scope; + + memset (&table_args->lcl.fp_addr, 0, sizeof (table_args->lcl.fp_addr)); + memset (&table_args->rmt.fp_addr, 0, sizeof (table_args->rmt.fp_addr)); + ip_set (&table_args->lcl.fp_addr, mp->lcl_ip, mp->is_ip4); + ip_set (&table_args->rmt.fp_addr, mp->rmt_ip, mp->is_ip4); + error = vnet_session_rule_add_del (&args); + if (error) + { + rv = clib_error_get_code (error); + clib_error_report (error); + } + REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY); +} + static clib_error_t * application_reaper_cb (u32 client_index) { |