Revert "Allow interface types to override glean adjacency behaivour"
This reverts commit 8b30e471df4d42214619e1d6c50cc8298426b45f.
Change-Id: I99edb236eb0a7f8ba3fba333c3481a710ebcb59c
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c
index 09e6c0a..82023f1 100644
--- a/src/vnet/adj/adj_glean.c
+++ b/src/vnet/adj/adj_glean.c
@@ -68,51 +68,26 @@
adj->sub_type.glean.receive_addr = *nh_addr;
}
- adj->rewrite_header.sw_if_index = sw_if_index;
adj->rewrite_header.data_bytes = 0;
- adj_lock(adj_get_index(adj));
- vnet_update_adjacency_for_sw_interface(vnet_get_main(),
- sw_if_index,
- adj_get_index(adj));
+ vnet_rewrite_for_sw_interface(vnet_get_main(),
+ adj_fib_proto_2_nd(proto),
+ sw_if_index,
+ adj_get_glean_node(proto)->index,
+ VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST,
+ &adj->rewrite_header,
+ sizeof (adj->rewrite_data));
}
else
{
adj = adj_get(adj_gleans[proto][sw_if_index]);
- adj_lock(adj_get_index(adj));
}
+ adj_lock(adj_get_index(adj));
+
return (adj_get_index(adj));
}
-/**
- * adj_glean_update_rewrite
- */
-void
-adj_glean_update_rewrite (adj_index_t adj_index)
-{
- ip_adjacency_t *adj;
-
- ASSERT(ADJ_INDEX_INVALID != adj_index);
-
- adj = adj_get(adj_index);
-
- vnet_rewrite_for_sw_interface(vnet_get_main(),
- adj_fib_proto_2_nd(adj->ia_nh_proto),
- adj->rewrite_header.sw_if_index,
- adj_get_glean_node(adj->ia_nh_proto)->index,
- VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST,
- &adj->rewrite_header,
- sizeof (adj->rewrite_data));
-}
-
-adj_index_t
-adj_glean_get (fib_protocol_t proto,
- u32 sw_if_index)
-{
- return (adj_gleans[proto][sw_if_index]);
-}
-
void
adj_glean_remove (fib_protocol_t proto,
u32 sw_if_index)
@@ -252,17 +227,12 @@
vnet_main_t * vnm = vnet_get_main();
ip_adjacency_t * adj = adj_get(index);
- s = format(s, "%U-glean: %U",
- format_fib_protocol, adj->ia_nh_proto,
- format_vnet_sw_interface_name,
- vnm,
- vnet_get_sw_interface(vnm,
- adj->rewrite_header.sw_if_index));
- s = format (s, " %U",
- format_vnet_rewrite,
- &adj->rewrite_header, sizeof (adj->rewrite_data), 0);
-
- return (s);
+ return (format(s, "%U-glean: %U",
+ format_fib_protocol, adj->ia_nh_proto,
+ format_vnet_sw_interface_name,
+ vnm,
+ vnet_get_sw_interface(vnm,
+ adj->rewrite_header.sw_if_index)));
}
diff --git a/src/vnet/adj/adj_glean.h b/src/vnet/adj/adj_glean.h
index 47cddfb..640bd2f 100644
--- a/src/vnet/adj/adj_glean.h
+++ b/src/vnet/adj/adj_glean.h
@@ -48,25 +48,6 @@
const ip46_address_t *nh_addr);
/**
- * @brief Get an existing glean
- *
- * @return INVALID if it does not exist
- */
-extern adj_index_t adj_glean_get(fib_protocol_t proto,
- u32 sw_if_index);
-
-/**
- * adj_glean_update_rewrite
- *
- * Called by an adjacency provider (an interface type) to configure
- * a glean adj (i.e. and adjacency linked to a connected prefix) to
- * its default behaviour.
- * Other interface types (i.e. 6RD tunnels) can can choose not to use
- * glean behaviour on an adjacency liked to a connected prefix.
- */
-extern void adj_glean_update_rewrite(adj_index_t adj_index);
-
-/**
* @brief Format/display a glean adjacency.
*/
extern u8* format_adj_glean(u8* s, va_list *ap);
diff --git a/src/vnet/adj/adj_internal.h b/src/vnet/adj/adj_internal.h
index 3b7ddb2..e6d276e 100644
--- a/src/vnet/adj/adj_internal.h
+++ b/src/vnet/adj/adj_internal.h
@@ -78,21 +78,6 @@
return (0);
}
-static inline ip46_type_t
-adj_proto_to_46 (fib_protocol_t proto)
-{
- switch (proto)
- {
- case FIB_PROTOCOL_IP4:
- return (IP46_TYPE_IP4);
- case FIB_PROTOCOL_IP6:
- return (IP46_TYPE_IP6);
- default:
- return (IP46_TYPE_IP4);
- }
- return (IP46_TYPE_IP4);
-}
-
/**
* @brief
* Get a pointer to an adjacency object from its index
diff --git a/src/vnet/adj/adj_midchain.c b/src/vnet/adj/adj_midchain.c
index b32a0e4..9fd3246 100644
--- a/src/vnet/adj/adj_midchain.c
+++ b/src/vnet/adj/adj_midchain.c
@@ -590,9 +590,8 @@
ip_adjacency_t * adj = adj_get(index);
s = format (s, "%U", format_vnet_link, adj->ia_link);
- s = format (s, " via %U",
- format_ip46_address, &adj->sub_type.nbr.next_hop,
- adj_proto_to_46(adj->ia_nh_proto));
+ s = format (s, " via %U ",
+ format_ip46_address, &adj->sub_type.nbr.next_hop);
s = format (s, " %U",
format_vnet_rewrite,
&adj->rewrite_header, sizeof (adj->rewrite_data), indent);
diff --git a/src/vnet/adj/adj_nbr.c b/src/vnet/adj/adj_nbr.c
index 97940da..fc7a7fc 100644
--- a/src/vnet/adj/adj_nbr.c
+++ b/src/vnet/adj/adj_nbr.c
@@ -968,6 +968,21 @@
.function = adj_nbr_show,
};
+static ip46_type_t
+adj_proto_to_46 (fib_protocol_t proto)
+{
+ switch (proto)
+ {
+ case FIB_PROTOCOL_IP4:
+ return (IP46_TYPE_IP4);
+ case FIB_PROTOCOL_IP6:
+ return (IP46_TYPE_IP6);
+ default:
+ return (IP46_TYPE_IP4);
+ }
+ return (IP46_TYPE_IP4);
+}
+
u8*
format_adj_nbr_incomplete (u8* s, va_list *ap)
{
diff --git a/src/vnet/ethernet/arp.c b/src/vnet/ethernet/arp.c
index da56c2b..149f0a5 100644
--- a/src/vnet/ethernet/arp.c
+++ b/src/vnet/ethernet/arp.c
@@ -455,10 +455,8 @@
switch (adj->lookup_next_index)
{
- case IP_LOOKUP_NEXT_GLEAN:
- adj_glean_update_rewrite (ai);
- break;
case IP_LOOKUP_NEXT_ARP:
+ case IP_LOOKUP_NEXT_GLEAN:
if (NULL != e)
{
adj_nbr_walk_nh4 (sw_if_index,
@@ -2489,8 +2487,6 @@
change_arp_mac (sw_if_index, e);
}));
/* *INDENT-ON* */
-
- adj_glean_update_rewrite (adj_glean_get (FIB_PROTOCOL_IP4, sw_if_index));
}
void
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index b197aa1..7516aec 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -1453,10 +1453,8 @@
switch (adj->lookup_next_index)
{
- case IP_LOOKUP_NEXT_GLEAN:
- adj_glean_update_rewrite (ai);
- break;
case IP_LOOKUP_NEXT_ARP:
+ case IP_LOOKUP_NEXT_GLEAN:
/*
* default rewirte in neighbour adj
*/
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index 61d2983..82b402f 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -566,10 +566,8 @@
switch (adj->lookup_next_index)
{
- case IP_LOOKUP_NEXT_GLEAN:
- adj_glean_update_rewrite (ai);
- break;
case IP_LOOKUP_NEXT_ARP:
+ case IP_LOOKUP_NEXT_GLEAN:
if (NULL != nbr)
{
adj_nbr_walk_nh6 (sw_if_index, &nbr->key.ip6_address,
@@ -4270,8 +4268,6 @@
}
}));
/* *INDENT-ON* */
-
- adj_glean_update_rewrite (adj_glean_get (FIB_PROTOCOL_IP6, sw_if_index));
}
void
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 256000a..f2880bf 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -255,6 +255,47 @@
}
u8 *
+format_ip_lookup_next (u8 * s, va_list * args)
+{
+ /* int promotion of ip_lookup_next_t */
+ ip_lookup_next_t n = va_arg (*args, int);
+ char *t = 0;
+
+ switch (n)
+ {
+ default:
+ s = format (s, "unknown %d", n);
+ return s;
+
+ case IP_LOOKUP_NEXT_DROP:
+ t = "drop";
+ break;
+ case IP_LOOKUP_NEXT_PUNT:
+ t = "punt";
+ break;
+ case IP_LOOKUP_NEXT_ARP:
+ t = "arp";
+ break;
+ case IP_LOOKUP_NEXT_MIDCHAIN:
+ t = "midchain";
+ break;
+ case IP_LOOKUP_NEXT_GLEAN:
+ t = "glean";
+ break;
+ case IP_LOOKUP_NEXT_MCAST:
+ t = "mcast";
+ break;
+ case IP_LOOKUP_NEXT_REWRITE:
+ break;
+ }
+
+ if (t)
+ vec_add (s, t, strlen (t));
+
+ return s;
+}
+
+u8 *
format_ip_adjacency_packet_data (u8 * s, va_list * args)
{
u32 adj_index = va_arg (*args, u32);