LISP: re-fetch mapping before it expires
[vpp.git] / src / vnet / lisp-cp / lisp_api.c
index 78d32e1..f7c4197 100644 (file)
 #define vl_api_lisp_add_del_remote_mapping_t_endian vl_noop_handler
 #define vl_api_lisp_add_del_remote_mapping_t_print vl_noop_handler
 
+#define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
+#define vl_api_one_add_del_locator_set_t_print vl_noop_handler
+#define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
+#define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
+
 #define vl_typedefs            /* define message structures */
 #include <vnet/vnet_all_api_h.h>
 #undef vl_typedefs
@@ -440,9 +445,24 @@ vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp)
   /* *INDENT-OFF* */
   REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY,
   {
-      rmp->status = status;
-      gid_address_put (rmp->address, &addr);
-      rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
+    rmp->status = status;
+    ip_address_t *ip = &gid_address_ip (&addr);
+    switch (ip_addr_version (ip))
+      {
+      case IP4:
+        clib_memcpy (rmp->address, &ip_addr_v4 (ip),
+                     sizeof (ip_addr_v4 (ip)));
+        break;
+
+      case IP6:
+        clib_memcpy (rmp->address, &ip_addr_v6 (ip),
+                     sizeof (ip_addr_v6 (ip)));
+        break;
+
+      default:
+        ASSERT (0);
+      }
+    rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
   });
   /* *INDENT-ON* */
 }
@@ -501,8 +521,19 @@ static void
 
   /* NOTE: for now this works as a static remote mapping, i.e.,
    * not authoritative and ttl infinite. */
-  rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
-                                 mp->is_add, 1 /* is_static */ , 0);
+  if (mp->is_add)
+    {
+      vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
+      memset (m_args, 0, sizeof (m_args[0]));
+      gid_address_copy (&m_args->eid, eid);
+      m_args->action = mp->action;
+      m_args->is_static = 1;
+      m_args->ttl = ~0;
+      m_args->authoritative = 0;
+      rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
+    }
+  else
+    rv = vnet_lisp_del_mapping (eid, NULL);
 
   if (mp->del_all)
     vnet_lisp_clear_all_remote_adjacencies ();
@@ -752,6 +783,10 @@ send_lisp_eid_table_details (mapping_t * mapit,
       return;
     }
 
+  /* don't send PITR generated mapping */
+  if (mapit->pitr_set)
+    return;
+
   gid = &mapit->eid;
   ip_prefix = &gid_address_ippref (gid);
   mac = gid_address_mac (gid);