aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-09-24 23:38:37 -0700
committerDamjan Marion <dmarion@me.com>2018-09-25 11:59:37 +0000
commitfe4e48f617f3e0f62880adebdcfb5989aa4e6db7 (patch)
treeb5d0778bc798a9119760992f878ff2e3666ea1ee /src/vnet
parent608f95cddc4e1e78b4d3ac3b2c3f1ae86f1fa632 (diff)
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>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/bier/bier_disp_dispatch_node.c1
-rw-r--r--src/vnet/bier/bier_drop.c5
-rw-r--r--src/vnet/bier/bier_hdr_inlines.h5
-rw-r--r--src/vnet/bier/bier_imp.c2
-rw-r--r--src/vnet/bier/bier_imp_node.c59
-rw-r--r--src/vnet/bier/bier_table.c96
-rw-r--r--src/vnet/bier/bier_table.h1
7 files changed, 110 insertions, 59 deletions
diff --git a/src/vnet/bier/bier_disp_dispatch_node.c b/src/vnet/bier/bier_disp_dispatch_node.c
index 40d0a293658..0dbcada78ed 100644
--- a/src/vnet/bier/bier_disp_dispatch_node.c
+++ b/src/vnet/bier/bier_disp_dispatch_node.c
@@ -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
diff --git a/src/vnet/bier/bier_drop.c b/src/vnet/bier/bier_drop.c
index eb873acf7ba..da6d5668c7a 100644
--- a/src/vnet/bier/bier_drop.c
+++ b/src/vnet/bier/bier_drop.c
@@ -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,
diff --git a/src/vnet/bier/bier_hdr_inlines.h b/src/vnet/bier/bier_hdr_inlines.h
index 4437dc82e24..d58926e97ef 100644
--- a/src/vnet/bier/bier_hdr_inlines.h
+++ b/src/vnet/bier/bier_hdr_inlines.h
@@ -27,6 +27,11 @@
#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
*/
diff --git a/src/vnet/bier/bier_imp.c b/src/vnet/bier/bier_imp.c
index 0c87d1724b4..87a8f909a85 100644
--- a/src/vnet/bier/bier_imp.c
+++ b/src/vnet/bier/bier_imp.c
@@ -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
diff --git a/src/vnet/bier/bier_imp_node.c b/src/vnet/bier/bier_imp_node.c
index 9c09d6722bc..0f1820b4028 100644
--- a/src/vnet/bier/bier_imp_node.c
+++ b/src/vnet/bier/bier_imp_node.c
@@ -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;
-
- /* next node */
- next0 = bimp0->bi_dpo[fproto].dpoi_next_node;
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] =
- bimp0->bi_dpo[fproto].dpoi_index;
+
+ /* 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);
+
+ /*
+ * 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)
diff --git a/src/vnet/bier/bier_table.c b/src/vnet/bier/bier_table.c
index 3ecda105457..edfb754ecc1 100644
--- a/src/vnet/bier/bier_table.c
+++ b/src/vnet/bier/bier_table.c
@@ -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);
diff --git a/src/vnet/bier/bier_table.h b/src/vnet/bier/bier_table.h
index 9cd9937d76c..5264e4c2fbf 100644
--- a/src/vnet/bier/bier_table.h
+++ b/src/vnet/bier/bier_table.h
@@ -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,