return session_lookup_del_connection (ts);
}
+static u32
+session_lookup_action_to_session (u32 action_index)
+{
+ if (action_index != SESSION_RULES_TABLE_ACTION_DROP)
+ return action_index;
+ return SESSION_INVALID_INDEX;
+}
+
static stream_session_t *
-session_lookup_app_listen_session (u32 app_index)
+session_lookup_app_listen_session (u32 app_index, u8 fib_proto,
+ u8 transport_proto)
{
application_t *app;
app = application_get (app_index);
if (!app)
return 0;
- if (application_n_listeners (app) != 1)
- {
- clib_warning ("there should be one and only one listener %d",
- hash_elts (app->listeners_table));
- return 0;
- }
-
- return application_first_listener (app);
+ return application_first_listener (app, fib_proto, transport_proto);
}
stream_session_t *
ip4_address_t * lcl, u16 lcl_port,
ip4_address_t * rmt, u16 rmt_port)
{
- u32 action_index;
+ u32 action_index, session_index;
action_index = session_rules_table_lookup4 (srt, proto, lcl, rmt, lcl_port,
rmt_port);
+ session_index = session_lookup_action_to_session (action_index);
/* Nothing sophisticated for now, action index is app index */
- return session_lookup_app_listen_session (action_index);
+ return session_lookup_app_listen_session (session_index, FIB_PROTOCOL_IP4,
+ proto);
}
stream_session_t *
ip6_address_t * lcl, u16 lcl_port,
ip6_address_t * rmt, u16 rmt_port)
{
- u32 action_index;
+ u32 action_index, session_index;
action_index = session_rules_table_lookup6 (srt, proto, lcl, rmt, lcl_port,
rmt_port);
- return session_lookup_app_listen_session (action_index);
+ session_index = session_lookup_action_to_session (action_index);
+ return session_lookup_app_listen_session (session_index, FIB_PROTOCOL_IP6,
+ proto);
}
u64
session_kv6_t kv6;
ip4_address_t lcl4;
ip6_address_t lcl6;
- u32 si;
+ u32 ai;
int rv;
st = session_table_get (table_index);
return kv4.value;
memset (&lcl4, 0, sizeof (lcl4));
- si =
- session_rules_table_lookup4 (&st->session_rules, sep->transport_proto,
- &lcl4, &sep->ip.ip4, 0, sep->port);
- if (si != SESSION_RULES_TABLE_INVALID_INDEX)
- return si;
+ ai = session_rules_table_lookup4 (&st->session_rules,
+ sep->transport_proto, &lcl4,
+ &sep->ip.ip4, 0, sep->port);
+ if (ai != SESSION_RULES_TABLE_INVALID_INDEX)
+ return session_lookup_action_to_session (ai);
}
else
{
return kv6.value;
memset (&lcl6, 0, sizeof (lcl6));
- si =
- session_rules_table_lookup6 (&st->session_rules, sep->transport_proto,
- &lcl6, &sep->ip.ip6, 0, sep->port);
- if (si != SESSION_RULES_TABLE_INVALID_INDEX)
- return si;
+ ai = session_rules_table_lookup6 (&st->session_rules,
+ sep->transport_proto, &lcl6,
+ &sep->ip.ip6, 0, sep->port);
+ if (ai != SESSION_RULES_TABLE_INVALID_INDEX)
+ return session_lookup_action_to_session (ai);
}
return SESSION_INVALID_HANDLE;
}
session_kv6_t kv6;
ip4_address_t lcl4;
ip6_address_t lcl6;
- u32 si;
+ u32 ai;
int rv;
st = session_table_get (table_index);
return (u32) kv4.value;
memset (&lcl4, 0, sizeof (lcl4));
- si =
- session_rules_table_lookup4 (&st->session_rules, sep->transport_proto,
- &lcl4, &sep->ip.ip4, 0, sep->port);
- if (si != SESSION_RULES_TABLE_INVALID_INDEX)
- return si;
+ ai = session_rules_table_lookup4 (&st->session_rules,
+ sep->transport_proto, &lcl4,
+ &sep->ip.ip4, 0, sep->port);
+ if (ai != SESSION_RULES_TABLE_INVALID_INDEX)
+ return session_lookup_action_to_session (ai);
}
else
{
return (u32) kv6.value;
memset (&lcl6, 0, sizeof (lcl6));
- si =
- session_rules_table_lookup6 (&st->session_rules, sep->transport_proto,
- &lcl6, &sep->ip.ip6, 0, sep->port);
- if (si != SESSION_RULES_TABLE_INVALID_INDEX)
- return si;
+ ai = session_rules_table_lookup6 (&st->session_rules,
+ sep->transport_proto, &lcl6,
+ &sep->ip.ip6, 0, sep->port);
+ if (ai != SESSION_RULES_TABLE_INVALID_INDEX)
+ return session_lookup_action_to_session (ai);
}
return SESSION_INVALID_INDEX;
}
if (args->scope & SESSION_RULE_SCOPE_LOCAL)
{
st = app_namespace_get_local_table (app_ns);
- error =
- session_rules_table_add_del (&st->session_rules, &args->table_args);
+ error = session_rules_table_add_del (&st->session_rules,
+ &args->table_args);
}
return error;
}
};
/* *INDENT-ON* */
+void
+session_lookup_dump_rules_table (u32 fib_index, u8 fib_proto,
+ u8 transport_proto)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ session_table_t *st;
+ st = session_table_get_for_fib_index (fib_index, fib_proto);
+ session_rules_table_cli_dump (vm, &st->session_rules, fib_proto,
+ transport_proto);
+}
+
+void
+session_lookup_dump_local_rules_table (u32 table_index, u8 fib_proto,
+ u8 transport_proto)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ session_table_t *st;
+ st = session_table_get (table_index);
+ session_rules_table_cli_dump (vm, &st->session_rules, fib_proto,
+ transport_proto);
+}
+
static clib_error_t *
show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)