aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/adj/adj.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-04-05 08:11:14 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-04-06 15:18:44 +0000
commit88fc83eb716bf07f4634de6de5b569f795a56418 (patch)
tree4c8037b62cb6a57209aef4e28ae273d0ba4e40e7 /src/vnet/adj/adj.c
parent5ee51f8ed616f14f3b32ae8857d383fefa02d861 (diff)
BFD-FIB interactions
- single-hop BFD: attach a delegate to the appropriate adjacency - multi-hop BFD [not supported yet]: attach a delegate to the FIB entry. adjacency/fib_entry state tracks the BFD session state. when the state is down the object does not contribute forwarding hence and hence dependent objects will not use it. For example, if a route is ECMP via two adjacencies and one of them is BFD down, then only the other is used to forward (i.e. we don't drop half the traffic). Change-Id: I0ef53e20e73b067001a132cd0a3045408811a822 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/adj/adj.c')
-rw-r--r--src/vnet/adj/adj.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/vnet/adj/adj.c b/src/vnet/adj/adj.c
index 7cf9e9d081d..90182006f60 100644
--- a/src/vnet/adj/adj.c
+++ b/src/vnet/adj/adj.c
@@ -18,6 +18,7 @@
#include <vnet/adj/adj_glean.h>
#include <vnet/adj/adj_midchain.h>
#include <vnet/adj/adj_mcast.h>
+#include <vnet/adj/adj_delegate.h>
#include <vnet/fib/fib_node_list.h>
/* Adjacency packet/byte counters indexed by adjacency index. */
@@ -57,13 +58,14 @@ adj_alloc (fib_protocol_t proto)
vlib_validate_combined_counter(&adjacency_counters,
adj_get_index(adj));
- adj->rewrite_header.sw_if_index = ~0;
- adj->lookup_next_index = 0;
-
fib_node_init(&adj->ia_node,
FIB_NODE_TYPE_ADJ);
+
adj->ia_nh_proto = proto;
adj->ia_flags = 0;
+ adj->rewrite_header.sw_if_index = ~0;
+ adj->lookup_next_index = 0;
+ adj->ia_delegates = NULL;
ip4_main.lookup_main.adjacency_heap = adj_pool;
ip6_main.lookup_main.adjacency_heap = adj_pool;
@@ -122,11 +124,19 @@ format_ip_adjacency (u8 * s, va_list * args)
if (fiaf & FORMAT_IP_ADJACENCY_DETAIL)
{
+ adj_delegate_type_t adt;
+ adj_delegate_t *aed;
vlib_counter_t counts;
vlib_get_combined_counter(&adjacency_counters, adj_index, &counts);
s = format (s, "\n counts:[%Ld:%Ld]", counts.packets, counts.bytes);
s = format (s, "\n locks:%d", adj->ia_node.fn_locks);
+ s = format(s, "\n delegates:\n ");
+ FOR_EACH_ADJ_DELEGATE(adj, adt, aed,
+ {
+ s = format(s, " %U\n", format_adj_deletegate, aed);
+ });
+
s = format(s, "\n children:\n ");
s = fib_node_children_format(adj->ia_node.fn_children, s);
}
@@ -173,7 +183,11 @@ adj_last_lock_gone (ip_adjacency_t *adj)
adj_mcast_remove(adj->ia_nh_proto,
adj->rewrite_header.sw_if_index);
break;
- default:
+ case IP_LOOKUP_NEXT_DROP:
+ case IP_LOOKUP_NEXT_PUNT:
+ case IP_LOOKUP_NEXT_LOCAL:
+ case IP_LOOKUP_NEXT_ICMP_ERROR:
+ case IP_LOOKUP_N_NEXT:
/*
* type not stored in any DB from which we need to remove it
*/
@@ -183,6 +197,8 @@ adj_last_lock_gone (ip_adjacency_t *adj)
vlib_worker_thread_barrier_release(vm);
fib_node_deinit(&adj->ia_node);
+ ASSERT(0 == vec_len(adj->ia_delegates));
+ vec_free(adj->ia_delegates);
pool_put(adj_pool, adj);
}
@@ -352,6 +368,33 @@ adj_get_sw_if_index (adj_index_t ai)
}
/**
+ * @brief Return true if the adjacency is 'UP', i.e. can be used for forwarding
+ * 0 is down, !0 is up.
+ */
+int
+adj_is_up (adj_index_t ai)
+{
+ const adj_delegate_t *aed;
+
+ aed = adj_delegate_get(adj_get(ai), ADJ_DELEGATE_BFD);
+
+ if (NULL == aed)
+ {
+ /*
+ * no BFD tracking - resolved
+ */
+ return (!0);
+ }
+ else
+ {
+ /*
+ * defer to the state of the BFD tracking
+ */
+ return (ADJ_BFD_STATE_UP == aed->ad_bfd_state);
+ }
+}
+
+/**
* @brief Return the rewrite string of the adjacency
*/
const u8*