#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. */
{
ip_adjacency_t *adj;
- pool_get(adj_pool, adj);
+ pool_get_aligned(adj_pool, adj, CLIB_CACHE_LINE_BYTES);
adj_poison(adj);
vlib_validate_combined_counter(&adjacency_counters,
adj_get_index(adj));
- adj->rewrite_header.sw_if_index = ~0;
- adj->n_adj = 1;
- 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->rewrite_header.flags = 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;
+ /* lest it become a midchain in the future */
+ memset(&adj->sub_type.midchain.next_dpo, 0,
+ sizeof(adj->sub_type.midchain.next_dpo));
return (adj);
}
case IP_LOOKUP_NEXT_MCAST:
s = format (s, "%U", format_adj_mcast, adj_index, 0);
break;
+ case IP_LOOKUP_NEXT_MCAST_MIDCHAIN:
+ s = format (s, "%U", format_adj_mcast_midchain, adj_index, 0);
+ break;
default:
break;
}
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 children:\n ");
- s = fib_node_children_format(adj->ia_node.fn_children, s);
+ 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 ");
+ adj_delegate_format(s, adj);
+
+ s = format(s, "\n children:");
+ if (fib_node_list_get_size(adj->ia_node.fn_children))
+ {
+ s = format(s, "\n ");
+ s = fib_node_children_format(adj->ia_node.fn_children, s);
+ }
}
return s;
ASSERT(0 == fib_node_list_get_size(adj->ia_node.fn_children));
ADJ_DBG(adj, "last-lock-gone");
+ adj_delegate_adj_deleted(adj);
+
vlib_worker_thread_barrier_sync (vm);
switch (adj->lookup_next_index)
adj->rewrite_header.sw_if_index);
break;
case IP_LOOKUP_NEXT_MCAST:
+ case IP_LOOKUP_NEXT_MCAST_MIDCHAIN:
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
*/
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);
}
+u32
+adj_dpo_get_urpf (const dpo_id_t *dpo)
+{
+ ip_adjacency_t *adj;
+
+ adj = adj_get(dpo->dpoi_index);
+
+ return (adj->rewrite_header.sw_if_index);
+}
+
void
adj_lock (adj_index_t adj_index)
{
adj_walk (sw_if_index, adj_feature_update_walk_cb, &ctx);
}
+static adj_walk_rc_t
+adj_mtu_update_walk_cb (adj_index_t ai,
+ void *arg)
+{
+ ip_adjacency_t *adj;
+
+ adj = adj_get(ai);
+
+ vnet_rewrite_update_mtu (vnet_get_main(), adj->ia_link,
+ &adj->rewrite_header);
+
+ return (ADJ_WALK_RC_CONTINUE);
+}
+
+static void
+adj_mtu_update (vnet_main_t * vnm, u32 sw_if_index, u32 flags)
+{
+ adj_walk (sw_if_index, adj_mtu_update_walk_cb, NULL);
+}
+
+VNET_SW_INTERFACE_MTU_CHANGE_FUNCTION(adj_mtu_update);
+
/**
* @brief Walk the Adjacencies on a given interface
*/
FOR_EACH_FIB_IP_PROTOCOL(proto)
{
adj_nbr_walk(sw_if_index, proto, cb, ctx);
+ adj_mcast_walk(sw_if_index, proto, cb, ctx);
}
}
return (adj->rewrite_header.sw_if_index);
}
+/**
+ * @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)
+{
+ return (adj_bfd_is_up(ai));
+}
+
/**
* @brief Return the rewrite string of the adjacency
*/
* [@0]
* [@1] glean: loop0
* [@2] ipv4 via 1.0.0.2 loop0: IP4: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
- * [@3] mpls via 1.0.0.2 loop0: MPLS_UNICAST: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
+ * [@3] mpls via 1.0.0.2 loop0: MPLS: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
* [@4] ipv4 via 1.0.0.3 loop0: IP4: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
- * [@5] mpls via 1.0.0.3 loop0: MPLS_UNICAST: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
+ * [@5] mpls via 1.0.0.3 loop0: MPLS: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
* @cliexend
?*/
VLIB_CLI_COMMAND (adj_show_command, static) = {