BIER; bi-dir to/from underlay
set and check a special RX interface value as the packet enters and exits a BIER domain Change-Id: I5ff2f0e2d1b3ce0f3598b935f518fc11eb0896ee Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
This commit is contained in:
committed by
Damjan Marion
parent
608f95cddc
commit
fe4e48f617
@@ -72,6 +72,7 @@ bier_disp_dispatch_inline (vlib_main_t * vm,
|
||||
bdei0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
|
||||
hdr0 = vlib_buffer_get_current(b0);
|
||||
bde0 = bier_disp_entry_get(bdei0);
|
||||
vnet_buffer(b0)->ip.adj_index[VLIB_RX] = BIER_RX_ITF;
|
||||
|
||||
/*
|
||||
* header is in network order - flip it, we are about to
|
||||
|
||||
@@ -87,11 +87,10 @@ format_bier_drop_trace (u8 * s, va_list * args)
|
||||
return s;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
VLIB_REGISTER_NODE (bier_drop_node, static) =
|
||||
{
|
||||
.function = bier_drop,.
|
||||
name = "bier-drop",
|
||||
.function = bier_drop,
|
||||
.name = "bier-drop",
|
||||
.vector_size = sizeof (u32),
|
||||
.format_trace = format_bier_drop_trace,
|
||||
.n_next_nodes = 1,
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
#include <vnet/bier/bier_bit_string.h>
|
||||
#include <vnet/ip/ip6_packet.h>
|
||||
|
||||
/**
|
||||
* Special Value of the BIER RX interface
|
||||
*/
|
||||
#define BIER_RX_ITF (~0 - 1)
|
||||
|
||||
/**
|
||||
* Mask and shift values for the fields incorporated
|
||||
* into the header's first word
|
||||
|
||||
@@ -68,7 +68,7 @@ bier_imp_add_or_lock (const bier_table_id_t *bti,
|
||||
pool_get_aligned(bier_imp_pool, bi, CLIB_CACHE_LINE_BYTES);
|
||||
|
||||
bi->bi_tbl = *bti;
|
||||
btii = bier_table_add_or_lock(bti, MPLS_LABEL_INVALID);
|
||||
btii = bier_table_lock(bti);
|
||||
|
||||
/*
|
||||
* init the BIER header we will paint on in the data plane
|
||||
|
||||
@@ -120,30 +120,39 @@ bier_imp_dpo_inline (vlib_main_t * vm,
|
||||
vlib_buffer_advance(b0, -(sizeof(bier_hdr_t) +
|
||||
bier_hdr_len_id_to_num_bytes(bimp0->bi_tbl.bti_hdr_len)));
|
||||
hdr0 = vlib_buffer_get_current(b0);
|
||||
clib_memcpy(hdr0, &bimp0->bi_hdr,
|
||||
(sizeof(bier_hdr_t) +
|
||||
bier_hdr_len_id_to_num_bytes(bimp0->bi_tbl.bti_hdr_len)));
|
||||
/*
|
||||
* Fixup the entropy and protocol, both of which have a
|
||||
* zero value post the paint job
|
||||
*/
|
||||
hdr0->bh_oam_dscp_proto |=
|
||||
clib_host_to_net_u16(bproto << BIER_HDR_PROTO_FIELD_SHIFT);
|
||||
hdr0->bh_first_word |=
|
||||
clib_host_to_net_u32((vnet_buffer(b0)->ip.flow_hash &
|
||||
BIER_HDR_ENTROPY_FIELD_MASK) <<
|
||||
BIER_HDR_ENTROPY_FIELD_SHIFT);
|
||||
|
||||
/*
|
||||
* use TTL 64 for the post enacp MPLS label/BIFT-ID
|
||||
* this we be decremeted in bier_output node.
|
||||
*/
|
||||
vnet_buffer(b0)->mpls.ttl = 65;
|
||||
/* RPF check */
|
||||
if (PREDICT_FALSE(BIER_RX_ITF == vnet_buffer(b0)->ip.adj_index[VLIB_RX]))
|
||||
{
|
||||
next0 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
clib_memcpy(hdr0, &bimp0->bi_hdr,
|
||||
(sizeof(bier_hdr_t) +
|
||||
bier_hdr_len_id_to_num_bytes(bimp0->bi_tbl.bti_hdr_len)));
|
||||
/*
|
||||
* Fixup the entropy and protocol, both of which have a
|
||||
* zero value post the paint job
|
||||
*/
|
||||
hdr0->bh_oam_dscp_proto |=
|
||||
clib_host_to_net_u16(bproto << BIER_HDR_PROTO_FIELD_SHIFT);
|
||||
hdr0->bh_first_word |=
|
||||
clib_host_to_net_u32((vnet_buffer(b0)->ip.flow_hash &
|
||||
BIER_HDR_ENTROPY_FIELD_MASK) <<
|
||||
BIER_HDR_ENTROPY_FIELD_SHIFT);
|
||||
|
||||
/* next node */
|
||||
next0 = bimp0->bi_dpo[fproto].dpoi_next_node;
|
||||
vnet_buffer(b0)->ip.adj_index[VLIB_TX] =
|
||||
bimp0->bi_dpo[fproto].dpoi_index;
|
||||
/*
|
||||
* use TTL 64 for the post enacp MPLS label/BIFT-ID
|
||||
* this we be decremeted in bier_output node.
|
||||
*/
|
||||
vnet_buffer(b0)->mpls.ttl = 65;
|
||||
|
||||
/* next node */
|
||||
next0 = bimp0->bi_dpo[fproto].dpoi_next_node;
|
||||
vnet_buffer(b0)->ip.adj_index[VLIB_TX] =
|
||||
bimp0->bi_dpo[fproto].dpoi_index;
|
||||
}
|
||||
|
||||
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
|
||||
{
|
||||
@@ -194,7 +203,7 @@ VLIB_REGISTER_NODE (bier_imp_ip4_node) = {
|
||||
.format_trace = format_bier_imp_trace,
|
||||
.n_next_nodes = 1,
|
||||
.next_nodes = {
|
||||
[0] = "error-drop",
|
||||
[0] = "bier-drop",
|
||||
}
|
||||
};
|
||||
VLIB_NODE_FUNCTION_MULTIARCH (bier_imp_ip4_node, bier_imp_ip4)
|
||||
|
||||
@@ -329,6 +329,70 @@ bier_table_mk_ecmp (index_t bti)
|
||||
return (bt);
|
||||
}
|
||||
|
||||
|
||||
static index_t
|
||||
bier_table_create (const bier_table_id_t *btid,
|
||||
mpls_label_t local_label)
|
||||
{
|
||||
/*
|
||||
* add a new table
|
||||
*/
|
||||
bier_table_t *bt;
|
||||
index_t bti;
|
||||
u32 key;
|
||||
|
||||
key = bier_table_mk_key(btid);
|
||||
|
||||
pool_get_aligned(bier_table_pool, bt, CLIB_CACHE_LINE_BYTES);
|
||||
bier_table_init(bt, btid, local_label);
|
||||
|
||||
hash_set(bier_tables_by_key, key, bier_table_get_index(bt));
|
||||
bti = bier_table_get_index(bt);
|
||||
|
||||
if (bier_table_is_main(bt))
|
||||
{
|
||||
bt = bier_table_mk_ecmp(bti);
|
||||
|
||||
/*
|
||||
* add whichever mpls-fib or bift we need
|
||||
*/
|
||||
if (local_label != MPLS_LABEL_INVALID)
|
||||
{
|
||||
bt->bt_ll = local_label;
|
||||
bier_table_mk_lfib(bt);
|
||||
}
|
||||
else
|
||||
{
|
||||
bier_table_mk_bift(bt);
|
||||
}
|
||||
}
|
||||
|
||||
return (bti);
|
||||
}
|
||||
|
||||
index_t
|
||||
bier_table_lock (const bier_table_id_t *btid)
|
||||
{
|
||||
bier_table_t *bt;
|
||||
index_t bti;
|
||||
|
||||
bt = bier_table_find(btid);
|
||||
|
||||
if (NULL == bt)
|
||||
{
|
||||
bti = bier_table_create(btid, MPLS_LABEL_INVALID);
|
||||
bt = bier_table_get(bti);
|
||||
}
|
||||
else
|
||||
{
|
||||
bti = bier_table_get_index(bt);
|
||||
}
|
||||
|
||||
bier_table_lock_i(bt);
|
||||
|
||||
return (bti);
|
||||
}
|
||||
|
||||
index_t
|
||||
bier_table_add_or_lock (const bier_table_id_t *btid,
|
||||
mpls_label_t local_label)
|
||||
@@ -379,36 +443,8 @@ bier_table_add_or_lock (const bier_table_id_t *btid,
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* add a new table
|
||||
*/
|
||||
u32 key;
|
||||
|
||||
key = bier_table_mk_key(btid);
|
||||
|
||||
pool_get_aligned(bier_table_pool, bt, CLIB_CACHE_LINE_BYTES);
|
||||
bier_table_init(bt, btid, local_label);
|
||||
|
||||
hash_set(bier_tables_by_key, key, bier_table_get_index(bt));
|
||||
bti = bier_table_get_index(bt);
|
||||
|
||||
if (bier_table_is_main(bt))
|
||||
{
|
||||
bt = bier_table_mk_ecmp(bti);
|
||||
|
||||
/*
|
||||
* add whichever mpls-fib or bift we need
|
||||
*/
|
||||
if (local_label != MPLS_LABEL_INVALID)
|
||||
{
|
||||
bt->bt_ll = local_label;
|
||||
bier_table_mk_lfib(bt);
|
||||
}
|
||||
else
|
||||
{
|
||||
bier_table_mk_bift(bt);
|
||||
}
|
||||
}
|
||||
bti = bier_table_create(btid, local_label);
|
||||
bt = bier_table_get(bti);
|
||||
}
|
||||
|
||||
bier_table_lock_i(bt);
|
||||
|
||||
@@ -91,6 +91,7 @@ STATIC_ASSERT((sizeof(bier_table_t) <= 2*CLIB_CACHE_LINE_BYTES),
|
||||
|
||||
extern index_t bier_table_add_or_lock(const bier_table_id_t *id,
|
||||
mpls_label_t ll);
|
||||
extern index_t bier_table_lock(const bier_table_id_t *id);
|
||||
extern void bier_table_unlock(const bier_table_id_t *id);
|
||||
|
||||
extern void bier_table_route_path_add(const bier_table_id_t *bti,
|
||||
|
||||
@@ -482,6 +482,37 @@ class TestBier(VppTestCase):
|
||||
#
|
||||
self.send_and_expect(self.pg0, [p], self.pg1)
|
||||
|
||||
#
|
||||
# A multicast route to forward post BIER disposition that needs
|
||||
# a check against sending back into the BIER core
|
||||
#
|
||||
bi = VppBierImp(self, bti, 333, chr(0x3) * 32)
|
||||
bi.add_vpp_config()
|
||||
|
||||
route_eg_232_1_1_2 = VppIpMRoute(
|
||||
self,
|
||||
"0.0.0.0",
|
||||
"232.1.1.2", 32,
|
||||
MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
|
||||
paths=[VppMRoutePath(0xffffffff,
|
||||
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
|
||||
proto=DpoProto.DPO_PROTO_BIER,
|
||||
bier_imp=bi.bi_index),
|
||||
VppMRoutePath(self.pg1.sw_if_index,
|
||||
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
|
||||
route_eg_232_1_1_2.add_vpp_config()
|
||||
route_eg_232_1_1_2.update_rpf_id(8192)
|
||||
|
||||
p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
|
||||
MPLS(label=77, ttl=255) /
|
||||
BIER(length=BIERLength.BIER_LEN_256,
|
||||
BitString=chr(255)*32,
|
||||
BFRID=77) /
|
||||
IP(src="1.1.1.1", dst="232.1.1.2") /
|
||||
UDP(sport=1234, dport=1234) /
|
||||
Raw())
|
||||
self.send_and_expect(self.pg0, [p], self.pg1)
|
||||
|
||||
def bier_e2e(self, hdr_len_id, n_bytes, max_bp):
|
||||
""" BIER end-to-end"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user