teib: Rename NHRP to TEIB 46/24746/2
authorNeale Ranns <nranns@cisco.com>
Mon, 3 Feb 2020 10:55:09 +0000 (10:55 +0000)
committerDamjan Marion <dmarion@me.com>
Tue, 4 Feb 2020 09:44:58 +0000 (09:44 +0000)
Type: refactor

The Tunnel Endpoint Informatiob Base (TEIB) is a better
description of what it is (a mapping between tunnel endpoint
address, in the overlay, and next-hop address, in the underlay)
whereas NHRP is one instanc eof a control protocol that might add
such endpoints.

Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: Idcb2ad0b6543d3e5d9f6e96f9d14dafb5ce2aa85

16 files changed:
MAINTAINERS
src/vnet/CMakeLists.txt
src/vnet/gre/gre.c
src/vnet/gre/gre.h
src/vnet/gre/interface.c
src/vnet/ipip/ipip.c
src/vnet/nhrp/nhrp.c [deleted file]
src/vnet/nhrp/nhrp.h [deleted file]
src/vnet/teib/teib.api [moved from src/vnet/nhrp/nhrp.api with 86% similarity]
src/vnet/teib/teib.c [new file with mode: 0644]
src/vnet/teib/teib.h [new file with mode: 0644]
src/vnet/teib/teib_api.c [moved from src/vnet/nhrp/nhrp_api.c with 64% similarity]
src/vnet/teib/teib_cli.c [moved from src/vnet/nhrp/nhrp_cli.c with 83% similarity]
test/test_gre.py
test/test_ipip.py
test/vpp_teib.py [moved from test/vpp_nhrp.py with 80% similarity]

index 45fc277..bb86fd4 100644 (file)
@@ -180,10 +180,10 @@ I:        cop
 M:     Dave Barach <dave@barachs.net>
 F:     src/vnet/cop/
 
-VNET NHRP
-I:     nhrp
+VNET TEIB
+I:     teib
 M:     Neale Ranns <nranns@cisco.com>
-F:     src/vnet/nhrp/
+F:     src/vnet/teib/
 
 Crypto native Plugin
 I:     crypto-native
index 6f9f6bc..5a9ae4c 100644 (file)
@@ -1517,20 +1517,20 @@ list(APPEND VNET_HEADERS
 list(APPEND VNET_API_FILES pci/pci_types.api)
 
 ##############################################################################
-# NHRP
+# Tunnel Endpoint Information Base
 ##############################################################################
 
 list (APPEND VNET_SOURCES
-  nhrp/nhrp_api.c
-  nhrp/nhrp_cli.c
-  nhrp/nhrp.c
+  teib/teib_api.c
+  teib/teib_cli.c
+  teib/teib.c
 )
 
 list(APPEND VNET_HEADERS
-  nhrp/nhrp.h
+  teib/teib.h
 )
 
-list(APPEND VNET_API_FILES nhrp/nhrp.api)
+list(APPEND VNET_API_FILES teib/teib.api)
 
 ##############################################################################
 # ARP/ND
index f1bc694..a4f3888 100644 (file)
@@ -438,9 +438,9 @@ mgre_mk_complete_walk (adj_index_t ai, void *data)
      gre_build_rewrite (vnet_get_main (),
                        ctx->t->sw_if_index,
                        adj_get_link_type (ai),
-                       &nhrp_entry_get_nh (ctx->ne)->fp_addr));
+                       &teib_entry_get_nh (ctx->ne)->fp_addr));
 
-  nhrp_entry_adj_stack (ctx->ne, ai);
+  teib_entry_adj_stack (ctx->ne, ai);
 
   return (ADJ_WALK_RC_CONTINUE);
 }
@@ -464,7 +464,7 @@ mgre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
 {
   gre_main_t *gm = &gre_main;
   ip_adjacency_t *adj;
-  nhrp_entry_t *ne;
+  teib_entry_t *ne;
   gre_tunnel_t *t;
   u32 ti;
 
@@ -472,7 +472,7 @@ mgre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
   ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
   t = pool_elt_at_index (gm->tunnels, ti);
 
-  ne = nhrp_entry_find (sw_if_index, &adj->sub_type.nbr.next_hop);
+  ne = teib_entry_find (sw_if_index, &adj->sub_type.nbr.next_hop);
 
   if (NULL == ne)
     // no NHRP entry to provide the next-hop
index 0cc60b8..14798d8 100644 (file)
@@ -25,7 +25,7 @@
 #include <vnet/ip/format.h>
 #include <vnet/adj/adj_types.h>
 #include <vnet/tunnel/tunnel.h>
-#include <vnet/nhrp/nhrp.h>
+#include <vnet/teib/teib.h>
 
 extern vnet_hw_interface_class_t gre_hw_interface_class;
 extern vnet_hw_interface_class_t mgre_hw_interface_class;
@@ -328,7 +328,7 @@ extern void gre_update_adj (vnet_main_t * vnm,
 typedef struct mgre_walk_ctx_t_
 {
   const gre_tunnel_t *t;
-  const nhrp_entry_t *ne;
+  const teib_entry_t *ne;
 } mgre_walk_ctx_t;
 
 adj_walk_rc_t mgre_mk_complete_walk (adj_index_t ai, void *data);
index 553c89a..6efa3da 100644 (file)
@@ -25,7 +25,7 @@
 #include <vnet/adj/adj_nbr.h>
 #include <vnet/mpls/mpls.h>
 #include <vnet/l2/l2_input.h>
-#include <vnet/nhrp/nhrp.h>
+#include <vnet/teib/teib.h>
 
 u8 *
 format_gre_tunnel_type (u8 * s, va_list * args)
@@ -183,23 +183,23 @@ gre_tunnel_restack (gre_tunnel_t * gt)
 }
 
 static void
-gre_nhrp_mk_key (const gre_tunnel_t * t,
-                const nhrp_entry_t * ne, gre_tunnel_key_t * key)
+gre_teib_mk_key (const gre_tunnel_t * t,
+                const teib_entry_t * ne, gre_tunnel_key_t * key)
 {
   const fib_prefix_t *nh;
 
-  nh = nhrp_entry_get_nh (ne);
+  nh = teib_entry_get_nh (ne);
 
   /* construct the key using mode P2P so it can be found in the DP */
   if (FIB_PROTOCOL_IP4 == nh->fp_proto)
     gre_mk_key4 (t->tunnel_src.ip4,
                 nh->fp_addr.ip4,
-                nhrp_entry_get_fib_index (ne),
+                teib_entry_get_fib_index (ne),
                 t->type, TUNNEL_MODE_P2P, 0, &key->gtk_v4);
   else
     gre_mk_key6 (&t->tunnel_src.ip6,
                 &nh->fp_addr.ip6,
-                nhrp_entry_get_fib_index (ne),
+                teib_entry_get_fib_index (ne),
                 t->type, TUNNEL_MODE_P2P, 0, &key->gtk_v6);
 }
 
@@ -207,7 +207,7 @@ gre_nhrp_mk_key (const gre_tunnel_t * t,
  * An NHRP entry has been added
  */
 static void
-gre_nhrp_entry_added (const nhrp_entry_t * ne)
+gre_teib_entry_added (const teib_entry_t * ne)
 {
   gre_main_t *gm = &gre_main;
   const ip46_address_t *nh;
@@ -216,7 +216,7 @@ gre_nhrp_entry_added (const nhrp_entry_t * ne)
   u32 sw_if_index;
   u32 t_idx;
 
-  sw_if_index = nhrp_entry_get_sw_if_index (ne);
+  sw_if_index = teib_entry_get_sw_if_index (ne);
   if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
     return;
 
@@ -233,7 +233,7 @@ gre_nhrp_entry_added (const nhrp_entry_t * ne)
 
   /* the next-hop (underlay) of the NHRP entry will form part of the key for
    * ingress lookup to match packets to this interface */
-  gre_nhrp_mk_key (t, ne, &key);
+  gre_teib_mk_key (t, ne, &key);
   gre_tunnel_db_add (t, &key);
 
   /* update the rewrites for each of the adjacencies for this peer (overlay)
@@ -242,15 +242,15 @@ gre_nhrp_entry_added (const nhrp_entry_t * ne)
     .t = t,
     .ne = ne
   };
-  nh = nhrp_entry_get_peer (ne);
-  adj_nbr_walk_nh (nhrp_entry_get_sw_if_index (ne),
+  nh = teib_entry_get_peer (ne);
+  adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
                   (ip46_address_is_ip4 (nh) ?
                    FIB_PROTOCOL_IP4 :
                    FIB_PROTOCOL_IP6), nh, mgre_mk_complete_walk, &ctx);
 }
 
 static void
-gre_nhrp_entry_deleted (const nhrp_entry_t * ne)
+gre_teib_entry_deleted (const teib_entry_t * ne)
 {
   gre_main_t *gm = &gre_main;
   const ip46_address_t *nh;
@@ -259,7 +259,7 @@ gre_nhrp_entry_deleted (const nhrp_entry_t * ne)
   u32 sw_if_index;
   u32 t_idx;
 
-  sw_if_index = nhrp_entry_get_sw_if_index (ne);
+  sw_if_index = teib_entry_get_sw_if_index (ne);
   if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
     return;
 
@@ -271,37 +271,37 @@ gre_nhrp_entry_deleted (const nhrp_entry_t * ne)
   t = pool_elt_at_index (gm->tunnels, t_idx);
 
   /* remove the next-hop as an ingress lookup key */
-  gre_nhrp_mk_key (t, ne, &key);
+  gre_teib_mk_key (t, ne, &key);
   gre_tunnel_db_remove (t, &key);
 
-  nh = nhrp_entry_get_peer (ne);
+  nh = teib_entry_get_peer (ne);
 
   /* make all the adjacencies incomplete */
-  adj_nbr_walk_nh (nhrp_entry_get_sw_if_index (ne),
+  adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
                   (ip46_address_is_ip4 (nh) ?
                    FIB_PROTOCOL_IP4 :
                    FIB_PROTOCOL_IP6), nh, mgre_mk_incomplete_walk, t);
 }
 
 static walk_rc_t
-gre_tunnel_delete_nhrp_walk (index_t nei, void *ctx)
+gre_tunnel_delete_teib_walk (index_t nei, void *ctx)
 {
   gre_tunnel_t *t = ctx;
   gre_tunnel_key_t key;
 
-  gre_nhrp_mk_key (t, nhrp_entry_get (nei), &key);
+  gre_teib_mk_key (t, teib_entry_get (nei), &key);
   gre_tunnel_db_remove (t, &key);
 
   return (WALK_CONTINUE);
 }
 
 static walk_rc_t
-gre_tunnel_add_nhrp_walk (index_t nei, void *ctx)
+gre_tunnel_add_teib_walk (index_t nei, void *ctx)
 {
   gre_tunnel_t *t = ctx;
   gre_tunnel_key_t key;
 
-  gre_nhrp_mk_key (t, nhrp_entry_get (nei), &key);
+  gre_teib_mk_key (t, teib_entry_get (nei), &key);
   gre_tunnel_db_add (t, &key);
 
   return (WALK_CONTINUE);
@@ -421,7 +421,7 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
   gre_tunnel_db_add (t, &key);
 
   if (t->mode == TUNNEL_MODE_MP)
-    nhrp_walk_itf (t->sw_if_index, gre_tunnel_add_nhrp_walk, t);
+    teib_walk_itf (t->sw_if_index, gre_tunnel_add_teib_walk, t);
 
   if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
     {
@@ -477,7 +477,7 @@ vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
     return VNET_API_ERROR_NO_SUCH_ENTRY;
 
   if (t->mode == TUNNEL_MODE_MP)
-    nhrp_walk_itf (t->sw_if_index, gre_tunnel_delete_nhrp_walk, t);
+    teib_walk_itf (t->sw_if_index, gre_tunnel_delete_teib_walk, t);
 
   sw_if_index = t->sw_if_index;
   vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
@@ -753,16 +753,16 @@ VLIB_CLI_COMMAND (show_gre_tunnel_command, static) = {
 };
 /* *INDENT-ON* */
 
-const static nhrp_vft_t gre_nhrp_vft = {
-  .nv_added = gre_nhrp_entry_added,
-  .nv_deleted = gre_nhrp_entry_deleted,
+const static teib_vft_t gre_teib_vft = {
+  .nv_added = gre_teib_entry_added,
+  .nv_deleted = gre_teib_entry_deleted,
 };
 
 /* force inclusion from application's main.c */
 clib_error_t *
 gre_interface_init (vlib_main_t * vm)
 {
-  nhrp_register (&gre_nhrp_vft);
+  teib_register (&gre_teib_vft);
 
   return (NULL);
 }
index c94e91d..047a2df 100644 (file)
@@ -25,7 +25,7 @@
 #include <vnet/fib/ip6_fib.h>
 #include <vnet/ip/format.h>
 #include <vnet/ipip/ipip.h>
-#include <vnet/nhrp/nhrp.h>
+#include <vnet/teib/teib.h>
 #include <vnet/tunnel/tunnel_dp.h>
 
 ipip_main_t ipip_main;
@@ -299,7 +299,7 @@ ipip_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
 typedef struct mipip_walk_ctx_t_
 {
   const ipip_tunnel_t *t;
-  const nhrp_entry_t *ne;
+  const teib_entry_t *ne;
 } mipip_walk_ctx_t;
 
 static adj_walk_rc_t
@@ -313,10 +313,10 @@ mipip_mk_complete_walk (adj_index_t ai, void *data)
      ADJ_FLAG_MIDCHAIN_IP_STACK, ipip_build_rewrite (vnet_get_main (),
                                                     ctx->t->sw_if_index,
                                                     adj_get_link_type (ai),
-                                                    &nhrp_entry_get_nh
+                                                    &teib_entry_get_nh
                                                     (ctx->ne)->fp_addr));
 
-  nhrp_entry_adj_stack (ctx->ne, ai);
+  teib_entry_adj_stack (ctx->ne, ai);
 
   return (ADJ_WALK_RC_CONTINUE);
 }
@@ -340,7 +340,7 @@ mipip_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
 {
   ipip_main_t *gm = &ipip_main;
   ip_adjacency_t *adj;
-  nhrp_entry_t *ne;
+  teib_entry_t *ne;
   ipip_tunnel_t *t;
   u32 ti;
 
@@ -348,7 +348,7 @@ mipip_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
   ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
   t = pool_elt_at_index (gm->tunnels, ti);
 
-  ne = nhrp_entry_find (sw_if_index, &adj->sub_type.nbr.next_hop);
+  ne = teib_entry_find (sw_if_index, &adj->sub_type.nbr.next_hop);
 
   if (NULL == ne)
     {
@@ -527,21 +527,21 @@ ipip_mk_key (const ipip_tunnel_t * t, ipip_tunnel_key_t * key)
 }
 
 static void
-ipip_nhrp_mk_key (const ipip_tunnel_t * t,
-                 const nhrp_entry_t * ne, ipip_tunnel_key_t * key)
+ipip_teib_mk_key (const ipip_tunnel_t * t,
+                 const teib_entry_t * ne, ipip_tunnel_key_t * key)
 {
   const fib_prefix_t *nh;
 
-  nh = nhrp_entry_get_nh (ne);
+  nh = teib_entry_get_nh (ne);
 
   /* construct the key using mode P2P so it can be found in the DP */
   ipip_mk_key_i (t->transport, IPIP_MODE_P2P,
                 &t->tunnel_src, &nh->fp_addr,
-                nhrp_entry_get_fib_index (ne), key);
+                teib_entry_get_fib_index (ne), key);
 }
 
 static void
-ipip_nhrp_entry_added (const nhrp_entry_t * ne)
+ipip_teib_entry_added (const teib_entry_t * ne)
 {
   ipip_main_t *gm = &ipip_main;
   const ip46_address_t *nh;
@@ -550,7 +550,7 @@ ipip_nhrp_entry_added (const nhrp_entry_t * ne)
   u32 sw_if_index;
   u32 t_idx;
 
-  sw_if_index = nhrp_entry_get_sw_if_index (ne);
+  sw_if_index = teib_entry_get_sw_if_index (ne);
   if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
     return;
 
@@ -561,7 +561,7 @@ ipip_nhrp_entry_added (const nhrp_entry_t * ne)
 
   t = pool_elt_at_index (gm->tunnels, t_idx);
 
-  ipip_nhrp_mk_key (t, ne, &key);
+  ipip_teib_mk_key (t, ne, &key);
   ipip_tunnel_db_add (t, &key);
 
   // update the rewrites for each of the adjacencies for this next-hop
@@ -569,15 +569,15 @@ ipip_nhrp_entry_added (const nhrp_entry_t * ne)
     .t = t,
     .ne = ne
   };
-  nh = nhrp_entry_get_peer (ne);
-  adj_nbr_walk_nh (nhrp_entry_get_sw_if_index (ne),
+  nh = teib_entry_get_peer (ne);
+  adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
                   (ip46_address_is_ip4 (nh) ?
                    FIB_PROTOCOL_IP4 :
                    FIB_PROTOCOL_IP6), nh, mipip_mk_complete_walk, &ctx);
 }
 
 static void
-ipip_nhrp_entry_deleted (const nhrp_entry_t * ne)
+ipip_teib_entry_deleted (const teib_entry_t * ne)
 {
   ipip_main_t *gm = &ipip_main;
   const ip46_address_t *nh;
@@ -586,7 +586,7 @@ ipip_nhrp_entry_deleted (const nhrp_entry_t * ne)
   u32 sw_if_index;
   u32 t_idx;
 
-  sw_if_index = nhrp_entry_get_sw_if_index (ne);
+  sw_if_index = teib_entry_get_sw_if_index (ne);
   if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
     return;
 
@@ -597,37 +597,37 @@ ipip_nhrp_entry_deleted (const nhrp_entry_t * ne)
 
   t = pool_elt_at_index (gm->tunnels, t_idx);
 
-  ipip_nhrp_mk_key (t, ne, &key);
+  ipip_teib_mk_key (t, ne, &key);
   ipip_tunnel_db_remove (t, &key);
 
-  nh = nhrp_entry_get_peer (ne);
+  nh = teib_entry_get_peer (ne);
 
   /* make all the adjacencies incomplete */
-  adj_nbr_walk_nh (nhrp_entry_get_sw_if_index (ne),
+  adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
                   (ip46_address_is_ip4 (nh) ?
                    FIB_PROTOCOL_IP4 :
                    FIB_PROTOCOL_IP6), nh, mipip_mk_incomplete_walk, t);
 }
 
 static walk_rc_t
-ipip_tunnel_delete_nhrp_walk (index_t nei, void *ctx)
+ipip_tunnel_delete_teib_walk (index_t nei, void *ctx)
 {
   ipip_tunnel_t *t = ctx;
   ipip_tunnel_key_t key;
 
-  ipip_nhrp_mk_key (t, nhrp_entry_get (nei), &key);
+  ipip_teib_mk_key (t, teib_entry_get (nei), &key);
   ipip_tunnel_db_remove (t, &key);
 
   return (WALK_CONTINUE);
 }
 
 static walk_rc_t
-ipip_tunnel_add_nhrp_walk (index_t nei, void *ctx)
+ipip_tunnel_add_teib_walk (index_t nei, void *ctx)
 {
   ipip_tunnel_t *t = ctx;
   ipip_tunnel_key_t key;
 
-  ipip_nhrp_mk_key (t, nhrp_entry_get (nei), &key);
+  ipip_teib_mk_key (t, teib_entry_get (nei), &key);
   ipip_tunnel_db_add (t, &key);
 
   return (WALK_CONTINUE);
@@ -721,7 +721,7 @@ ipip_add_tunnel (ipip_transport_t transport,
   ipip_tunnel_db_add (t, &key);
 
   if (t->mode == IPIP_MODE_P2MP)
-    nhrp_walk_itf (t->sw_if_index, ipip_tunnel_add_nhrp_walk, t);
+    teib_walk_itf (t->sw_if_index, ipip_tunnel_add_teib_walk, t);
 
   if (sw_if_indexp)
     *sw_if_indexp = sw_if_index;
@@ -754,7 +754,7 @@ ipip_del_tunnel (u32 sw_if_index)
     return VNET_API_ERROR_NO_SUCH_ENTRY;
 
   if (t->mode == IPIP_MODE_P2MP)
-    nhrp_walk_itf (t->sw_if_index, ipip_tunnel_delete_nhrp_walk, t);
+    teib_walk_itf (t->sw_if_index, ipip_tunnel_delete_teib_walk, t);
 
   vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
   gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0;
@@ -768,9 +768,9 @@ ipip_del_tunnel (u32 sw_if_index)
   return 0;
 }
 
-const static nhrp_vft_t ipip_nhrp_vft = {
-  .nv_added = ipip_nhrp_entry_added,
-  .nv_deleted = ipip_nhrp_entry_deleted,
+const static teib_vft_t ipip_teib_vft = {
+  .nv_added = ipip_teib_entry_added,
+  .nv_deleted = ipip_teib_entry_deleted,
 };
 
 static clib_error_t *
@@ -784,7 +784,7 @@ ipip_init (vlib_main_t * vm)
   gm->tunnel_by_key =
     hash_create_mem (0, sizeof (ipip_tunnel_key_t), sizeof (uword));
 
-  nhrp_register (&ipip_nhrp_vft);
+  teib_register (&ipip_teib_vft);
 
   return 0;
 }
diff --git a/src/vnet/nhrp/nhrp.c b/src/vnet/nhrp/nhrp.c
deleted file mode 100644 (file)
index 11d2c2b..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * nhrp.h: next-hop resolution
- *
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <vnet/nhrp/nhrp.h>
-#include <vnet/fib/fib_table.h>
-#include <vnet/adj/adj_midchain.h>
-
-typedef struct nhrp_key_t_
-{
-  ip46_address_t nk_peer;
-  u32 nk_sw_if_index;
-} nhrp_key_t;
-
-struct nhrp_entry_t_
-{
-  nhrp_key_t *ne_key;
-  fib_prefix_t ne_nh;
-  u32 ne_fib_index;
-};
-
-static uword *nhrp_db;
-static nhrp_entry_t *nhrp_pool;
-static nhrp_vft_t *nhrp_vfts;
-
-#define NHRP_NOTIFY(_ne, _fn) {                 \
-  nhrp_vft_t *_vft;                             \
-  vec_foreach(_vft, nhrp_vfts) {                \
-    if (_vft->_fn) {                             \
-      _vft->_fn(_ne);                            \
-    }                                           \
-  }                                             \
-}
-
-u32
-nhrp_entry_get_sw_if_index (const nhrp_entry_t * ne)
-{
-  return (ne->ne_key->nk_sw_if_index);
-}
-
-u32
-nhrp_entry_get_fib_index (const nhrp_entry_t * ne)
-{
-  return (ne->ne_fib_index);
-}
-
-const ip46_address_t *
-nhrp_entry_get_peer (const nhrp_entry_t * ne)
-{
-  return (&ne->ne_key->nk_peer);
-}
-
-const fib_prefix_t *
-nhrp_entry_get_nh (const nhrp_entry_t * ne)
-{
-  return (&ne->ne_nh);
-}
-
-void
-nhrp_entry_adj_stack (const nhrp_entry_t * ne, adj_index_t ai)
-{
-  adj_midchain_delegate_stack (ai, ne->ne_fib_index, &ne->ne_nh);
-}
-
-nhrp_entry_t *
-nhrp_entry_get (index_t nei)
-{
-  return pool_elt_at_index (nhrp_pool, nei);
-}
-
-nhrp_entry_t *
-nhrp_entry_find (u32 sw_if_index, const ip46_address_t * peer)
-{
-  nhrp_key_t nk = {
-    .nk_peer = *peer,
-    .nk_sw_if_index = sw_if_index,
-  };
-  uword *p;
-
-  p = hash_get_mem (nhrp_db, &nk);
-
-  if (NULL != p)
-    return nhrp_entry_get (p[0]);
-
-  return (NULL);
-}
-
-int
-nhrp_entry_add (u32 sw_if_index,
-               const ip46_address_t * peer,
-               u32 nh_table_id, const ip46_address_t * nh)
-{
-  fib_protocol_t fproto;
-  nhrp_entry_t *ne;
-  u32 fib_index;
-  index_t nei;
-
-  fproto = (ip46_address_is_ip4 (nh) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
-
-  fib_index = fib_table_find (fproto, nh_table_id);
-
-  if (~0 == fib_index)
-    {
-      return (VNET_API_ERROR_NO_SUCH_FIB);
-    }
-
-  ne = nhrp_entry_find (sw_if_index, peer);
-
-  if (NULL == ne)
-    {
-      nhrp_key_t nk = {
-       .nk_peer = *peer,
-       .nk_sw_if_index = sw_if_index,
-      };
-      nhrp_entry_t *ne;
-
-      pool_get_zero (nhrp_pool, ne);
-
-      nei = ne - nhrp_pool;
-      ne->ne_key = clib_mem_alloc (sizeof (*ne->ne_key));
-      clib_memcpy (ne->ne_key, &nk, sizeof (*ne->ne_key));
-
-      ip46_address_copy (&ne->ne_nh.fp_addr, nh);
-      ne->ne_nh.fp_proto = fproto;
-      ne->ne_nh.fp_len = (ne->ne_nh.fp_proto == FIB_PROTOCOL_IP4 ? 32 : 128);
-      ne->ne_fib_index = fib_index;
-
-      hash_set_mem (nhrp_db, ne->ne_key, nei);
-
-      NHRP_NOTIFY (ne, nv_added);
-    }
-  else
-    return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
-
-  return 0;
-}
-
-int
-nhrp_entry_del (u32 sw_if_index, const ip46_address_t * peer)
-{
-  nhrp_entry_t *ne;
-
-  ne = nhrp_entry_find (sw_if_index, peer);
-
-  if (ne != NULL)
-    {
-      hash_unset_mem (nhrp_db, ne->ne_key);
-
-      NHRP_NOTIFY (ne, nv_deleted);
-
-      clib_mem_free (ne->ne_key);
-      pool_put (nhrp_pool, ne);
-    }
-  else
-    return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
-
-  return 0;
-}
-
-u8 *
-format_nhrp_entry (u8 * s, va_list * args)
-{
-  index_t nei = va_arg (*args, index_t);
-  vnet_main_t *vnm = vnet_get_main ();
-  nhrp_entry_t *ne;
-
-  ne = nhrp_entry_get (nei);
-
-  s = format (s, "[%d] ", nei);
-  s = format (s, "%U:", format_vnet_sw_if_index_name,
-             vnm, ne->ne_key->nk_sw_if_index);
-  s = format (s, " %U", format_ip46_address,
-             &ne->ne_key->nk_peer, IP46_TYPE_ANY);
-  s = format (s, " via [%d]:%U",
-             fib_table_get_table_id (ne->ne_fib_index, ne->ne_nh.fp_proto),
-             format_fib_prefix, &ne->ne_nh);
-
-  return (s);
-}
-
-void
-nhrp_walk (nhrp_walk_cb_t fn, void *ctx)
-{
-  index_t nei;
-
-  /* *INDENT-OFF* */
-  pool_foreach_index(nei, nhrp_pool,
-  ({
-    fn(nei, ctx);
-  }));
-  /* *INDENT-ON* */
-}
-
-void
-nhrp_walk_itf (u32 sw_if_index, nhrp_walk_cb_t fn, void *ctx)
-{
-  index_t nei;
-
-  /* *INDENT-OFF* */
-  pool_foreach_index(nei, nhrp_pool,
-  ({
-    if (sw_if_index == nhrp_entry_get_sw_if_index(nhrp_entry_get(nei)))
-      fn(nei, ctx);
-  }));
-  /* *INDENT-ON* */
-}
-
-void
-nhrp_register (const nhrp_vft_t * vft)
-{
-  vec_add1 (nhrp_vfts, *vft);
-}
-
-static clib_error_t *
-nhrp_init (vlib_main_t * vm)
-{
-  nhrp_db = hash_create_mem (0, sizeof (nhrp_key_t), sizeof (u32));
-
-  return (NULL);
-}
-
-VLIB_INIT_FUNCTION (nhrp_init);
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/vnet/nhrp/nhrp.h b/src/vnet/nhrp/nhrp.h
deleted file mode 100644 (file)
index 5b46b0d..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * nhrp.h: next-hop resolution
- *
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __NHRP_H__
-#define __NHRP_H__
-
-#include <vnet/ip/ip.h>
-
-/**
- * An NHRP entry represents the mapping between a peer on an interface in the overlay
- * and a next-hop address in the underlay.
- *  i.e. there's a multipoint tunnel providing the overlay (henace a peer on
- *   that tunnel) which is reachable via 'tunnel destination' address in the
- *   underlay.
- */
-typedef struct nhrp_entry_t_ nhrp_entry_t;
-
-/** accessors for the opaque struct */
-extern u32 nhrp_entry_get_sw_if_index (const nhrp_entry_t * ne);
-extern u32 nhrp_entry_get_fib_index (const nhrp_entry_t * ne);
-extern const ip46_address_t *nhrp_entry_get_peer (const nhrp_entry_t * ne);
-extern const fib_prefix_t *nhrp_entry_get_nh (const nhrp_entry_t * ne);
-extern u8 *format_nhrp_entry (u8 * s, va_list * args);
-
-/**
- * Create a new NHRP entry
- */
-extern int nhrp_entry_add (u32 sw_if_index,
-                          const ip46_address_t * peer,
-                          u32 nh_table_id, const ip46_address_t * nh);
-
-extern int nhrp_entry_del (u32 sw_if_index, const ip46_address_t * peer);
-
-extern nhrp_entry_t *nhrp_entry_find (u32 sw_if_index,
-                                     const ip46_address_t * peer);
-extern nhrp_entry_t *nhrp_entry_get (index_t nei);
-
-extern void nhrp_entry_adj_stack (const nhrp_entry_t * ne, adj_index_t ai);
-
-typedef walk_rc_t (*nhrp_walk_cb_t) (index_t nei, void *ctx);
-
-extern void nhrp_walk (nhrp_walk_cb_t fn, void *ctx);
-extern void nhrp_walk_itf (u32 sw_if_index, nhrp_walk_cb_t fn, void *ctx);
-
-/**
- * Notifications for the creation and deletion of NHRP entries
- */
-typedef void (*nhrp_entry_added_t) (const nhrp_entry_t * ne);
-typedef void (*nhrp_entry_deleted_t) (const nhrp_entry_t * ne);
-
-typedef struct nhrp_vft_t_
-{
-  nhrp_entry_added_t nv_added;
-  nhrp_entry_deleted_t nv_deleted;
-} nhrp_vft_t;
-
-extern void nhrp_register (const nhrp_vft_t * vft);
-
-#endif
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
similarity index 86%
rename from src/vnet/nhrp/nhrp.api
rename to src/vnet/teib/teib.api
index de0630c..8e73208 100644 (file)
@@ -19,10 +19,10 @@ option version = "1.0.0";
 import "vnet/ip/ip_types.api";
 import "vnet/interface_types.api";
 
-/** \brief NHRP Entry
+/** \brief TEIB Entry
     @param sw_if_index 
 */
-typedef nhrp_entry
+typedef teib_entry
 {
   vl_api_interface_index_t sw_if_index;
   vl_api_address_t peer;
@@ -30,24 +30,24 @@ typedef nhrp_entry
   u32 nh_table_id;
 };
 
-autoreply define nhrp_entry_add_del
+autoreply define teib_entry_add_del
 {
   u32 client_index;
   u32 context;
   u8 is_add;
-  vl_api_nhrp_entry_t entry;
+  vl_api_teib_entry_t entry;
 };
 
-define nhrp_dump
+define teib_dump
 {
   u32 client_index;
   u32 context;
 };
 
-define nhrp_details
+define teib_details
 {
   u32 context;
-  vl_api_nhrp_entry_t entry;
+  vl_api_teib_entry_t entry;
 };
 
 /*
diff --git a/src/vnet/teib/teib.c b/src/vnet/teib/teib.c
new file mode 100644 (file)
index 0000000..e392b49
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ * teib.h: next-hop resolution
+ *
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <vnet/teib/teib.h>
+#include <vnet/fib/fib_table.h>
+#include <vnet/adj/adj_midchain.h>
+
+typedef struct teib_key_t_
+{
+  ip46_address_t tk_peer;
+  u32 tk_sw_if_index;
+} teib_key_t;
+
+struct teib_entry_t_
+{
+  teib_key_t *te_key;
+  fib_prefix_t te_nh;
+  u32 te_fib_index;
+};
+
+static uword *teib_db;
+static teib_entry_t *teib_pool;
+static teib_vft_t *teib_vfts;
+
+#define TEIB_NOTIFY(_te, _fn) {                  \
+  teib_vft_t *_vft;                              \
+  vec_foreach(_vft, teib_vfts) {                 \
+    if (_vft->_fn) {                             \
+      _vft->_fn(_te);                            \
+    }                                            \
+  }                                              \
+}
+
+u32
+teib_entry_get_sw_if_index (const teib_entry_t * te)
+{
+  return (te->te_key->tk_sw_if_index);
+}
+
+u32
+teib_entry_get_fib_index (const teib_entry_t * te)
+{
+  return (te->te_fib_index);
+}
+
+const ip46_address_t *
+teib_entry_get_peer (const teib_entry_t * te)
+{
+  return (&te->te_key->tk_peer);
+}
+
+const fib_prefix_t *
+teib_entry_get_nh (const teib_entry_t * te)
+{
+  return (&te->te_nh);
+}
+
+void
+teib_entry_adj_stack (const teib_entry_t * te, adj_index_t ai)
+{
+  adj_midchain_delegate_stack (ai, te->te_fib_index, &te->te_nh);
+}
+
+teib_entry_t *
+teib_entry_get (index_t tei)
+{
+  return pool_elt_at_index (teib_pool, tei);
+}
+
+teib_entry_t *
+teib_entry_find (u32 sw_if_index, const ip46_address_t * peer)
+{
+  teib_key_t nk = {
+    .tk_peer = *peer,
+    .tk_sw_if_index = sw_if_index,
+  };
+  uword *p;
+
+  p = hash_get_mem (teib_db, &nk);
+
+  if (NULL != p)
+    return teib_entry_get (p[0]);
+
+  return (NULL);
+}
+
+int
+teib_entry_add (u32 sw_if_index,
+               const ip46_address_t * peer,
+               u32 nh_table_id, const ip46_address_t * nh)
+{
+  fib_protocol_t fproto;
+  teib_entry_t *te;
+  u32 fib_index;
+  index_t tei;
+
+  fproto = (ip46_address_is_ip4 (nh) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
+
+  fib_index = fib_table_find (fproto, nh_table_id);
+
+  if (~0 == fib_index)
+    {
+      return (VNET_API_ERROR_NO_SUCH_FIB);
+    }
+
+  te = teib_entry_find (sw_if_index, peer);
+
+  if (NULL == te)
+    {
+      teib_key_t nk = {
+       .tk_peer = *peer,
+       .tk_sw_if_index = sw_if_index,
+      };
+      teib_entry_t *te;
+
+      pool_get_zero (teib_pool, te);
+
+      tei = te - teib_pool;
+      te->te_key = clib_mem_alloc (sizeof (*te->te_key));
+      clib_memcpy (te->te_key, &nk, sizeof (*te->te_key));
+
+      ip46_address_copy (&te->te_nh.fp_addr, nh);
+      te->te_nh.fp_proto = fproto;
+      te->te_nh.fp_len = (te->te_nh.fp_proto == FIB_PROTOCOL_IP4 ? 32 : 128);
+      te->te_fib_index = fib_index;
+
+      hash_set_mem (teib_db, te->te_key, tei);
+
+      TEIB_NOTIFY (te, nv_added);
+    }
+  else
+    return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
+
+  return 0;
+}
+
+int
+teib_entry_del (u32 sw_if_index, const ip46_address_t * peer)
+{
+  teib_entry_t *te;
+
+  te = teib_entry_find (sw_if_index, peer);
+
+  if (te != NULL)
+    {
+      hash_unset_mem (teib_db, te->te_key);
+
+      TEIB_NOTIFY (te, nv_deleted);
+
+      clib_mem_free (te->te_key);
+      pool_put (teib_pool, te);
+    }
+  else
+    return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
+
+  return 0;
+}
+
+u8 *
+format_teib_entry (u8 * s, va_list * args)
+{
+  index_t tei = va_arg (*args, index_t);
+  vnet_main_t *vnm = vnet_get_main ();
+  teib_entry_t *te;
+
+  te = teib_entry_get (tei);
+
+  s = format (s, "[%d] ", tei);
+  s = format (s, "%U:", format_vnet_sw_if_index_name,
+             vnm, te->te_key->tk_sw_if_index);
+  s = format (s, " %U", format_ip46_address,
+             &te->te_key->tk_peer, IP46_TYPE_ANY);
+  s = format (s, " via [%d]:%U",
+             fib_table_get_table_id (te->te_fib_index, te->te_nh.fp_proto),
+             format_fib_prefix, &te->te_nh);
+
+  return (s);
+}
+
+void
+teib_walk (teib_walk_cb_t fn, void *ctx)
+{
+  index_t tei;
+
+  /* *INDENT-OFF* */
+  pool_foreach_index(tei, teib_pool,
+  ({
+    fn(tei, ctx);
+  }));
+  /* *INDENT-ON* */
+}
+
+void
+teib_walk_itf (u32 sw_if_index, teib_walk_cb_t fn, void *ctx)
+{
+  index_t tei;
+
+  /* *INDENT-OFF* */
+  pool_foreach_index(tei, teib_pool,
+  ({
+    if (sw_if_index == teib_entry_get_sw_if_index(teib_entry_get(tei)))
+      fn(tei, ctx);
+  }));
+  /* *INDENT-ON* */
+}
+
+void
+teib_register (const teib_vft_t * vft)
+{
+  vec_add1 (teib_vfts, *vft);
+}
+
+static clib_error_t *
+teib_init (vlib_main_t * vm)
+{
+  teib_db = hash_create_mem (0, sizeof (teib_key_t), sizeof (u32));
+
+  return (NULL);
+}
+
+VLIB_INIT_FUNCTION (teib_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/teib/teib.h b/src/vnet/teib/teib.h
new file mode 100644 (file)
index 0000000..4a03eee
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * teib.h: next-hop resolution
+ *
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TEIB_H__
+#define __TEIB_H__
+
+#include <vnet/ip/ip.h>
+
+/**
+ * Tunnel Endpoint Information Base.
+ *
+ * A TEIB entry represents the mapping between a peer on an interface in the overlay
+ * and a next-hop address in the underlay.
+ *  i.e. there's a multipoint tunnel providing the overlay (henace a peer on
+ *   that tunnel) which is reachable via 'tunnel destination' address in the
+ *   underlay.
+ *
+ * Such overlay to underlay mappings might be providied by a protocol like NHRP
+ */
+typedef struct teib_entry_t_ teib_entry_t;
+
+/** accessors for the opaque struct */
+extern u32 teib_entry_get_sw_if_index (const teib_entry_t * ne);
+extern u32 teib_entry_get_fib_index (const teib_entry_t * ne);
+extern const ip46_address_t *teib_entry_get_peer (const teib_entry_t * ne);
+extern const fib_prefix_t *teib_entry_get_nh (const teib_entry_t * ne);
+extern u8 *format_teib_entry (u8 * s, va_list * args);
+
+/**
+ * Create a new TEIB entry
+ */
+extern int teib_entry_add (u32 sw_if_index,
+                          const ip46_address_t * peer,
+                          u32 nh_table_id, const ip46_address_t * nh);
+
+extern int teib_entry_del (u32 sw_if_index, const ip46_address_t * peer);
+
+extern teib_entry_t *teib_entry_find (u32 sw_if_index,
+                                     const ip46_address_t * peer);
+extern teib_entry_t *teib_entry_get (index_t nei);
+
+extern void teib_entry_adj_stack (const teib_entry_t * ne, adj_index_t ai);
+
+typedef walk_rc_t (*teib_walk_cb_t) (index_t nei, void *ctx);
+
+extern void teib_walk (teib_walk_cb_t fn, void *ctx);
+extern void teib_walk_itf (u32 sw_if_index, teib_walk_cb_t fn, void *ctx);
+
+/**
+ * Notifications for the creation and deletion of TEIB entries
+ */
+typedef void (*teib_entry_added_t) (const teib_entry_t * ne);
+typedef void (*teib_entry_deleted_t) (const teib_entry_t * ne);
+
+typedef struct teib_vft_t_
+{
+  teib_entry_added_t nv_added;
+  teib_entry_deleted_t nv_deleted;
+} teib_vft_t;
+
+extern void teib_register (const teib_vft_t * vft);
+
+#endif
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
similarity index 64%
rename from src/vnet/nhrp/nhrp_api.c
rename to src/vnet/teib/teib_api.c
index d36adf9..a51dd6d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *------------------------------------------------------------------
- * nhrp_api.c - nhrp api
+ * teib_api.c - teib api
  *
  * Copyright (c) 2016 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
 #include <vlibmemory/api.h>
 
 #include <vnet/api_errno.h>
-#include <vnet/nhrp/nhrp.h>
+#include <vnet/teib/teib.h>
 #include <vnet/ip/ip_types_api.h>
 #include <vnet/fib/fib_table.h>
 
 /* define message IDs */
 #include <vnet/format_fns.h>
-#include <vnet/nhrp/nhrp.api_enum.h>
-#include <vnet/nhrp/nhrp.api_types.h>
+#include <vnet/teib/teib.api_enum.h>
+#include <vnet/teib/teib.api_types.h>
 
-static u32 nhrp_base_msg_id;
-#define REPLY_MSG_ID_BASE nhrp_base_msg_id
+static u32 teib_base_msg_id;
+#define REPLY_MSG_ID_BASE teib_base_msg_id
 
 #include <vlibapi/api_helper_macros.h>
 
 static void
-vl_api_nhrp_entry_add_del_t_handler (vl_api_nhrp_entry_add_del_t * mp)
+vl_api_teib_entry_add_del_t_handler (vl_api_teib_entry_add_del_t * mp)
 {
-  vl_api_nhrp_entry_add_del_reply_t *rmp;
+  vl_api_teib_entry_add_del_reply_t *rmp;
   ip46_address_t peer, nh;
   int rv;
 
@@ -48,45 +48,45 @@ vl_api_nhrp_entry_add_del_t_handler (vl_api_nhrp_entry_add_del_t * mp)
   ip_address_decode (&mp->entry.nh, &nh);
 
   if (mp->is_add)
-    rv = nhrp_entry_add (ntohl (mp->entry.sw_if_index), &peer,
+    rv = teib_entry_add (ntohl (mp->entry.sw_if_index), &peer,
                         ntohl (mp->entry.nh_table_id), &nh);
   else
-    rv = nhrp_entry_del (ntohl (mp->entry.sw_if_index), &peer);
+    rv = teib_entry_del (ntohl (mp->entry.sw_if_index), &peer);
 
   BAD_SW_IF_INDEX_LABEL;
 
-  REPLY_MACRO (VL_API_NHRP_ENTRY_ADD_DEL_REPLY);
+  REPLY_MACRO (VL_API_TEIB_ENTRY_ADD_DEL_REPLY);
 }
 
-typedef struct vl_api_nhrp_send_t_
+typedef struct vl_api_teib_send_t_
 {
   vl_api_registration_t *reg;
   u32 context;
-} vl_api_nhrp_send_t;
+} vl_api_teib_send_t;
 
 static walk_rc_t
-vl_api_nhrp_send_one (index_t nei, void *arg)
+vl_api_teib_send_one (index_t nei, void *arg)
 {
-  vl_api_nhrp_details_t *mp;
-  vl_api_nhrp_send_t *ctx = arg;
-  const nhrp_entry_t *ne;
+  vl_api_teib_details_t *mp;
+  vl_api_teib_send_t *ctx = arg;
+  const teib_entry_t *ne;
   const fib_prefix_t *pfx;
 
   mp = vl_msg_api_alloc (sizeof (*mp));
   clib_memset (mp, 0, sizeof (*mp));
-  mp->_vl_msg_id = ntohs (VL_API_NHRP_DETAILS + REPLY_MSG_ID_BASE);
+  mp->_vl_msg_id = ntohs (VL_API_TEIB_DETAILS + REPLY_MSG_ID_BASE);
   mp->context = ctx->context;
 
-  ne = nhrp_entry_get (nei);
-  pfx = nhrp_entry_get_nh (ne);
+  ne = teib_entry_get (nei);
+  pfx = teib_entry_get_nh (ne);
 
-  ip_address_encode (nhrp_entry_get_peer (ne), IP46_TYPE_ANY,
+  ip_address_encode (teib_entry_get_peer (ne), IP46_TYPE_ANY,
                     &mp->entry.peer);
   ip_address_encode (&pfx->fp_addr, IP46_TYPE_ANY, &mp->entry.nh);
   mp->entry.nh_table_id =
     htonl (fib_table_get_table_id
-          (nhrp_entry_get_fib_index (ne), pfx->fp_proto));
-  mp->entry.sw_if_index = htonl (nhrp_entry_get_sw_if_index (ne));
+          (teib_entry_get_fib_index (ne), pfx->fp_proto));
+  mp->entry.sw_if_index = htonl (teib_entry_get_sw_if_index (ne));
 
   vl_api_send_msg (ctx->reg, (u8 *) mp);
 
@@ -94,7 +94,7 @@ vl_api_nhrp_send_one (index_t nei, void *arg)
 }
 
 static void
-vl_api_nhrp_dump_t_handler (vl_api_nhrp_dump_t * mp)
+vl_api_teib_dump_t_handler (vl_api_teib_dump_t * mp)
 {
   vl_api_registration_t *reg;
 
@@ -102,32 +102,32 @@ vl_api_nhrp_dump_t_handler (vl_api_nhrp_dump_t * mp)
   if (!reg)
     return;
 
-  vl_api_nhrp_send_t ctx = {
+  vl_api_teib_send_t ctx = {
     .reg = reg,
     .context = mp->context,
   };
 
-  nhrp_walk (vl_api_nhrp_send_one, &ctx);
+  teib_walk (vl_api_teib_send_one, &ctx);
 }
 
 /*
- * nhrp_api_hookup
+ * teib_api_hookup
  * Add vpe's API message handlers to the table.
  * vlib has already mapped shared memory and
  * added the client registration handlers.
  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
  */
-#include <vnet/nhrp/nhrp.api.c>
+#include <vnet/teib/teib.api.c>
 
 static clib_error_t *
-nhrp_api_hookup (vlib_main_t * vm)
+teib_api_hookup (vlib_main_t * vm)
 {
-  nhrp_base_msg_id = setup_message_id_table ();
+  teib_base_msg_id = setup_message_id_table ();
 
   return (NULL);
 }
 
-VLIB_API_INIT_FUNCTION (nhrp_api_hookup);
+VLIB_API_INIT_FUNCTION (teib_api_hookup);
 
 /*
  * fd.io coding-style-patch-verification: ON
similarity index 83%
rename from src/vnet/nhrp/nhrp_cli.c
rename to src/vnet/teib/teib_cli.c
index 654c750..faf0d82 100644 (file)
  * limitations under the License.
  */
 
-#include <vnet/nhrp/nhrp.h>
+#include <vnet/teib/teib.h>
 
 static clib_error_t *
-nhrp_add (vlib_main_t * vm,
+teib_add (vlib_main_t * vm,
          unformat_input_t * input, vlib_cli_command_t * cmd)
 {
   unformat_input_t _line_input, *line_input = &_line_input;
@@ -71,7 +71,7 @@ nhrp_add (vlib_main_t * vm,
       goto done;
     }
 
-  rv = nhrp_entry_add (sw_if_index, &peer, nh_table_id, &nh);
+  rv = teib_entry_add (sw_if_index, &peer, nh_table_id, &nh);
 
   if (rv)
     {
@@ -87,15 +87,15 @@ done:
 }
 
 /* *INDENT-OFF* */
-VLIB_CLI_COMMAND (nhrp_create_command, static) = {
-  .path = "create nhrp",
-  .short_help = "create nhrp <interface> peer <addr> nh <addr> [nh-table-id <ID>]",
-  .function = nhrp_add,
+VLIB_CLI_COMMAND (teib_create_command, static) = {
+  .path = "create teib",
+  .short_help = "create teib <interface> peer <addr> nh <addr> [nh-table-id <ID>]",
+  .function = teib_add,
 };
 /* *INDENT-ON* */
 
 static clib_error_t *
-nhrp_del (vlib_main_t * vm,
+teib_del (vlib_main_t * vm,
          unformat_input_t * input, vlib_cli_command_t * cmd)
 {
   unformat_input_t _line_input, *line_input = &_line_input;
@@ -137,7 +137,7 @@ nhrp_del (vlib_main_t * vm,
       goto done;
     }
 
-  rv = nhrp_entry_del (sw_if_index, &peer);
+  rv = teib_entry_del (sw_if_index, &peer);
 
   if (rv)
     {
@@ -153,35 +153,35 @@ done:
 }
 
 /* *INDENT-OFF* */
-VLIB_CLI_COMMAND (nhrp_delete_command, static) = {
-  .path = "delete nhrp",
-  .short_help = "delete nhrp <interface> peer <addr>",
-  .function = nhrp_del,
+VLIB_CLI_COMMAND (teib_delete_command, static) = {
+  .path = "delete teib",
+  .short_help = "delete teib <interface> peer <addr>",
+  .function = teib_del,
 };
 /* *INDENT-ON* */
 
 static walk_rc_t
-nhrp_show_one (index_t nei, void *ctx)
+teib_show_one (index_t nei, void *ctx)
 {
-  vlib_cli_output (ctx, "%U", format_nhrp_entry, nei);
+  vlib_cli_output (ctx, "%U", format_teib_entry, nei);
 
   return (WALK_CONTINUE);
 }
 
 
 static clib_error_t *
-nhrp_show (vlib_main_t * vm,
+teib_show (vlib_main_t * vm,
           unformat_input_t * input, vlib_cli_command_t * cmd)
 {
-  nhrp_walk (nhrp_show_one, vm);
+  teib_walk (teib_show_one, vm);
   return (NULL);
 }
 
 /* *INDENT-OFF* */
-VLIB_CLI_COMMAND (nhrp_show_command, static) = {
-  .path = "show nhrp",
-  .short_help = "show nhrp",
-  .function = nhrp_show,
+VLIB_CLI_COMMAND (teib_show_command, static) = {
+  .path = "show teib",
+  .short_help = "show teib",
+  .function = teib_show,
 };
 /* *INDENT-ON* */
 
index e73ba2f..c604378 100644 (file)
@@ -12,7 +12,7 @@ from scapy.volatile import RandMAC, RandIP
 from framework import VppTestCase, VppTestRunner
 from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint
 from vpp_gre_interface import VppGreInterface
-from vpp_nhrp import VppNhrp
+from vpp_teib import VppNhrp
 from vpp_ip import DpoProto
 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
 from util import ppp, ppc
@@ -1069,10 +1069,10 @@ class TestGRE(VppTestCase):
                 #
                 # Add a NHRP entry resolves the peer
                 #
-                nhrp = VppNhrp(self, gre_if,
+                teib = VppNhrp(self, gre_if,
                                gre_if._remote_hosts[ii].ip4,
                                itf._remote_hosts[ii].ip4)
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
 
                 #
                 # Send a packet stream that is routed into the tunnel
@@ -1095,11 +1095,11 @@ class TestGRE(VppTestCase):
                 #
                 # delete and re-add the NHRP
                 #
-                nhrp.remove_vpp_config()
+                teib.remove_vpp_config()
                 self.send_and_assert_no_replies(self.pg0, tx_e)
                 self.send_and_assert_no_replies(self.pg0, tx_i)
 
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
                 rx = self.send_and_expect(self.pg0, tx_e, itf)
                 self.verify_tunneled_4o4(self.pg0, rx, tx_e,
                                          itf.local_ip4,
@@ -1154,10 +1154,10 @@ class TestGRE(VppTestCase):
                 #
                 # Add a NHRP entry resolves the peer
                 #
-                nhrp = VppNhrp(self, gre_if,
+                teib = VppNhrp(self, gre_if,
                                gre_if._remote_hosts[ii].ip6,
                                itf._remote_hosts[ii].ip6)
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
 
                 #
                 # route traffic via the peer
@@ -1190,10 +1190,10 @@ class TestGRE(VppTestCase):
                 #
                 # delete and re-add the NHRP
                 #
-                nhrp.remove_vpp_config()
+                teib.remove_vpp_config()
                 self.send_and_assert_no_replies(self.pg0, tx_e)
 
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
                 rx = self.send_and_expect(self.pg0, tx_e, itf)
                 self.verify_tunneled_6o6(self.pg0, rx, tx_e,
                                          itf.local_ip6,
index 511164f..1cc4a7d 100644 (file)
@@ -8,7 +8,7 @@ from framework import VppTestCase, VppTestRunner
 from vpp_ip import DpoProto
 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
 from vpp_ipip_tun_interface import VppIpIpTunInterface
-from vpp_nhrp import VppNhrp
+from vpp_teib import VppNhrp
 from vpp_papi import VppEnum
 from socket import AF_INET, AF_INET6, inet_pton
 from util import reassemble4
@@ -530,10 +530,10 @@ class TestIPIP(VppTestCase):
                 #
                 # Add a NHRP entry resolves the peer
                 #
-                nhrp = VppNhrp(self, ipip_if,
+                teib = VppNhrp(self, ipip_if,
                                ipip_if._remote_hosts[ii].ip4,
                                itf._remote_hosts[ii].ip4)
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
                 self.logger.info(self.vapi.cli("sh adj nbr ipip0 %s" %
                                                ipip_if._remote_hosts[ii].ip4))
 
@@ -568,11 +568,11 @@ class TestIPIP(VppTestCase):
                 #
                 # delete and re-add the NHRP
                 #
-                nhrp.remove_vpp_config()
+                teib.remove_vpp_config()
                 self.send_and_assert_no_replies(self.pg0, tx_e)
                 self.send_and_assert_no_replies(self.pg0, tx_i)
 
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
                 rx = self.send_and_expect(self.pg0, tx_e, itf)
                 for rx in rxs:
                     self.assertEqual(rx[IP].src, itf.local_ip4)
similarity index 80%
rename from test/vpp_nhrp.py
rename to test/vpp_teib.py
index e04e305..e117ac3 100644 (file)
@@ -6,8 +6,8 @@
 from vpp_object import VppObject
 
 
-def find_nhrp(test, ne):
-    ns = test.vapi.nhrp_dump()
+def find_teib(test, ne):
+    ns = test.vapi.teib_dump()
     for n in ns:
         if ne.peer == str(n.entry.peer) \
            and ne.itf._sw_if_index == n.entry.sw_if_index:
@@ -25,7 +25,7 @@ class VppNhrp(VppObject):
         self.nh = nh
 
     def add_vpp_config(self):
-        r = self._test.vapi.nhrp_entry_add_del(
+        r = self._test.vapi.teib_entry_add_del(
             is_add=1,
             entry={
                 'nh_table_id': self.table_id,
@@ -36,7 +36,7 @@ class VppNhrp(VppObject):
         self._test.registry.register(self, self._test.logger)
 
     def remove_vpp_config(self):
-        r = self._test.vapi.nhrp_entry_add_del(
+        r = self._test.vapi.teib_entry_add_del(
             is_add=0,
             entry={
                 'nh_table_id': self.table_id,
@@ -45,7 +45,7 @@ class VppNhrp(VppObject):
             })
 
     def query_vpp_config(self):
-        return find_nhrp(self._test, self)
+        return find_teib(self._test, self)
 
     def object_id(self):
-        return ("nhrp-%s-%s" % (self.itf, self.peer))
+        return ("teib-%s-%s" % (self.itf, self.peer))