Optimize GRE Tunnel and add support for ERSPAN encap
Change GRE tunnel to use the interface type where the same encap node is used as output node for all GRE tunnels, instead of having dedicated output and tx node for each tunnel. This allows for more efficient tunnel creation and deletion at scale tested at 1000's of GRE tunnels. Add support for ERSPAN encap as another tunnel type, in addition to the existing L3 and TEB types. The GRE ERSPAN encap supported is type 2 thus GRE encap need to include sequence number and GRE- ERSPAN tunnel can be created with user secified ERSPAN session ID. The GRE tunnel lookup hash key is updated to inclue tunnel type and session ID, in addition to SIP/DIP and FIB index. Thus, GRE-ERSPAN tunnel can be created, with the appropriate session ID, to be used as output interface for SPAN config to send mirrored packets. Change interface naming so that all GRE tunnels, irrespective of tunnel type, uses "greN" where N is the instance number. Removed interface reuse on tunnel creation and deletion to enable unfied tunnel interface name. Add support of user specified instance on GRE tunnel creation. Thus, N in the "greN" interface name can optionally be specified by user via CLI/API. Optimize GRE tunnel encap DPO stacking to bypass load-balance DPO node since packet output on GRE tunnel always belong to the same flow after 5-tupple hash. Change-Id: Ifa83915744a1a88045c998604777cc3583f4da52 Signed-off-by: John Lo <loj@cisco.com>
This commit is contained in:
+23
-11
@@ -13055,10 +13055,12 @@ api_gre_add_del_tunnel (vat_main_t * vam)
|
||||
u8 is_add = 1;
|
||||
u8 ipv4_set = 0;
|
||||
u8 ipv6_set = 0;
|
||||
u8 teb = 0;
|
||||
u8 t_type = GRE_TUNNEL_TYPE_L3;
|
||||
u8 src_set = 0;
|
||||
u8 dst_set = 0;
|
||||
u32 outer_fib_id = 0;
|
||||
u32 session_id = 0;
|
||||
u32 instance = ~0;
|
||||
int ret;
|
||||
|
||||
memset (&src4, 0, sizeof src4);
|
||||
@@ -13070,6 +13072,8 @@ api_gre_add_del_tunnel (vat_main_t * vam)
|
||||
{
|
||||
if (unformat (line_input, "del"))
|
||||
is_add = 0;
|
||||
else if (unformat (line_input, "instance %d", &instance))
|
||||
;
|
||||
else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
|
||||
{
|
||||
src_set = 1;
|
||||
@@ -13093,7 +13097,9 @@ api_gre_add_del_tunnel (vat_main_t * vam)
|
||||
else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
|
||||
;
|
||||
else if (unformat (line_input, "teb"))
|
||||
teb = 1;
|
||||
t_type = GRE_TUNNEL_TYPE_TEB;
|
||||
else if (unformat (line_input, "erspan %d", &session_id))
|
||||
t_type = GRE_TUNNEL_TYPE_ERSPAN;
|
||||
else
|
||||
{
|
||||
errmsg ("parse error '%U'", format_unformat_error, line_input);
|
||||
@@ -13130,9 +13136,11 @@ api_gre_add_del_tunnel (vat_main_t * vam)
|
||||
clib_memcpy (&mp->src_address, &src6, 16);
|
||||
clib_memcpy (&mp->dst_address, &dst6, 16);
|
||||
}
|
||||
mp->outer_fib_id = ntohl (outer_fib_id);
|
||||
mp->instance = htonl (instance);
|
||||
mp->outer_fib_id = htonl (outer_fib_id);
|
||||
mp->is_add = is_add;
|
||||
mp->teb = teb;
|
||||
mp->session_id = htons ((u16) session_id);
|
||||
mp->tunnel_type = t_type;
|
||||
mp->is_ipv6 = ipv6_set;
|
||||
|
||||
S (mp);
|
||||
@@ -13147,11 +13155,12 @@ static void vl_api_gre_tunnel_details_t_handler
|
||||
ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
|
||||
ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
|
||||
|
||||
print (vam->ofp, "%11d%24U%24U%6d%14d",
|
||||
print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
|
||||
ntohl (mp->sw_if_index),
|
||||
ntohl (mp->instance),
|
||||
format_ip46_address, &src, IP46_TYPE_ANY,
|
||||
format_ip46_address, &dst, IP46_TYPE_ANY,
|
||||
mp->teb, ntohl (mp->outer_fib_id));
|
||||
mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
|
||||
}
|
||||
|
||||
static void vl_api_gre_tunnel_details_t_handler_json
|
||||
@@ -13171,6 +13180,7 @@ static void vl_api_gre_tunnel_details_t_handler_json
|
||||
|
||||
vat_json_init_object (node);
|
||||
vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
|
||||
vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
|
||||
if (!mp->is_ipv6)
|
||||
{
|
||||
clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
|
||||
@@ -13185,9 +13195,10 @@ static void vl_api_gre_tunnel_details_t_handler_json
|
||||
clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
|
||||
vat_json_object_add_ip6 (node, "dst_address", ip6);
|
||||
}
|
||||
vat_json_object_add_uint (node, "teb", mp->teb);
|
||||
vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
|
||||
vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
|
||||
vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
|
||||
vat_json_object_add_uint (node, "session_id", mp->session_id);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -13216,9 +13227,9 @@ api_gre_tunnel_dump (vat_main_t * vam)
|
||||
|
||||
if (!vam->json_output)
|
||||
{
|
||||
print (vam->ofp, "%11s%24s%24s%6s%14s",
|
||||
"sw_if_index", "src_address", "dst_address", "teb",
|
||||
"outer_fib_id");
|
||||
print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
|
||||
"sw_if_index", "instance", "src_address", "dst_address",
|
||||
"tunnel_type", "outer_fib_id", "session_id");
|
||||
}
|
||||
|
||||
/* Get list of gre-tunnel interfaces */
|
||||
@@ -22885,7 +22896,8 @@ _(geneve_add_del_tunnel, \
|
||||
_(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
|
||||
_(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
|
||||
_(gre_add_del_tunnel, \
|
||||
"src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
|
||||
"src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
|
||||
"[teb | erspan <session-id>] [del]") \
|
||||
_(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
|
||||
_(l2_fib_clear_table, "") \
|
||||
_(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
|
||||
|
||||
@@ -136,7 +136,8 @@ _(ACL_IN_USE_OUTBOUND, -143, "Outbound ACL in use") \
|
||||
_(INIT_FAILED, -144, "Initialization Failed") \
|
||||
_(NETLINK_ERROR, -145, "netlink error") \
|
||||
_(BIER_BSL_UNSUP, -146, "BIER bit-string-length unsupported") \
|
||||
_(INSTANCE_IN_USE, -147, "Instance in use")
|
||||
_(INSTANCE_IN_USE, -147, "Instance in use") \
|
||||
_(INVALID_SESSION_ID, -148, "session ID out of range")
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
+19
-3
@@ -13,18 +13,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
option version = "1.0.0";
|
||||
option version = "1.0.1";
|
||||
|
||||
/** \brief Create or delete a GRE tunnel
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param is_add - Use 1 to create the tunnel, 0 to remove it
|
||||
@param is_ipv6 - Use 0 for IPv4, 1 for IPv6
|
||||
@param tunnel_type - 0: L3, 1: TEB, 2: ERSPAN
|
||||
@param instance - optional unique custom device instance, else ~0.
|
||||
@param src_address - Source IP address
|
||||
@param dst_address - Destination IP address, can be multicast
|
||||
@param outer_fib_id - Encap FIB table ID
|
||||
@param session_id - session for ERSPAN tunnel, range 0-1023
|
||||
*/
|
||||
define gre_add_del_tunnel
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_add;
|
||||
u8 is_ipv6;
|
||||
u8 teb;
|
||||
u8 tunnel_type;
|
||||
u32 instance; /* If non-~0, specifies a custom dev instance */
|
||||
u8 src_address[16];
|
||||
u8 dst_address[16];
|
||||
u32 outer_fib_id;
|
||||
u16 session_id;
|
||||
};
|
||||
|
||||
define gre_add_del_tunnel_reply
|
||||
@@ -45,11 +59,13 @@ define gre_tunnel_details
|
||||
{
|
||||
u32 context;
|
||||
u32 sw_if_index;
|
||||
u32 instance;
|
||||
u8 is_ipv6;
|
||||
u8 teb;
|
||||
u8 tunnel_type;
|
||||
u8 src_address[16];
|
||||
u8 dst_address[16];
|
||||
u32 outer_fib_id;
|
||||
u16 session_id;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
+190
-81
File diff suppressed because it is too large
Load Diff
+128
-63
File diff suppressed because it is too large
Load Diff
@@ -66,8 +66,10 @@ static void vl_api_gre_add_del_tunnel_t_handler
|
||||
memset (a, 0, sizeof (*a));
|
||||
|
||||
a->is_add = mp->is_add;
|
||||
a->teb = mp->teb;
|
||||
a->tunnel_type = mp->tunnel_type;
|
||||
a->is_ipv6 = mp->is_ipv6;
|
||||
a->instance = ntohl (mp->instance);
|
||||
a->session_id = ntohs (mp->session_id);
|
||||
|
||||
/* ip addresses sent in network byte order */
|
||||
if (!mp->is_ipv6)
|
||||
@@ -102,23 +104,25 @@ static void send_gre_tunnel_details
|
||||
|
||||
rmp = vl_msg_api_alloc (sizeof (*rmp));
|
||||
memset (rmp, 0, sizeof (*rmp));
|
||||
rmp->_vl_msg_id = ntohs (VL_API_GRE_TUNNEL_DETAILS);
|
||||
rmp->_vl_msg_id = htons (VL_API_GRE_TUNNEL_DETAILS);
|
||||
if (!is_ipv6)
|
||||
{
|
||||
clib_memcpy (rmp->src_address, &(t->tunnel_src.ip4.as_u8), 4);
|
||||
clib_memcpy (rmp->dst_address, &(t->tunnel_dst.fp_addr.ip4.as_u8), 4);
|
||||
ft = fib_table_get (t->outer_fib_index, FIB_PROTOCOL_IP4);
|
||||
rmp->outer_fib_id = ft->ft_table_id;
|
||||
rmp->outer_fib_id = htonl (ft->ft_table_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
clib_memcpy (rmp->src_address, &(t->tunnel_src.ip6.as_u8), 16);
|
||||
clib_memcpy (rmp->dst_address, &(t->tunnel_dst.fp_addr.ip6.as_u8), 16);
|
||||
ft = fib_table_get (t->outer_fib_index, FIB_PROTOCOL_IP6);
|
||||
rmp->outer_fib_id = ft->ft_table_id;
|
||||
rmp->outer_fib_id = htonl (ft->ft_table_id);
|
||||
}
|
||||
rmp->teb = (GRE_TUNNEL_TYPE_TEB == t->type);
|
||||
rmp->tunnel_type = t->type;
|
||||
rmp->instance = htonl (t->user_instance);
|
||||
rmp->sw_if_index = htonl (t->sw_if_index);
|
||||
rmp->session_id = htons (t->session_id);
|
||||
rmp->context = context;
|
||||
rmp->is_ipv6 = is_ipv6;
|
||||
|
||||
|
||||
+186
-152
File diff suppressed because it is too large
Load Diff
+44
-39
@@ -164,8 +164,10 @@ gre_input (vlib_main_t * vm,
|
||||
protocol1 = h1->protocol;
|
||||
sparse_vec_index2 (gm->next_by_protocol, protocol0, protocol1,
|
||||
&i0, &i1);
|
||||
next0 = vec_elt (gm->next_by_protocol, i0);
|
||||
next1 = vec_elt (gm->next_by_protocol, i1);
|
||||
next0 = vec_elt (gm->next_by_protocol, i0).next_index;
|
||||
next1 = vec_elt (gm->next_by_protocol, i1).next_index;
|
||||
u8 ttype0 = vec_elt (gm->next_by_protocol, i0).tunnel_type;
|
||||
u8 ttype1 = vec_elt (gm->next_by_protocol, i1).tunnel_type;
|
||||
|
||||
b0->error =
|
||||
node->errors[i0 ==
|
||||
@@ -190,22 +192,21 @@ gre_input (vlib_main_t * vm,
|
||||
|
||||
|
||||
/* RPF check for ip4/ip6 input */
|
||||
if (PREDICT_TRUE (next0 == GRE_INPUT_NEXT_IP4_INPUT
|
||||
|| next0 == GRE_INPUT_NEXT_IP6_INPUT
|
||||
|| next0 == GRE_INPUT_NEXT_ETHERNET_INPUT
|
||||
|| next0 == GRE_INPUT_NEXT_MPLS_INPUT))
|
||||
if (PREDICT_TRUE (next0 > GRE_INPUT_NEXT_DROP))
|
||||
{
|
||||
if (is_ipv6)
|
||||
{
|
||||
gre_mk_key6 (&ip6_0->dst_address,
|
||||
&ip6_0->src_address,
|
||||
vnet_buffer (b0)->ip.fib_index, &key0.gtk_v6);
|
||||
vnet_buffer (b0)->ip.fib_index,
|
||||
ttype0, 0, &key0.gtk_v6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gre_mk_key4 (&ip4_0->dst_address,
|
||||
&ip4_0->src_address,
|
||||
vnet_buffer (b0)->ip.fib_index, &key0.gtk_v4);
|
||||
gre_mk_key4 (ip4_0->dst_address,
|
||||
ip4_0->src_address,
|
||||
vnet_buffer (b0)->ip.fib_index,
|
||||
ttype0, 0, &key0.gtk_v4);
|
||||
}
|
||||
|
||||
if ((!is_ipv6 && !gre_match_key4 (&cached_tunnel_key.gtk_v4,
|
||||
@@ -264,22 +265,21 @@ gre_input (vlib_main_t * vm,
|
||||
vnet_buffer (b0)->sw_if_index[VLIB_RX] = tunnel_sw_if_index;
|
||||
|
||||
drop0:
|
||||
if (PREDICT_TRUE (next1 == GRE_INPUT_NEXT_IP4_INPUT
|
||||
|| next1 == GRE_INPUT_NEXT_IP6_INPUT
|
||||
|| next1 == GRE_INPUT_NEXT_ETHERNET_INPUT
|
||||
|| next1 == GRE_INPUT_NEXT_MPLS_INPUT))
|
||||
if (PREDICT_TRUE (next1 > GRE_INPUT_NEXT_DROP))
|
||||
{
|
||||
if (is_ipv6)
|
||||
{
|
||||
gre_mk_key6 (&ip6_1->dst_address,
|
||||
&ip6_1->src_address,
|
||||
vnet_buffer (b1)->ip.fib_index, &key1.gtk_v6);
|
||||
vnet_buffer (b1)->ip.fib_index,
|
||||
ttype1, 0, &key1.gtk_v6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gre_mk_key4 (&ip4_1->dst_address,
|
||||
&ip4_1->src_address,
|
||||
vnet_buffer (b1)->ip.fib_index, &key1.gtk_v4);
|
||||
gre_mk_key4 (ip4_1->dst_address,
|
||||
ip4_1->src_address,
|
||||
vnet_buffer (b1)->ip.fib_index,
|
||||
ttype1, 0, &key1.gtk_v4);
|
||||
}
|
||||
|
||||
if ((!is_ipv6 && !gre_match_key4 (&cached_tunnel_key.gtk_v4,
|
||||
@@ -423,7 +423,8 @@ gre_input (vlib_main_t * vm,
|
||||
h0 = vlib_buffer_get_current (b0);
|
||||
|
||||
i0 = sparse_vec_index (gm->next_by_protocol, h0->protocol);
|
||||
next0 = vec_elt (gm->next_by_protocol, i0);
|
||||
next0 = vec_elt (gm->next_by_protocol, i0).next_index;
|
||||
u8 ttype0 = vec_elt (gm->next_by_protocol, i0).tunnel_type;
|
||||
|
||||
b0->error =
|
||||
node->errors[i0 == SPARSE_VEC_INVALID_INDEX
|
||||
@@ -440,22 +441,21 @@ gre_input (vlib_main_t * vm,
|
||||
so we can increase counters and help forward node to
|
||||
pick right FIB */
|
||||
/* RPF check for ip4/ip6 input */
|
||||
if (PREDICT_TRUE (next0 == GRE_INPUT_NEXT_IP4_INPUT
|
||||
|| next0 == GRE_INPUT_NEXT_IP6_INPUT
|
||||
|| next0 == GRE_INPUT_NEXT_ETHERNET_INPUT
|
||||
|| next0 == GRE_INPUT_NEXT_MPLS_INPUT))
|
||||
if (PREDICT_TRUE (next0 > GRE_INPUT_NEXT_DROP))
|
||||
{
|
||||
if (is_ipv6)
|
||||
{
|
||||
gre_mk_key6 (&ip6_0->dst_address,
|
||||
&ip6_0->src_address,
|
||||
vnet_buffer (b0)->ip.fib_index, &key0.gtk_v6);
|
||||
vnet_buffer (b0)->ip.fib_index,
|
||||
ttype0, 0, &key0.gtk_v6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gre_mk_key4 (&ip4_0->dst_address,
|
||||
&ip4_0->src_address,
|
||||
vnet_buffer (b0)->ip.fib_index, &key0.gtk_v4);
|
||||
gre_mk_key4 (ip4_0->dst_address,
|
||||
ip4_0->src_address,
|
||||
vnet_buffer (b0)->ip.fib_index,
|
||||
ttype0, 0, &key0.gtk_v4);
|
||||
}
|
||||
|
||||
if ((!is_ipv6 && !gre_match_key4 (&cached_tunnel_key.gtk_v4,
|
||||
@@ -592,9 +592,7 @@ VLIB_REGISTER_NODE (gre4_input_node) = {
|
||||
.format_trace = format_gre_rx_trace,
|
||||
.unformat_buffer = unformat_gre_header,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
VLIB_REGISTER_NODE (gre6_input_node) = {
|
||||
.function = gre6_input,
|
||||
.name = "gre6-input",
|
||||
@@ -617,17 +615,19 @@ VLIB_REGISTER_NODE (gre6_input_node) = {
|
||||
.format_trace = format_gre_rx_trace,
|
||||
.unformat_buffer = unformat_gre_header,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
VLIB_NODE_FUNCTION_MULTIARCH (gre4_input_node, gre4_input)
|
||||
VLIB_NODE_FUNCTION_MULTIARCH (gre6_input_node, gre6_input)
|
||||
void
|
||||
gre_register_input_protocol (vlib_main_t * vm,
|
||||
gre_protocol_t protocol, u32 node_index)
|
||||
/* *INDENT-ON* */
|
||||
|
||||
void
|
||||
gre_register_input_protocol (vlib_main_t * vm,
|
||||
gre_protocol_t protocol, u32 node_index,
|
||||
gre_tunnel_type_t tunnel_type)
|
||||
{
|
||||
gre_main_t *em = &gre_main;
|
||||
gre_protocol_info_t *pi;
|
||||
u16 *n;
|
||||
next_info_t *n;
|
||||
u32 i;
|
||||
|
||||
{
|
||||
@@ -638,6 +638,7 @@ VLIB_NODE_FUNCTION_MULTIARCH (gre6_input_node, gre6_input)
|
||||
|
||||
pi = gre_get_protocol_info (em, protocol);
|
||||
pi->node_index = node_index;
|
||||
pi->tunnel_type = tunnel_type;
|
||||
pi->next_index = vlib_node_add_next (vm, gre4_input_node.index, node_index);
|
||||
i = vlib_node_add_next (vm, gre6_input_node.index, node_index);
|
||||
ASSERT (i == pi->next_index);
|
||||
@@ -645,7 +646,8 @@ VLIB_NODE_FUNCTION_MULTIARCH (gre6_input_node, gre6_input)
|
||||
/* Setup gre protocol -> next index sparse vector mapping. */
|
||||
n = sparse_vec_validate (em->next_by_protocol,
|
||||
clib_host_to_net_u16 (protocol));
|
||||
n[0] = pi->next_index;
|
||||
n->next_index = pi->next_index;
|
||||
n->tunnel_type = tunnel_type;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -689,14 +691,17 @@ gre_input_init (vlib_main_t * vm)
|
||||
mpls_unicast_input = vlib_get_node_by_name (vm, (u8 *) "mpls-input");
|
||||
ASSERT (mpls_unicast_input);
|
||||
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_teb, ethernet_input->index);
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_teb,
|
||||
ethernet_input->index, GRE_TUNNEL_TYPE_TEB);
|
||||
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_ip4, ip4_input->index);
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_ip4,
|
||||
ip4_input->index, GRE_TUNNEL_TYPE_L3);
|
||||
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_ip6, ip6_input->index);
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_ip6,
|
||||
ip6_input->index, GRE_TUNNEL_TYPE_L3);
|
||||
|
||||
gre_register_input_protocol (vm, GRE_PROTOCOL_mpls_unicast,
|
||||
mpls_unicast_input->index);
|
||||
mpls_unicast_input->index, GRE_TUNNEL_TYPE_L3);
|
||||
|
||||
ip4_register_protocol (IP_PROTOCOL_GRE, gre4_input_node.index);
|
||||
ip6_register_protocol (IP_PROTOCOL_GRE, gre6_input_node.index);
|
||||
|
||||
@@ -24,6 +24,7 @@ _ (0x86DD, ip6) \
|
||||
_ (0x6558, teb) \
|
||||
_ (0x0806, arp) \
|
||||
_ (0x8847, mpls_unicast) \
|
||||
_ (0x88BE, erspan) \
|
||||
_ (0x894F, nsh)
|
||||
|
||||
typedef enum
|
||||
@@ -54,6 +55,111 @@ typedef struct
|
||||
u16 protocol;
|
||||
} gre_header_t;
|
||||
|
||||
/* From draft-foschiano-erspan-03.txt
|
||||
|
||||
Different frame variants known as "ERSPAN Types" can be
|
||||
distinguished based on the GRE "Protocol Type" field value: Type I
|
||||
and II's value is 0x88BE while Type III's is 0x22EB [ETYPES].
|
||||
|
||||
GRE header for ERSPAN Type II encapsulation (8 octets [34:41])
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|0|0|0|1|0|00000|000000000|00000| Protocol Type for ERSPAN |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Sequence Number (increments per packet per session) |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
Note that in the above GRE header [RFC1701] out of the C, R, K, S,
|
||||
s, Recur, Flags, Version fields only S (bit 03) may be set to 1. The
|
||||
other fields are always set to zero.
|
||||
|
||||
ERSPAN Type II's frame format also adds a special 8-octet ERSPAN
|
||||
"feature" header on top of the MAC/IPv4/GRE headers to enclose the
|
||||
raw mirrored frames.
|
||||
|
||||
The ERSPAN Type II feature header is described below:
|
||||
|
||||
ERSPAN Type II header (8 octets [42:49])
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Ver | VLAN | COS | En|T| Session ID |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Reserved | Index |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
The various fields of the above header are described in this table:
|
||||
|
||||
Field Position Length Definition
|
||||
[octet:bit] (bits)
|
||||
|
||||
Ver [42:0] 4 ERSPAN Encapsulation version.
|
||||
This indicates the version of
|
||||
the ERSPAN encapsulation
|
||||
specification. Set to 0x1 for
|
||||
Type II.
|
||||
|
||||
VLAN [42:4] 12 Original VLAN of the frame,
|
||||
mirrored from the source.
|
||||
If the En field is set to 11,
|
||||
the value of VLAN is undefined.
|
||||
|
||||
COS [44:0] 3 Original class of service of the
|
||||
frame, mirrored from the source.
|
||||
|
||||
En [44:3] 2 The trunk encapsulation type
|
||||
associated with the ERSPAN source
|
||||
port for ingress ERSPAN traffic.
|
||||
|
||||
The possible values are:
|
||||
00-originally without VLAN tag
|
||||
01-originally ISL encapsulated
|
||||
10-originally 802.1Q encapsulated
|
||||
11-VLAN tag preserved in frame.
|
||||
|
||||
T [44:5] 1 This bit indicates that the frame
|
||||
copy encapsulated in the ERSPAN
|
||||
packet has been truncated. This
|
||||
occurs if the ERSPAN encapsulated
|
||||
frame exceeds the configured MTU.
|
||||
|
||||
Session ID [44:6] 10 Identification associated with
|
||||
(ERSPAN ID) each ERSPAN session. Must be
|
||||
unique between the source and the
|
||||
receiver(s). (See section below.)
|
||||
|
||||
Reserved [46:0] 12 All bits are set to zero
|
||||
|
||||
Index [47:4] 20 A 20 bit index/port number
|
||||
associated with the ERSPAN
|
||||
traffic's port and
|
||||
direction (ingress/egress). N.B.:
|
||||
This field is platform dependent.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
typedef CLIB_PACKED (struct {
|
||||
u32 seq_num;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u16 ver_vlan;
|
||||
u16 cos_en_t_session;
|
||||
u32 res_index;
|
||||
} t2;
|
||||
u64 t2_u64;
|
||||
};
|
||||
}) erspan_t2_t;
|
||||
|
||||
typedef CLIB_PACKED (struct {
|
||||
gre_header_t gre;
|
||||
erspan_t2_t erspan;
|
||||
}) erspan_t2_header_t;
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* included_vnet_gre_packet_h */
|
||||
|
||||
/*
|
||||
|
||||
+12
-3
@@ -87,7 +87,8 @@ span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0,
|
||||
if (mirror_frames[i] == 0)
|
||||
{
|
||||
if (sf == SPAN_FEAT_L2)
|
||||
mirror_frames[i] = vlib_get_frame_to_node (vnm->vlib_main, l2output_node.index);
|
||||
mirror_frames[i] = vlib_get_frame_to_node (vnm->vlib_main,
|
||||
l2output_node.index);
|
||||
else
|
||||
mirror_frames[i] = vnet_get_frame_to_sw_interface (vnm, i);
|
||||
}
|
||||
@@ -108,8 +109,16 @@ span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0,
|
||||
span_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
|
||||
t->src_sw_if_index = sw_if_index0;
|
||||
t->mirror_sw_if_index = i;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
/* Enable this path to allow packet trace of SPAN packets.
|
||||
Note that all SPAN packets will show up on the trace output
|
||||
with the first SPAN packet (since they are in the same frame)
|
||||
thus making trace output of the original packet confusing */
|
||||
mirror_frames[i]->flags |= VLIB_FRAME_TRACE;
|
||||
c0->flags |= VLIB_BUFFER_IS_TRACED;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}));
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
@@ -795,10 +795,6 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm,
|
||||
error = clib_error_return (0, "tunnel does not exist...");
|
||||
goto done;
|
||||
|
||||
case VNET_API_ERROR_INVALID_ARGUMENT:
|
||||
error = clib_error_return (0, "Invalid argument");
|
||||
goto done;
|
||||
|
||||
case VNET_API_ERROR_INSTANCE_IN_USE:
|
||||
error = clib_error_return (0, "Instance is in use");
|
||||
goto done;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <vnet/l2/l2_input.h>
|
||||
#include <vnet/srv6/sr.h>
|
||||
#include <vnet/srmpls/sr_mpls.h>
|
||||
#include <vnet/gre/gre.h>
|
||||
#include <vnet/vxlan-gpe/vxlan_gpe.h>
|
||||
#include <vnet/geneve/geneve.h>
|
||||
#include <vnet/classify/policer_classify.h>
|
||||
@@ -1622,9 +1623,14 @@ static void *vl_api_gre_add_del_tunnel_t_print
|
||||
(ip46_address_t *) & (mp->src_address),
|
||||
mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
|
||||
|
||||
if (mp->teb)
|
||||
s = format (s, "instance %d ", ntohl (mp->instance));
|
||||
|
||||
if (mp->tunnel_type == GRE_TUNNEL_TYPE_TEB)
|
||||
s = format (s, "teb ");
|
||||
|
||||
if (mp->tunnel_type == GRE_TUNNEL_TYPE_ERSPAN)
|
||||
s = format (s, "erspan %d ", ntohs (mp->session_id));
|
||||
|
||||
if (mp->outer_fib_id)
|
||||
s = format (s, "outer-fib-id %d ", ntohl (mp->outer_fib_id));
|
||||
|
||||
|
||||
+8
-2
@@ -18,6 +18,12 @@ from scapy.volatile import RandMAC, RandIP
|
||||
from util import ppp, ppc
|
||||
|
||||
|
||||
class GreTunnelTypes:
|
||||
TT_L3 = 0
|
||||
TT_TEB = 1
|
||||
TT_ERSPAN = 2
|
||||
|
||||
|
||||
class TestGRE(VppTestCase):
|
||||
""" GRE Test Case """
|
||||
|
||||
@@ -720,10 +726,10 @@ class TestGRE(VppTestCase):
|
||||
#
|
||||
gre_if1 = VppGreInterface(self, self.pg0.local_ip4,
|
||||
"2.2.2.2",
|
||||
is_teb=1)
|
||||
type=GreTunnelTypes.TT_TEB)
|
||||
gre_if2 = VppGreInterface(self, self.pg0.local_ip4,
|
||||
"2.2.2.3",
|
||||
is_teb=1)
|
||||
type=GreTunnelTypes.TT_TEB)
|
||||
gre_if1.add_vpp_config()
|
||||
gre_if2.add_vpp_config()
|
||||
|
||||
|
||||
+1
-1
@@ -252,7 +252,7 @@ class TestSpan(VppTestCase):
|
||||
|
||||
gre_if = VppGreInterface(self, self.pg2.local_ip4,
|
||||
self.pg2.remote_ip4,
|
||||
is_teb=1)
|
||||
type=1)
|
||||
|
||||
gre_if.add_vpp_config()
|
||||
gre_if.admin_up()
|
||||
|
||||
@@ -8,7 +8,8 @@ class VppGreInterface(VppInterface):
|
||||
VPP GRE interface
|
||||
"""
|
||||
|
||||
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0):
|
||||
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
|
||||
session=0):
|
||||
""" Create VPP GRE interface """
|
||||
self._sw_if_index = 0
|
||||
super(VppGreInterface, self).__init__(test)
|
||||
@@ -16,14 +17,16 @@ class VppGreInterface(VppInterface):
|
||||
self.t_src = src_ip
|
||||
self.t_dst = dst_ip
|
||||
self.t_outer_fib = outer_fib_id
|
||||
self.t_is_teb = is_teb
|
||||
self.t_type = type
|
||||
self.t_session = session
|
||||
|
||||
def add_vpp_config(self):
|
||||
s = socket.inet_pton(socket.AF_INET, self.t_src)
|
||||
d = socket.inet_pton(socket.AF_INET, self.t_dst)
|
||||
r = self.test.vapi.gre_tunnel_add_del(s, d,
|
||||
outer_fib_id=self.t_outer_fib,
|
||||
is_teb=self.t_is_teb)
|
||||
tunnel_type=self.t_type,
|
||||
session_id=self.t_session)
|
||||
self._sw_if_index = r.sw_if_index
|
||||
self.generate_remote_hosts()
|
||||
self._test.registry.register(self, self._test.logger)
|
||||
@@ -34,6 +37,8 @@ class VppGreInterface(VppInterface):
|
||||
self.unconfig()
|
||||
self.test.vapi.gre_tunnel_add_del(s, d,
|
||||
outer_fib_id=self.t_outer_fib,
|
||||
tunnel_type=self.t_type,
|
||||
session_id=self.t_session,
|
||||
is_add=0)
|
||||
|
||||
def __str__(self):
|
||||
@@ -48,7 +53,8 @@ class VppGre6Interface(VppInterface):
|
||||
VPP GRE IPv6 interface
|
||||
"""
|
||||
|
||||
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0):
|
||||
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
|
||||
session=0):
|
||||
""" Create VPP GRE interface """
|
||||
self._sw_if_index = 0
|
||||
super(VppGre6Interface, self).__init__(test)
|
||||
@@ -56,14 +62,16 @@ class VppGre6Interface(VppInterface):
|
||||
self.t_src = src_ip
|
||||
self.t_dst = dst_ip
|
||||
self.t_outer_fib = outer_fib_id
|
||||
self.t_is_teb = is_teb
|
||||
self.t_type = type
|
||||
self.t_session = session
|
||||
|
||||
def add_vpp_config(self):
|
||||
s = socket.inet_pton(socket.AF_INET6, self.t_src)
|
||||
d = socket.inet_pton(socket.AF_INET6, self.t_dst)
|
||||
r = self.test.vapi.gre_tunnel_add_del(s, d,
|
||||
outer_fib_id=self.t_outer_fib,
|
||||
is_teb=self.t_is_teb,
|
||||
tunnel_type=self.t_type,
|
||||
session_id=self.t_session,
|
||||
is_ip6=1)
|
||||
self._sw_if_index = r.sw_if_index
|
||||
self.generate_remote_hosts()
|
||||
@@ -75,6 +83,8 @@ class VppGre6Interface(VppInterface):
|
||||
self.unconfig()
|
||||
self.test.vapi.gre_tunnel_add_del(s, d,
|
||||
outer_fib_id=self.t_outer_fib,
|
||||
tunnel_type=self.t_type,
|
||||
session_id=self.t_session,
|
||||
is_add=0,
|
||||
is_ip6=1)
|
||||
|
||||
|
||||
@@ -986,7 +986,9 @@ class VppPapiProvider(object):
|
||||
src_address,
|
||||
dst_address,
|
||||
outer_fib_id=0,
|
||||
is_teb=0,
|
||||
tunnel_type=0,
|
||||
instance=0xFFFFFFFF,
|
||||
session_id=0,
|
||||
is_add=1,
|
||||
is_ip6=0):
|
||||
""" Add a GRE tunnel
|
||||
@@ -994,19 +996,23 @@ class VppPapiProvider(object):
|
||||
:param src_address:
|
||||
:param dst_address:
|
||||
:param outer_fib_id: (Default value = 0)
|
||||
:param tunnel_type: (Default value = 0)
|
||||
:param instance: (Default value = 0xFFFFFFFF)
|
||||
:param session_id: (Defalt value = 0)
|
||||
:param is_add: (Default value = 1)
|
||||
:param is_ipv6: (Default value = 0)
|
||||
:param is_teb: (Default value = 0)
|
||||
"""
|
||||
|
||||
return self.api(
|
||||
self.papi.gre_add_del_tunnel,
|
||||
{'is_add': is_add,
|
||||
'is_ipv6': is_ip6,
|
||||
'teb': is_teb,
|
||||
'tunnel_type': tunnel_type,
|
||||
'instance': instance,
|
||||
'src_address': src_address,
|
||||
'dst_address': dst_address,
|
||||
'outer_fib_id': outer_fib_id}
|
||||
'outer_fib_id': outer_fib_id,
|
||||
'session_id': session_id}
|
||||
)
|
||||
|
||||
def udp_encap_add_del(self,
|
||||
|
||||
Reference in New Issue
Block a user