summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-01-19 11:29:18 -0800
committerDamjan Marion <dmarion@me.com>2019-01-20 22:57:38 +0000
commit6e5f93e70da602cc6923ad1b392cc836fd0a519f (patch)
tree92ce606b4126a64bdf844d46ccc3dba5ee7181ec /src/vnet
parenta74ae5886fb146f8f6ad69769a506b00d8d046ad (diff)
session: add support for vrf in session unformat (VPP-1546)
Change-Id: Ic5ba751c2bd2db9af4a21d3db40cc305d1208c30 Signed-off-by: Florin Coras <fcoras@cisco.com> (cherry picked from commit baee8d498830bbbf54ec76e7c0c887c6373fe985)
Diffstat (limited to 'src/vnet')
-rwxr-xr-xsrc/vnet/session/session_cli.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index ea6e635715f..9da7f5b46b8 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -100,12 +100,14 @@ uword
unformat_stream_session_id (unformat_input_t * input, va_list * args)
{
u8 *proto = va_arg (*args, u8 *);
+ u32 *fib_index = va_arg (*args, u32 *);
ip46_address_t *lcl = va_arg (*args, ip46_address_t *);
ip46_address_t *rmt = va_arg (*args, ip46_address_t *);
u16 *lcl_port = va_arg (*args, u16 *);
u16 *rmt_port = va_arg (*args, u16 *);
u8 *is_ip4 = va_arg (*args, u8 *);
u8 tuple_is_set = 0;
+ u32 vrf = ~0;
clib_memset (lcl, 0, sizeof (*lcl));
clib_memset (rmt, 0, sizeof (*rmt));
@@ -114,10 +116,16 @@ unformat_stream_session_id (unformat_input_t * input, va_list * args)
{
*proto = TRANSPORT_PROTO_TCP;
}
- if (unformat (input, "udp"))
+ else if (unformat (input, "udp"))
{
*proto = TRANSPORT_PROTO_UDP;
}
+ else
+ return 0;
+
+ if (unformat (input, "vrf %u", &vrf))
+ ;
+
if (unformat (input, "%U:%d->%U:%d", unformat_ip4_address, &lcl->ip4,
lcl_port, unformat_ip4_address, &rmt->ip4, rmt_port))
{
@@ -131,6 +139,13 @@ unformat_stream_session_id (unformat_input_t * input, va_list * args)
tuple_is_set = 1;
}
+ if (vrf != ~0)
+ {
+ fib_protocol_t fib_proto;
+ fib_proto = *is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
+ *fib_index = fib_table_find (fib_proto, vrf);
+ }
+
return tuple_is_set;
}
@@ -138,14 +153,14 @@ uword
unformat_stream_session (unformat_input_t * input, va_list * args)
{
stream_session_t **result = va_arg (*args, stream_session_t **);
+ u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
+ ip46_address_t lcl, rmt;
stream_session_t *s;
u8 proto = ~0;
- ip46_address_t lcl, rmt;
- u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
u8 is_ip4 = 0;
- if (!unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt,
- &lcl_port, &rmt_port, &is_ip4))
+ if (!unformat (input, "%U", unformat_stream_session_id, &proto, &fib_index,
+ &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
return 0;
if (is_ip4)
@@ -176,8 +191,8 @@ unformat_transport_connection (unformat_input_t * input, va_list * args)
u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
u8 is_ip4 = 0;
- if (!unformat (input, "%U", unformat_stream_session_id, &proto, &lcl, &rmt,
- &lcl_port, &rmt_port, &is_ip4))
+ if (!unformat (input, "%U", unformat_stream_session_id, &fib_index, &proto,
+ &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
return 0;
proto = (proto == (u8) ~ 0) ? suggested_proto : proto;