fib: MPLS EOS chains built for attached prefixes should link to a lookup DPO
Type: fix
Presently a local label associated with an attached or connected prefix will link to the glean. This is a problem since it will never use the adj-fibs that are installed for that attached prefix. Instead link the local label to a lookup in the table in which the attached link is bound.
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: Iad49fb6168b9ba47216a9a52bd262363b49c3c43
diff --git a/src/vnet/fib/fib_entry_src.c b/src/vnet/fib/fib_entry_src.c
index 5e66de7..c0275e8 100644
--- a/src/vnet/fib/fib_entry_src.c
+++ b/src/vnet/fib/fib_entry_src.c
@@ -257,6 +257,7 @@
fib_forward_chain_type_t fct;
int n_recursive_constrained;
u16 preference;
+ dpo_proto_t payload_proto;
} fib_entry_src_collect_forwarding_ctx_t;
/**
@@ -289,47 +290,6 @@
MPLS_IETF_IMPLICIT_NULL_LABEL == label));
}
-/**
- * @brief Turn the chain type requested by the client into the one they
- * really wanted
- */
-fib_forward_chain_type_t
-fib_entry_chain_type_fixup (const fib_entry_t *entry,
- fib_forward_chain_type_t fct)
-{
- /*
- * The EOS chain is a tricky since one cannot know the adjacency
- * to link to without knowing what the packets payload protocol
- * will be once the label is popped.
- */
- fib_forward_chain_type_t dfct;
-
- if (FIB_FORW_CHAIN_TYPE_MPLS_EOS != fct)
- {
- return (fct);
- }
-
- dfct = fib_entry_get_default_chain_type(entry);
-
- if (FIB_FORW_CHAIN_TYPE_MPLS_EOS == dfct)
- {
- /*
- * If the entry being asked is a eos-MPLS label entry,
- * then use the payload-protocol field, that we stashed there
- * for just this purpose
- */
- return (fib_forw_chain_type_from_dpo_proto(
- entry->fe_prefix.fp_payload_proto));
- }
- /*
- * else give them what this entry would be by default. i.e. if it's a v6
- * entry, then the label its local labelled should be carrying v6 traffic.
- * If it's a non-EOS label entry, then there are more labels and we want
- * a non-eos chain.
- */
- return (dfct);
-}
-
static dpo_proto_t
fib_prefix_get_payload_proto (const fib_prefix_t *pfx)
{
@@ -371,7 +331,8 @@
nh->path_index = path_index;
nh->path_weight = fib_path_get_weight(path_index);
- fib_path_contribute_forwarding(path_index, ctx->fct, &nh->path_dpo);
+ fib_path_contribute_forwarding(path_index, ctx->fct,
+ ctx->payload_proto, &nh->path_dpo);
break;
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
@@ -384,6 +345,7 @@
nh->path_weight = fib_path_get_weight(path_index);
fib_path_contribute_forwarding(path_index,
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS,
+ ctx->payload_proto,
&nh->path_dpo);
}
break;
@@ -397,11 +359,11 @@
nh->path_index = path_index;
nh->path_weight = fib_path_get_weight(path_index);
fib_path_contribute_forwarding(path_index,
- fib_entry_chain_type_fixup(ctx->fib_entry,
- ctx->fct),
+ ctx->fct,
+ ctx->payload_proto,
&nh->path_dpo);
fib_path_stack_mpls_disp(path_index,
- fib_prefix_get_payload_proto(&ctx->fib_entry->fe_prefix),
+ ctx->payload_proto,
FIB_MPLS_LSP_MODE_PIPE,
&nh->path_dpo);
@@ -480,9 +442,8 @@
*/
ctx->next_hops =
fib_path_ext_stack(path_ext,
+ ctx->payload_proto,
ctx->fct,
- fib_entry_chain_type_fixup(ctx->fib_entry,
- ctx->fct),
ctx->next_hops);
}
else
@@ -609,6 +570,7 @@
.preference = 0xffff,
.start_source_index = start,
.end_source_index = end,
+ .payload_proto = fib_prefix_get_payload_proto(&fib_entry->fe_prefix),
};
/*
diff --git a/src/vnet/fib/fib_entry_src.h b/src/vnet/fib/fib_entry_src.h
index ced6b5c..1f348ba 100644
--- a/src/vnet/fib/fib_entry_src.h
+++ b/src/vnet/fib/fib_entry_src.h
@@ -326,9 +326,6 @@
extern fib_path_list_flags_t fib_entry_src_flags_2_path_list_flags(
fib_entry_flag_t eflags);
-extern fib_forward_chain_type_t fib_entry_chain_type_fixup(const fib_entry_t *entry,
- fib_forward_chain_type_t fct);
-
extern void fib_entry_src_mk_lb (fib_entry_t *fib_entry,
fib_source_t source,
fib_forward_chain_type_t fct,
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index d7b6091..e4ad877 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -2421,6 +2421,7 @@
void
fib_path_contribute_forwarding (fib_node_index_t path_index,
fib_forward_chain_type_t fct,
+ dpo_proto_t payload_proto,
dpo_id_t *dpo)
{
fib_path_t *path;
@@ -2428,7 +2429,6 @@
path = fib_path_get(path_index);
ASSERT(path);
- ASSERT(FIB_FORW_CHAIN_TYPE_MPLS_EOS != fct);
/*
* The DPO stored in the path was created when the path was resolved.
@@ -2446,9 +2446,19 @@
case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
switch (fct)
{
+ case FIB_FORW_CHAIN_TYPE_MPLS_EOS: {
+ dpo_id_t tmp = DPO_INVALID;
+ dpo_copy (&tmp, dpo);
+ path = fib_path_attached_next_hop_get_adj(
+ path,
+ dpo_proto_to_link(payload_proto),
+ &tmp);
+ dpo_copy (dpo, &tmp);
+ dpo_reset(&tmp);
+ break;
+ }
case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
- case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
case FIB_FORW_CHAIN_TYPE_ETHERNET:
case FIB_FORW_CHAIN_TYPE_NSH:
@@ -2560,10 +2570,25 @@
case FIB_PATH_TYPE_ATTACHED:
switch (fct)
{
+ case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
+ /*
+ * End of stack traffic via an attacehd path (a glean)
+ * must forace an IP lookup so that the IP packet can
+ * match against any installed adj-fibs
+ */
+ lookup_dpo_add_or_lock_w_fib_index(
+ fib_table_get_index_for_sw_if_index(
+ dpo_proto_to_fib(payload_proto),
+ path->attached.fp_interface),
+ payload_proto,
+ LOOKUP_UNICAST,
+ LOOKUP_INPUT_DST_ADDR,
+ LOOKUP_TABLE_FROM_CONFIG,
+ dpo);
+ break;
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
- case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
case FIB_FORW_CHAIN_TYPE_ETHERNET:
case FIB_FORW_CHAIN_TYPE_NSH:
case FIB_FORW_CHAIN_TYPE_BIER:
@@ -2609,8 +2634,8 @@
/*
* Create the adj needed for sending IP multicast traffic
*/
- interface_rx_dpo_add_or_lock(fib_forw_chain_type_to_dpo_proto(fct),
- path->attached.fp_interface,
+ interface_rx_dpo_add_or_lock(payload_proto,
+ path->intf_rx.fp_interface,
dpo);
break;
case FIB_PATH_TYPE_UDP_ENCAP:
@@ -2630,6 +2655,7 @@
load_balance_path_t *
fib_path_append_nh_for_multipath_hash (fib_node_index_t path_index,
fib_forward_chain_type_t fct,
+ dpo_proto_t payload_proto,
load_balance_path_t *hash_key)
{
load_balance_path_t *mnh;
@@ -2646,7 +2672,7 @@
if (fib_path_is_resolved(path_index))
{
- fib_path_contribute_forwarding(path_index, fct, &mnh->path_dpo);
+ fib_path_contribute_forwarding(path_index, fct, payload_proto, &mnh->path_dpo);
}
else
{
diff --git a/src/vnet/fib/fib_path.h b/src/vnet/fib/fib_path.h
index c0f7641..f3442c2 100644
--- a/src/vnet/fib/fib_path.h
+++ b/src/vnet/fib/fib_path.h
@@ -191,6 +191,7 @@
extern load_balance_path_t * fib_path_append_nh_for_multipath_hash(
fib_node_index_t path_index,
fib_forward_chain_type_t fct,
+ dpo_proto_t payload_proto,
load_balance_path_t *hash_key);
extern void fib_path_stack_mpls_disp(fib_node_index_t path_index,
dpo_proto_t payload_proto,
@@ -198,6 +199,7 @@
dpo_id_t *dpo);
extern void fib_path_contribute_forwarding(fib_node_index_t path_index,
fib_forward_chain_type_t type,
+ dpo_proto_t payload_proto,
dpo_id_t *dpo);
extern void fib_path_contribute_urpf(fib_node_index_t path_index,
index_t urpf);
diff --git a/src/vnet/fib/fib_path_ext.c b/src/vnet/fib/fib_path_ext.c
index 209b627..f5611f9 100644
--- a/src/vnet/fib/fib_path_ext.c
+++ b/src/vnet/fib/fib_path_ext.c
@@ -163,8 +163,8 @@
load_balance_path_t *
fib_path_ext_stack (fib_path_ext_t *path_ext,
+ dpo_proto_t payload_proto,
fib_forward_chain_type_t child_fct,
- fib_forward_chain_type_t imp_null_fct,
load_balance_path_t *nhs)
{
fib_forward_chain_type_t parent_fct;
@@ -189,7 +189,7 @@
*/
if (fib_path_ext_is_imp_null(path_ext))
{
- parent_fct = imp_null_fct;
+ parent_fct = fib_forw_chain_type_from_dpo_proto(payload_proto);
}
else
{
@@ -240,6 +240,7 @@
*/
fib_path_contribute_forwarding(path_ext->fpe_path_index,
parent_fct,
+ payload_proto,
&via_dpo);
if (dpo_is_drop(&via_dpo) ||
diff --git a/src/vnet/fib/fib_path_ext.h b/src/vnet/fib/fib_path_ext.h
index b49fd97..2850a58 100644
--- a/src/vnet/fib/fib_path_ext.h
+++ b/src/vnet/fib/fib_path_ext.h
@@ -141,8 +141,8 @@
fib_node_index_t path_list_index);
extern load_balance_path_t *fib_path_ext_stack(fib_path_ext_t *path_ext,
+ dpo_proto_t payload_proto,
fib_forward_chain_type_t fct,
- fib_forward_chain_type_t imp_null_fct,
load_balance_path_t *nhs);
extern fib_path_ext_t * fib_path_ext_list_push_back (fib_path_ext_list_t *list,
diff --git a/src/vnet/fib/fib_path_list.c b/src/vnet/fib/fib_path_list.c
index 8175169..d7e860e 100644
--- a/src/vnet/fib/fib_path_list.c
+++ b/src/vnet/fib/fib_path_list.c
@@ -378,8 +378,10 @@
if ((flags & FIB_PATH_LIST_FWD_FLAG_STICKY) ||
fib_path_is_resolved(*path_index))
{
- nhs = fib_path_append_nh_for_multipath_hash(*path_index,
- fct, nhs);
+ nhs = fib_path_append_nh_for_multipath_hash(
+ *path_index, fct,
+ fib_forw_chain_type_to_dpo_proto(fct),
+ nhs);
}
}