srv6-mobile: Update GTP4/6.D function
GTP4/6.D behavior is updated as shown below. 1. When receiving GTP-U message or IPv6 linklocal destination in inner IP, GTP packet is tnralated to SRv6. 2. When receiving T-PDU packet, OuterIP/UDP/GTP headers are stripped off and Inner IP is encapsulated into SRv6 based on L3VPN SRv6 manner. Type: feature Signed-off-by: Tetsuya Murakami <tetsuya.mrk@gmail.com> Change-Id: I6092c98ea80236d54017f84c5b35cca0b645f034 Signed-off-by: Tetsuya Murakami <tetsuya.mrk@gmail.com>
This commit is contained in:
Tetsuya Murakami
committed by
Ole Tr�an
parent
dfc853c0ac
commit
be872a8dda
@ -12,6 +12,7 @@ RUN set -eux; \
|
||||
net-tools \
|
||||
iproute2 \
|
||||
tcpdump \
|
||||
python3-cffi \
|
||||
asciidoc \
|
||||
xmlto \
|
||||
libssl-dev \
|
||||
|
@ -15,6 +15,7 @@ RUN set -eux; \
|
||||
net-tools \
|
||||
iproute2 \
|
||||
tcpdump \
|
||||
python3-cffi \
|
||||
python2.7 \
|
||||
libssl-dev \
|
||||
netcat; \
|
||||
|
@ -68,12 +68,13 @@ static u8 keyword_str[] = "t.m.gtp4.d";
|
||||
static u8 def_str[] =
|
||||
"Transit function with decapsulation for IPv4/GTP tunnel";
|
||||
static u8 param_str[] =
|
||||
"<sr-prefix>/<sr-prefixlen> v6src_prefix <v6src_prefix>/<prefixlen> [nhtype <nhtype>]";
|
||||
"<sr-prefix>/<sr-prefixlen> v6src_prefix <v6src_prefix>/<prefixlen> [nhtype "
|
||||
"<nhtype>] fib-table <id>";
|
||||
|
||||
static u8 *
|
||||
clb_format_srv6_t_m_gtp4_d (u8 * s, va_list * args)
|
||||
{
|
||||
srv6_end_gtp4_param_t *ls_mem = va_arg (*args, void *);
|
||||
srv6_end_gtp4_d_param_t *ls_mem = va_arg (*args, void *);
|
||||
|
||||
s = format (s, "SRv6 T.M.GTP4.D\n\t");
|
||||
|
||||
@ -88,16 +89,18 @@ clb_format_srv6_t_m_gtp4_d (u8 * s, va_list * args)
|
||||
if (ls_mem->nhtype != SRV6_NHTYPE_NONE)
|
||||
{
|
||||
if (ls_mem->nhtype == SRV6_NHTYPE_IPV4)
|
||||
s = format (s, ", NHType IPv4\n");
|
||||
s = format (s, ", NHType IPv4");
|
||||
else if (ls_mem->nhtype == SRV6_NHTYPE_IPV6)
|
||||
s = format (s, ", NHType IPv6\n");
|
||||
s = format (s, ", NHType IPv6");
|
||||
else if (ls_mem->nhtype == SRV6_NHTYPE_NON_IP)
|
||||
s = format (s, ", NHType Non-IP\n");
|
||||
s = format (s, ", NHType Non-IP");
|
||||
else
|
||||
s = format (s, ", NHType Unknow(%d)\n", ls_mem->nhtype);
|
||||
s = format (s, ", NHType Unknow(%d)", ls_mem->nhtype);
|
||||
}
|
||||
else
|
||||
s = format (s, "\n");
|
||||
|
||||
s = format (s, ", FIB table %d", ls_mem->fib_table);
|
||||
|
||||
s = format (s, ", Drop In %d\n", ls_mem->drop_in);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -106,42 +109,65 @@ static uword
|
||||
clb_unformat_srv6_t_m_gtp4_d (unformat_input_t * input, va_list * args)
|
||||
{
|
||||
void **plugin_mem_p = va_arg (*args, void **);
|
||||
srv6_end_gtp4_param_t *ls_mem;
|
||||
srv6_end_gtp4_d_param_t *ls_mem;
|
||||
ip6_address_t sr_prefix;
|
||||
u32 sr_prefixlen;
|
||||
ip6_address_t v6src_prefix;
|
||||
u32 v6src_prefixlen;
|
||||
u8 nhtype;
|
||||
u32 fib_table = 0;
|
||||
bool drop_in = false;
|
||||
u8 nhtype = SRV6_NHTYPE_NONE;
|
||||
bool config = false;
|
||||
|
||||
if (unformat (input, "t.m.gtp4.d %U/%d v6src_prefix %U/%d nhtype ipv4",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen))
|
||||
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_IPV4;
|
||||
if (unformat (
|
||||
input,
|
||||
"t.m.gtp4.d %U/%d v6src_prefix %U/%d nhtype ipv4 fib-table %d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen, &fib_table))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_IPV4;
|
||||
}
|
||||
else if (unformat (input,
|
||||
"t.m.gtp4.d %U/%d v6src_prefix %U/%d nhtype ipv6 "
|
||||
"fib-table %d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen,
|
||||
&fib_table))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_IPV6;
|
||||
}
|
||||
else if (unformat (
|
||||
input, "t.m.gtp4.d %U/%d v6src_prefix %U/%d nhtype non-ip",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_NON_IP;
|
||||
}
|
||||
else if (unformat (input,
|
||||
"t.m.gtp4.d %U/%d v6src_prefix %U/%d fib-table %d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen,
|
||||
&fib_table))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_NONE;
|
||||
}
|
||||
else if (unformat (input, "drop-in"))
|
||||
{
|
||||
drop_in = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (unformat
|
||||
(input, "t.m.gtp4.d %U/%d v6src_prefix %U/%d nhtype ipv6",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen))
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_IPV6;
|
||||
}
|
||||
else
|
||||
if (unformat
|
||||
(input, "t.m.gtp4.d %U/%d v6src_prefix %U/%d nhtype non-ip",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen))
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_NON_IP;
|
||||
}
|
||||
else if (unformat (input, "t.m.gtp4.d %U/%d v6src_prefix %U/%d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
unformat_ip6_address, &v6src_prefix, &v6src_prefixlen))
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_NONE;
|
||||
}
|
||||
else
|
||||
|
||||
if (!config)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -158,6 +184,12 @@ clb_unformat_srv6_t_m_gtp4_d (unformat_input_t * input, va_list * args)
|
||||
|
||||
ls_mem->nhtype = nhtype;
|
||||
|
||||
ls_mem->drop_in = drop_in;
|
||||
|
||||
ls_mem->fib_table = fib_table;
|
||||
ls_mem->fib4_index = ip4_fib_index_from_table_id (fib_table);
|
||||
ls_mem->fib6_index = ip6_fib_index_from_table_id (fib_table);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -170,9 +202,9 @@ clb_creation_srv6_t_m_gtp4_d (ip6_sr_policy_t * sr_policy)
|
||||
static int
|
||||
clb_removal_srv6_t_m_gtp4_d (ip6_sr_policy_t * sr_policy)
|
||||
{
|
||||
srv6_end_gtp4_param_t *ls_mem;
|
||||
srv6_end_gtp4_d_param_t *ls_mem;
|
||||
|
||||
ls_mem = (srv6_end_gtp4_param_t *) sr_policy->plugin_mem;
|
||||
ls_mem = (srv6_end_gtp4_d_param_t *) sr_policy->plugin_mem;
|
||||
|
||||
clib_mem_free (ls_mem);
|
||||
|
||||
|
@ -66,11 +66,16 @@ static u8 param_str[] = "";
|
||||
static u8 *
|
||||
clb_format_srv6_end_m_gtp4_e (u8 * s, va_list * args)
|
||||
{
|
||||
srv6_end_gtp4_param_t *ls_mem = va_arg (*args, void *);
|
||||
srv6_end_gtp4_e_param_t *ls_mem = va_arg (*args, void *);
|
||||
|
||||
s = format (s, "SRv6 End gtp4.e\n\t");
|
||||
s = format (s, "SRv6 End gtp4.e\n");
|
||||
|
||||
s = format (s, "IPv4 address position: %d\n", ls_mem->v4src_position);
|
||||
s = format (s, "\tIPv4 address position: %d\n", ls_mem->v4src_position);
|
||||
|
||||
s = format (s, "\tIPv4 source address: %U\n", format_ip4_address,
|
||||
&ls_mem->v4src_addr);
|
||||
|
||||
s = format (s, "\tFib Table %d\n", ls_mem->fib_table);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -79,10 +84,33 @@ static uword
|
||||
clb_unformat_srv6_end_m_gtp4_e (unformat_input_t * input, va_list * args)
|
||||
{
|
||||
void **plugin_mem_p = va_arg (*args, void **);
|
||||
srv6_end_gtp4_param_t *ls_mem;
|
||||
u32 v4src_position;
|
||||
srv6_end_gtp4_e_param_t *ls_mem;
|
||||
ip4_address_t v4src_addr;
|
||||
u32 v4src_position = 0;
|
||||
u32 fib_table;
|
||||
bool config = false;
|
||||
|
||||
if (!unformat (input, "end.m.gtp4.e v4src_position %d", &v4src_position))
|
||||
memset (&v4src_addr, 0, sizeof (ip4_address_t));
|
||||
|
||||
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (input, "end.m.gtp4.e v4src_position %d fib-table %d",
|
||||
&v4src_position, &fib_table))
|
||||
{
|
||||
config = true;
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp4.e v4src_addr %U fib-table %d",
|
||||
unformat_ip4_address, &v4src_addr, &fib_table))
|
||||
{
|
||||
config = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!config)
|
||||
return 0;
|
||||
|
||||
ls_mem = clib_mem_alloc_aligned_at_offset (sizeof *ls_mem, 0, 0, 1);
|
||||
@ -90,6 +118,11 @@ clb_unformat_srv6_end_m_gtp4_e (unformat_input_t * input, va_list * args)
|
||||
*plugin_mem_p = ls_mem;
|
||||
|
||||
ls_mem->v4src_position = v4src_position;
|
||||
memcpy (&ls_mem->v4src_addr, &v4src_addr, sizeof (ip4_address_t));
|
||||
|
||||
ls_mem->fib_table = fib_table;
|
||||
ls_mem->fib4_index = ip4_fib_index_from_table_id (fib_table);
|
||||
ls_mem->fib6_index = ip6_fib_index_from_table_id (fib_table);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -103,7 +136,7 @@ clb_creation_srv6_end_m_gtp4_e (ip6_sr_localsid_t * localsid)
|
||||
static int
|
||||
clb_removal_srv6_end_m_gtp4_e (ip6_sr_localsid_t * localsid)
|
||||
{
|
||||
srv6_end_gtp4_param_t *ls_mem;
|
||||
srv6_end_gtp4_e_param_t *ls_mem;
|
||||
|
||||
ls_mem = localsid->plugin_mem;
|
||||
|
||||
|
@ -61,12 +61,13 @@ static u8 fn_name[] = "SRv6-End.M.GTP6.D-plugin";
|
||||
static u8 keyword_str[] = "end.m.gtp6.d";
|
||||
static u8 def_str[] =
|
||||
"Endpoint function with dencapsulation for IPv6/GTP tunnel";
|
||||
static u8 param_str[] = "<sr-prefix>/<sr-prefixlen> [nhtype <nhtype>]";
|
||||
static u8 param_str[] =
|
||||
"<sr-prefix>/<sr-prefixlen> [nhtype <nhtype>] fib-table <id>";
|
||||
|
||||
static u8 *
|
||||
clb_format_srv6_end_m_gtp6_d (u8 * s, va_list * args)
|
||||
{
|
||||
srv6_end_gtp6_param_t *ls_mem = va_arg (*args, void *);
|
||||
srv6_end_gtp6_d_param_t *ls_mem = va_arg (*args, void *);
|
||||
|
||||
s = format (s, "SRv6 End gtp6.d\n\t");
|
||||
|
||||
@ -77,16 +78,18 @@ clb_format_srv6_end_m_gtp6_d (u8 * s, va_list * args)
|
||||
if (ls_mem->nhtype != SRV6_NHTYPE_NONE)
|
||||
{
|
||||
if (ls_mem->nhtype == SRV6_NHTYPE_IPV4)
|
||||
s = format (s, ", NHType IPv4\n");
|
||||
s = format (s, ", NHType IPv4");
|
||||
else if (ls_mem->nhtype == SRV6_NHTYPE_IPV6)
|
||||
s = format (s, ", NHType IPv6\n");
|
||||
s = format (s, ", NHType IPv6");
|
||||
else if (ls_mem->nhtype == SRV6_NHTYPE_NON_IP)
|
||||
s = format (s, ", NHType Non-IP\n");
|
||||
s = format (s, ", NHType Non-IP");
|
||||
else
|
||||
s = format (s, ", NHType Unknow(%d)\n", ls_mem->nhtype);
|
||||
s = format (s, ", NHType Unknow(%d)", ls_mem->nhtype);
|
||||
}
|
||||
else
|
||||
s = format (s, "\n");
|
||||
|
||||
s = format (s, " FIB table %d", ls_mem->fib_table);
|
||||
|
||||
s = format (s, " Drop In %d", ls_mem->drop_in);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -95,32 +98,54 @@ static uword
|
||||
clb_unformat_srv6_end_m_gtp6_d (unformat_input_t * input, va_list * args)
|
||||
{
|
||||
void **plugin_mem_p = va_arg (*args, void **);
|
||||
srv6_end_gtp6_param_t *ls_mem;
|
||||
srv6_end_gtp6_d_param_t *ls_mem;
|
||||
ip6_address_t sr_prefix;
|
||||
u32 sr_prefixlen;
|
||||
u8 nhtype;
|
||||
u8 nhtype = SRV6_NHTYPE_NONE;
|
||||
bool drop_in = false;
|
||||
bool config = false;
|
||||
u32 fib_table = 0;
|
||||
|
||||
if (unformat (input, "end.m.gtp6.d %U/%d nh-type ipv4",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen))
|
||||
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_IPV4;
|
||||
if (unformat (input, "end.m.gtp6.d %U/%d nh-type ipv4 fib-table %d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
&fib_table))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_IPV4;
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp6.d %U/%d nh-type ipv6 fib-table %d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
&fib_table))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_IPV6;
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp6.d %U/%d nh-type none",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_NON_IP;
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp6.d %U/%d fib-table %d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen,
|
||||
&fib_table))
|
||||
{
|
||||
config = true;
|
||||
nhtype = SRV6_NHTYPE_NONE;
|
||||
}
|
||||
else if (unformat (input, "drop-in"))
|
||||
{
|
||||
drop_in = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp6.d %U/%d nh-type ipv6",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen))
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_IPV6;
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp6.d %U/%d nh-type none",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen))
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_NON_IP;
|
||||
}
|
||||
else if (unformat (input, "end.m.gtp6.d %U/%d",
|
||||
unformat_ip6_address, &sr_prefix, &sr_prefixlen))
|
||||
{
|
||||
nhtype = SRV6_NHTYPE_NONE;
|
||||
}
|
||||
else
|
||||
|
||||
if (!config)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -134,6 +159,12 @@ clb_unformat_srv6_end_m_gtp6_d (unformat_input_t * input, va_list * args)
|
||||
|
||||
ls_mem->nhtype = nhtype;
|
||||
|
||||
ls_mem->drop_in = drop_in;
|
||||
|
||||
ls_mem->fib_table = fib_table;
|
||||
ls_mem->fib4_index = ip4_fib_index_from_table_id (fib_table);
|
||||
ls_mem->fib6_index = ip6_fib_index_from_table_id (fib_table);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -143,10 +174,16 @@ clb_creation_srv6_end_m_gtp6_d (ip6_sr_localsid_t * localsid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
clb_creation_srv6_end_m_gtp6_d_2 (ip6_sr_policy_t *sr_policy)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
clb_removal_srv6_end_m_gtp6_d (ip6_sr_localsid_t * localsid)
|
||||
{
|
||||
srv6_end_gtp6_param_t *ls_mem;
|
||||
srv6_end_gtp6_d_param_t *ls_mem;
|
||||
|
||||
ls_mem = localsid->plugin_mem;
|
||||
|
||||
@ -155,6 +192,18 @@ clb_removal_srv6_end_m_gtp6_d (ip6_sr_localsid_t * localsid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
clb_removal_srv6_end_m_gtp6_d_2 (ip6_sr_policy_t *sr_policy)
|
||||
{
|
||||
srv6_end_gtp6_d_param_t *ls_mem;
|
||||
|
||||
ls_mem = sr_policy->plugin_mem;
|
||||
|
||||
clib_mem_free (ls_mem);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static clib_error_t *
|
||||
srv6_end_m_gtp6_d_init (vlib_main_t * vm)
|
||||
{
|
||||
@ -193,6 +242,15 @@ srv6_end_m_gtp6_d_init (vlib_main_t * vm)
|
||||
if (rc < 0)
|
||||
clib_error_return (0, "SRv6 Endpoint GTP6.D LocalSID function"
|
||||
"couldn't be registered");
|
||||
|
||||
rc = sr_policy_register_function (
|
||||
vm, fn_name, keyword_str, def_str, param_str, 128, // prefix len
|
||||
&dpo_type, clb_format_srv6_end_m_gtp6_d, clb_unformat_srv6_end_m_gtp6_d,
|
||||
clb_creation_srv6_end_m_gtp6_d_2, clb_removal_srv6_end_m_gtp6_d_2);
|
||||
if (rc < 0)
|
||||
clib_error_return (0, "SRv6 GTP6.D Steering function"
|
||||
"couldn't be registered");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ static u8 param_str[] = "<sr-prefix>/<sr-prefixlen> [nhtype <nhtype>]";
|
||||
static u8 *
|
||||
clb_format_srv6_end_m_gtp6_d_di (u8 * s, va_list * args)
|
||||
{
|
||||
srv6_end_gtp6_param_t *ls_mem = va_arg (*args, void *);
|
||||
srv6_end_gtp6_d_param_t *ls_mem = va_arg (*args, void *);
|
||||
|
||||
s = format (s, "SRv6 End gtp6.d Drop-in\n\t");
|
||||
|
||||
@ -95,7 +95,7 @@ static uword
|
||||
clb_unformat_srv6_end_m_gtp6_d_di (unformat_input_t * input, va_list * args)
|
||||
{
|
||||
void **plugin_mem_p = va_arg (*args, void **);
|
||||
srv6_end_gtp6_param_t *ls_mem;
|
||||
srv6_end_gtp6_d_param_t *ls_mem;
|
||||
ip6_address_t sr_prefix;
|
||||
u32 sr_prefixlen = 0;
|
||||
u8 nhtype;
|
||||
@ -145,7 +145,7 @@ clb_creation_srv6_end_m_gtp6_d_di (ip6_sr_localsid_t * localsid)
|
||||
static int
|
||||
clb_removal_srv6_end_m_gtp6_d_di (ip6_sr_localsid_t * localsid)
|
||||
{
|
||||
srv6_end_gtp6_param_t *ls_mem;
|
||||
srv6_end_gtp6_d_param_t *ls_mem;
|
||||
|
||||
ls_mem = localsid->plugin_mem;
|
||||
|
||||
|
@ -66,15 +66,34 @@ static u8 param_str[] = "";
|
||||
static u8 *
|
||||
clb_format_srv6_end_m_gtp6_e (u8 * s, va_list * args)
|
||||
{
|
||||
s = format (s, "SRv6 End format function unsupported.");
|
||||
srv6_end_gtp6_e_param_t *ls_mem = va_arg (*args, void *);
|
||||
;
|
||||
|
||||
s = format (s, "SRv6 End.M.GTP6.E function.");
|
||||
|
||||
s = format (s, "\tFib Table %d\n", ls_mem->fib_table);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static uword
|
||||
clb_unformat_srv6_end_m_gtp6_e (unformat_input_t * input, va_list * args)
|
||||
{
|
||||
if (!unformat (input, "end.m.gtp6.e"))
|
||||
void **plugin_mem_p = va_arg (*args, void **);
|
||||
srv6_end_gtp6_e_param_t *ls_mem;
|
||||
u32 fib_table;
|
||||
|
||||
if (!unformat (input, "end.m.gtp6.e fib-table %d", &fib_table))
|
||||
return 0;
|
||||
|
||||
ls_mem = clib_mem_alloc_aligned_at_offset (sizeof *ls_mem, 0, 0, 1);
|
||||
clib_memset (ls_mem, 0, sizeof *ls_mem);
|
||||
*plugin_mem_p = ls_mem;
|
||||
|
||||
ls_mem->fib_table = fib_table;
|
||||
ls_mem->fib4_index = ip4_fib_index_from_table_id (fib_table);
|
||||
ls_mem->fib6_index = ip6_fib_index_from_table_id (fib_table);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -87,6 +106,12 @@ clb_creation_srv6_end_m_gtp6_e (ip6_sr_localsid_t * localsid)
|
||||
static int
|
||||
clb_removal_srv6_end_m_gtp6_e (ip6_sr_localsid_t * localsid)
|
||||
{
|
||||
srv6_end_gtp6_e_param_t *ls_mem;
|
||||
|
||||
ls_mem = localsid->plugin_mem;
|
||||
|
||||
clib_mem_free (ls_mem);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
#include <vnet/ip/ip.h>
|
||||
#include <vnet/fib/ip4_fib.h>
|
||||
#include <vnet/fib/ip6_fib.h>
|
||||
#include <vnet/srv6/sr.h>
|
||||
#include <vnet/srv6/sr_packet.h>
|
||||
|
||||
@ -174,14 +176,24 @@ typedef struct
|
||||
|
||||
#define USER_PLANE_SUB_TLV_IE 0x01
|
||||
|
||||
typedef struct srv6_end_gtp6_param_s
|
||||
/* SRv6 mobile Plugin Params */
|
||||
|
||||
/* GTP6.D, GTP6.Di */
|
||||
typedef struct srv6_end_gtp6_d_param_s
|
||||
{
|
||||
u8 nhtype;
|
||||
|
||||
ip6_address_t sr_prefix;
|
||||
u32 sr_prefixlen;
|
||||
} srv6_end_gtp6_param_t;
|
||||
|
||||
bool drop_in;
|
||||
|
||||
u32 fib_table;
|
||||
u32 fib4_index;
|
||||
u32 fib6_index;
|
||||
} srv6_end_gtp6_d_param_t;
|
||||
|
||||
/* GTP6.DT */
|
||||
typedef struct srv6_end_gtp6_dt_param_s
|
||||
{
|
||||
u8 type;
|
||||
@ -191,6 +203,15 @@ typedef struct srv6_end_gtp6_dt_param_s
|
||||
u32 local_fib_index;
|
||||
} srv6_end_gtp6_dt_param_t;
|
||||
|
||||
/* GTP6.E */
|
||||
typedef struct srv6_end_gtp6_e_param_s
|
||||
{
|
||||
u32 fib_table;
|
||||
u32 fib4_index;
|
||||
u32 fib6_index;
|
||||
} srv6_end_gtp6_e_param_t;
|
||||
|
||||
/* GTP4.DT */
|
||||
typedef struct srv6_t_gtp4_dt_param_s
|
||||
{
|
||||
u8 type;
|
||||
@ -200,7 +221,19 @@ typedef struct srv6_t_gtp4_dt_param_s
|
||||
u32 local_fib_index;
|
||||
} srv6_t_gtp4_dt_param_t;
|
||||
|
||||
typedef struct srv6_end_gtp4_param_s
|
||||
/* GTP4.E */
|
||||
typedef struct srv6_end_gtp4_e_param_s
|
||||
{
|
||||
u32 v4src_position;
|
||||
ip4_address_t v4src_addr;
|
||||
|
||||
u32 fib_table;
|
||||
u32 fib4_index;
|
||||
u32 fib6_index;
|
||||
} srv6_end_gtp4_e_param_t;
|
||||
|
||||
/* GTP4.D */
|
||||
typedef struct srv6_end_gtp4_d_param_s
|
||||
{
|
||||
u8 nhtype;
|
||||
|
||||
@ -210,8 +243,12 @@ typedef struct srv6_end_gtp4_param_s
|
||||
ip6_address_t v6src_prefix;
|
||||
u32 v6src_prefixlen;
|
||||
|
||||
u32 v4src_position;
|
||||
} srv6_end_gtp4_param_t;
|
||||
bool drop_in;
|
||||
|
||||
u32 fib_table;
|
||||
u32 fib4_index;
|
||||
u32 fib6_index;
|
||||
} srv6_end_gtp4_d_param_t;
|
||||
|
||||
typedef struct srv6_end_main_v4_s
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -69,9 +69,10 @@ class TestSRv6EndMGTP4E(VppTestCase):
|
||||
pkts = self.create_packets([("A::1", "B::1"), ("C::1", "D::1")])
|
||||
|
||||
self.vapi.cli(
|
||||
"sr localsid address {} behavior end.m.gtp4.e v4src_position 64"
|
||||
.format(pkts[0]['IPv6'].dst))
|
||||
self.logger.info(self.vapi.cli("show sr localsids"))
|
||||
"sr localsid address {} behavior end.m.gtp4.e "
|
||||
.format(pkts[0]['IPv6'].dst) +
|
||||
"v4src_position 64 fib-table 0")
|
||||
self.logger.info(self.vapi.cli("show sr localsid"))
|
||||
|
||||
self.vapi.cli("clear errors")
|
||||
|
||||
@ -150,8 +151,8 @@ class TestSRv6TMGTP4D(VppTestCase):
|
||||
self.vapi.cli("set sr encaps source addr A1::1")
|
||||
self.vapi.cli("sr policy add bsid D4:: next D2:: next D3::")
|
||||
self.vapi.cli(
|
||||
"sr policy add bsid D5:: behavior t.m.gtp4.d"
|
||||
"D4::/32 v6src_prefix C1::/64 nhtype ipv6")
|
||||
"sr policy add bsid D5:: behavior t.m.gtp4.d D4::/32 " +
|
||||
"v6src_prefix C1::/64 nhtype ipv6 fib-table 0 drop-in")
|
||||
self.vapi.cli("sr steer l3 {}/32 via bsid D5::".format(self.ip4_dst))
|
||||
self.vapi.cli("ip route add D2::/32 via {}".format(self.ip6_dst))
|
||||
|
||||
@ -236,11 +237,11 @@ class TestSRv6EndMGTP6E(VppTestCase):
|
||||
pkts = self.create_packets([("A::1", "B::1"), ("C::1", "D::1")])
|
||||
|
||||
self.vapi.cli(
|
||||
"sr localsid prefix {}/64 behavior end.m.gtp6.e"
|
||||
"sr localsid prefix {}/64 behavior end.m.gtp6.e fib-table 0"
|
||||
.format(pkts[0]['IPv6'].dst))
|
||||
self.vapi.cli(
|
||||
"ip route add a1::/64 via {}".format(self.ip6_nhop))
|
||||
self.logger.info(self.vapi.cli("show sr localsids"))
|
||||
self.logger.info(self.vapi.cli("show sr localsid"))
|
||||
|
||||
self.vapi.cli("clear errors")
|
||||
|
||||
@ -316,10 +317,12 @@ class TestSRv6EndMGTP6D(VppTestCase):
|
||||
self.vapi.cli("set sr encaps source addr A1::1")
|
||||
self.vapi.cli("sr policy add bsid D4:: next D2:: next D3::")
|
||||
self.vapi.cli(
|
||||
"sr localsid prefix 2001::/64 behavior end.m.gtp6.d D4::/64")
|
||||
"sr localsid prefix 2001::/64 behavior end.m.gtp6.d " +
|
||||
"D4::/64 fib-table 0 drop-in")
|
||||
self.vapi.cli("ip route add D2::/64 via {}".format(self.ip6_nhop))
|
||||
|
||||
self.logger.info(self.vapi.cli("show sr policies"))
|
||||
self.logger.info(self.vapi.cli("show sr localsid"))
|
||||
|
||||
self.vapi.cli("clear errors")
|
||||
|
||||
@ -334,7 +337,11 @@ class TestSRv6EndMGTP6D(VppTestCase):
|
||||
|
||||
for pkt in capture:
|
||||
self.logger.info(pkt.show2(dump=True))
|
||||
self.logger.info("GTP6.D Address={}".format(
|
||||
self.logger.info("GTP6.D SID0={}".format(
|
||||
str(pkt[IPv6ExtHdrSegmentRouting].addresses[0])))
|
||||
self.logger.info("GTP6.D SID1={}".format(
|
||||
str(pkt[IPv6ExtHdrSegmentRouting].addresses[1])))
|
||||
self.assertEqual(
|
||||
str(pkt[IPv6ExtHdrSegmentRouting].addresses[0]), "d4::c800:0")
|
||||
str(pkt[IPv6ExtHdrSegmentRouting].addresses[0]), "2001::1")
|
||||
self.assertEqual(
|
||||
str(pkt[IPv6ExtHdrSegmentRouting].addresses[1]), "d4::c800:0")
|
||||
|
Reference in New Issue
Block a user