aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-12-13 09:13:41 -0800
committerNeale Ranns <nranns@cisco.com>2017-12-14 09:25:31 +0000
commitceb4d05ba0fb9771069b0081b928a9e75401fc87 (patch)
treecf05e164bcd06abde9e75a72ff402837a0644a2c
parentff6e7699a5e9921d73818970ecf3571080922ecc (diff)
BIER disposition default route
Change-Id: I7196ad8bf6afaf356674789c05e23ac000bc038e Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r--src/vnet/bier/bier.api3
-rw-r--r--src/vnet/bier/bier_api.c5
-rw-r--r--src/vnet/bier/bier_disp_lookup_node.c20
-rw-r--r--test/test_bier.py25
4 files changed, 45 insertions, 8 deletions
diff --git a/src/vnet/bier/bier.api b/src/vnet/bier/bier.api
index f7a13e4705b..6f88732aba9 100644
--- a/src/vnet/bier/bier.api
+++ b/src/vnet/bier/bier.api
@@ -221,7 +221,8 @@ define bier_disp_table_details
/** \brief BIER Disposition Entry Add / del
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param bde_bp - The Bit-position value for the entry
+ @param bde_bp - The Bit-position value for the entry, i.e. the sender's
+ Use 0 for the default (match any source) entry.
@param bde_tbl_id - The BIER dispositiontable-id the route is added in
@param bde_next_hop_sw_if_index - the nextop interface
@param bde_is_add - Is this a route add or delete
diff --git a/src/vnet/bier/bier_api.c b/src/vnet/bier/bier_api.c
index 67c70462540..002ea0b051a 100644
--- a/src/vnet/bier/bier_api.c
+++ b/src/vnet/bier/bier_api.c
@@ -496,7 +496,10 @@ vl_api_bier_disp_entry_add_del_t_handler (vl_api_bier_disp_entry_add_del_t * mp)
table_id = ntohl(mp->bde_tbl_id);
bp = ntohs(mp->bde_bp);
- if (0 == bp || bp > 0xffff)
+ /*
+ * BP=0 is the default route
+ */
+ if (bp > 0xffff)
{
rv = -1;
goto done;
diff --git a/src/vnet/bier/bier_disp_lookup_node.c b/src/vnet/bier/bier_disp_lookup_node.c
index 15515f467ca..1e1ea99557f 100644
--- a/src/vnet/bier/bier_disp_lookup_node.c
+++ b/src/vnet/bier/bier_disp_lookup_node.c
@@ -63,6 +63,7 @@ bier_disp_lookup_inline (vlib_main_t * vm,
while (n_left_from > 0 && n_left_to_next > 0)
{
const bier_hdr_t *hdr0;
+ bier_hdr_src_id_t src0;
vlib_buffer_t * b0;
u32 bdei0, bdti0;
u32 next0, bi0;
@@ -82,15 +83,22 @@ bier_disp_lookup_inline (vlib_main_t * vm,
/*
* lookup - source is in network order.
*/
- bdei0 = bier_disp_table_lookup(bdti0, bier_hdr_get_src_id(hdr0));
+ src0 = bier_hdr_get_src_id(hdr0);
+ next0 = BIER_DISP_LOOKUP_NEXT_DISPATCH;
+
+ bdei0 = bier_disp_table_lookup(bdti0, src0);
if (PREDICT_FALSE(INDEX_INVALID == bdei0))
{
- next0 = BIER_DISP_LOOKUP_NEXT_DROP;
- }
- else
- {
- next0 = BIER_DISP_LOOKUP_NEXT_DISPATCH;
+ /*
+ * if a specific match misses, try the default
+ */
+ bdei0 = bier_disp_table_lookup(bdti0, 0);
+
+ if (PREDICT_FALSE(INDEX_INVALID == bdei0))
+ {
+ next0 = BIER_DISP_LOOKUP_NEXT_DROP;
+ }
}
vnet_buffer(b0)->ip.adj_index[VLIB_TX] = bdei0;
diff --git a/test/test_bier.py b/test/test_bier.py
index 48d0a297ca6..514265cb5b5 100644
--- a/test/test_bier.py
+++ b/test/test_bier.py
@@ -335,6 +335,31 @@ class TestBier(VppTestCase):
self.send_and_expect(self.pg0, [p], self.pg1)
+ #
+ # A packet that does not match the Disposition entry gets dropped
+ #
+ p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
+ MPLS(label=77, ttl=255) /
+ BIER(length=BIERLength.BIER_LEN_256, BFRID=77) /
+ IP(src="1.1.1.1", dst="232.1.1.1") /
+ UDP(sport=1234, dport=1234) /
+ Raw())
+ self.send_and_assert_no_replies(self.pg0, p*2,
+ "no matching disposition entry")
+
+ #
+ # Add the default route to the disposition table
+ #
+ bier_de_2 = VppBierDispEntry(self, bdt.id, 0,
+ BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
+ "0.0.0.0", 0, rpf_id=8192)
+ bier_de_2.add_vpp_config()
+
+ #
+ # now the previous packet is forwarded
+ #
+ self.send_and_expect(self.pg0, [p], self.pg1)
+
def test_bier_e2e(self):
""" BIER end-to-end """