diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-02-16 02:44:05 -0800 |
---|---|---|
committer | Neale Ranns <neale.ranns@cisco.com> | 2018-02-16 02:44:08 -0800 |
commit | c819fc612f9a79eaba2981dc2e8f7c31552db5ea (patch) | |
tree | ba19a3f7b2f223ebd28e3fe87ad5f73ef81d9745 /src/vnet/adj | |
parent | 25d417f28680c78a709792d997884dd80227bb70 (diff) |
Allow providers to override glean behaviour
and update glean address on local interface MAC change
Change-Id: I530826d60c7e9db2b0fa2d45754139d82c5ea807
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vnet/adj')
-rw-r--r-- | src/vnet/adj/adj_glean.c | 64 | ||||
-rw-r--r-- | src/vnet/adj/adj_glean.h | 19 | ||||
-rw-r--r-- | src/vnet/adj/adj_internal.h | 15 | ||||
-rw-r--r-- | src/vnet/adj/adj_midchain.c | 9 | ||||
-rw-r--r-- | src/vnet/adj/adj_nbr.c | 15 |
5 files changed, 89 insertions, 33 deletions
diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c index 82023f12dd2..82d0a46eb1f 100644 --- a/src/vnet/adj/adj_glean.c +++ b/src/vnet/adj/adj_glean.c @@ -68,26 +68,55 @@ adj_glean_add_or_lock (fib_protocol_t proto, 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_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)); + vnet_update_adjacency_for_sw_interface(vnet_get_main(), + sw_if_index, + adj_get_index(adj)); } 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) +{ + if (sw_if_index < vec_len(adj_gleans[proto])) + { + return (adj_gleans[proto][sw_if_index]); + } + return (ADJ_INDEX_INVALID); +} + void adj_glean_remove (fib_protocol_t proto, u32 sw_if_index) @@ -227,12 +256,17 @@ format_adj_glean (u8* s, va_list *ap) vnet_main_t * vnm = vnet_get_main(); ip_adjacency_t * adj = adj_get(index); - 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))); + 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); } diff --git a/src/vnet/adj/adj_glean.h b/src/vnet/adj/adj_glean.h index 640bd2f91eb..47cddfbed2b 100644 --- a/src/vnet/adj/adj_glean.h +++ b/src/vnet/adj/adj_glean.h @@ -48,6 +48,25 @@ extern adj_index_t adj_glean_add_or_lock(fib_protocol_t proto, 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 e6d276e4d02..3b7ddb2f10c 100644 --- a/src/vnet/adj/adj_internal.h +++ b/src/vnet/adj/adj_internal.h @@ -78,6 +78,21 @@ adj_fib_proto_2_nd (fib_protocol_t fp) 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 9fd3246b15a..b6cb8240a52 100644 --- a/src/vnet/adj/adj_midchain.c +++ b/src/vnet/adj/adj_midchain.c @@ -519,7 +519,9 @@ adj_nbr_midchain_update_rewrite (adj_index_t adj_index, * one time only update. since we don't support chainging the tunnel * src,dst, this is all we need. */ - ASSERT(adj->lookup_next_index == IP_LOOKUP_NEXT_ARP); + ASSERT((adj->lookup_next_index == IP_LOOKUP_NEXT_ARP) || + (adj->lookup_next_index == IP_LOOKUP_NEXT_GLEAN)); + /* * tunnels can always provide a rewrite. */ @@ -590,8 +592,9 @@ format_adj_midchain (u8* s, va_list *ap) 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); + 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, " %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 fc7a7fcd93c..97940da0271 100644 --- a/src/vnet/adj/adj_nbr.c +++ b/src/vnet/adj/adj_nbr.c @@ -968,21 +968,6 @@ VLIB_CLI_COMMAND (ip4_show_fib_command, static) = { .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) { |