ONE-11: Fix bugs in LISP API
[vpp.git] / vpp / api / api.c
index 9c988a1..9bf4d3c 100644 (file)
@@ -42,6 +42,7 @@
 #include <vppinfra/format.h>
 #include <vppinfra/error.h>
 
+#include <vnet/api_errno.h> // alagalah TODO : committers please pay note, is this ok?
 #include <vnet/vnet.h>
 #include <vnet/l2/l2_input.h>
 #include <vnet/l2/l2_bd.h>
@@ -64,6 +65,7 @@
 #include <vnet/classify/input_acl.h>
 #include <vnet/l2/l2_classify.h>
 #include <vnet/vxlan/vxlan.h>
+#include <vnet/gre/gre.h>
 #include <vnet/l2/l2_vtr.h>
 #include <vnet/nsh-gre/nsh_gre.h>
 #include <vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h>
@@ -72,6 +74,7 @@
 #include <vnet/map/map.h>
 #include <vnet/cop/cop.h>
 #include <vnet/ip/ip6_hop_by_hop.h>
+#include <vnet/devices/af_packet/af_packet.h>
 
 #undef BIHASH_TYPE
 #undef __included_bihash_template_h__
@@ -272,6 +275,8 @@ _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key)                         \
 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)                   \
 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel)                           \
 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump)                                 \
+_(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel)                               \
+_(GRE_TUNNEL_DUMP, gre_tunnel_dump)                                     \
 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table)                               \
 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter)                     \
 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)         \
@@ -287,7 +292,6 @@ _(NSH_GRE_ADD_DEL_TUNNEL, nsh_gre_add_del_tunnel)                   \
 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump)                                        \
 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry)                               \
 _(NSH_VXLAN_GPE_ADD_DEL_TUNNEL, nsh_vxlan_gpe_add_del_tunnel)           \
-_(LISP_GPE_ADD_DEL_TUNNEL, lisp_gpe_add_del_tunnel)                    \
 _(INTERFACE_NAME_RENUMBER, interface_name_renumber)                    \
 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events)                             \
 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface)                     \
@@ -322,11 +326,17 @@ _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid)                       \
 _(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry)               \
 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver)                 \
 _(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable)                     \
+_(LISP_ENABLE_DISABLE, lisp_enable_disable)                             \
 _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface)                       \
 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump)                         \
 _(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump)                 \
 _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump)                           \
-_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)
+_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)                       \
+_(LISP_ENABLE_DISABLE_STATUS_DUMP,                                      \
+  lisp_enable_disable_status_dump)                                      \
+_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del)                   \
+_(AF_PACKET_CREATE, af_packet_create)                                   \
+_(AF_PACKET_DELETE, af_packet_delete)
 
 #define QUOTE_(x) #x
 #define QUOTE(x) QUOTE_(x)
@@ -1492,7 +1502,8 @@ static void vl_api_bridge_domain_sw_if_details_t_handler (
 
 static void send_bridge_domain_details (unix_shared_memory_queue_t *q,
                                         l2_bridge_domain_t * bd_config,
-                                        u32 n_sw_ifs)
+                                        u32 n_sw_ifs,
+                                        u32 context)
 {
     vl_api_bridge_domain_details_t * mp;
 
@@ -1507,13 +1518,15 @@ static void send_bridge_domain_details (unix_shared_memory_queue_t *q,
     mp->arp_term = bd_feature_arp_term (bd_config);
     mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
     mp->n_sw_ifs = ntohl (n_sw_ifs);
+    mp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&mp);
 }
 
 static void send_bd_sw_if_details (l2input_main_t * l2im,
                                    unix_shared_memory_queue_t *q,
-                                   l2_flood_member_t * member, u32 bd_id)
+                                   l2_flood_member_t * member, u32 bd_id,
+                                   u32 context)
 {
     vl_api_bridge_domain_sw_if_details_t * mp;
     l2_input_config_t * input_cfg;
@@ -1525,6 +1538,7 @@ static void send_bd_sw_if_details (l2input_main_t * l2im,
     mp->sw_if_index = ntohl (member->sw_if_index);
     input_cfg = vec_elt_at_index (l2im->configs, member->sw_if_index);
     mp->shg = input_cfg->shg;
+    mp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&mp);
 }
@@ -1556,10 +1570,10 @@ static void vl_api_bridge_domain_dump_t_handler (
             l2_flood_member_t * m;
             
             n_sw_ifs = vec_len (bd_config->members);
-            send_bridge_domain_details (q, bd_config, n_sw_ifs);
+            send_bridge_domain_details (q, bd_config, n_sw_ifs, mp->context);
             
             vec_foreach (m, bd_config->members) {
-                send_bd_sw_if_details (l2im, q, m, bd_config->bd_id);
+                send_bd_sw_if_details (l2im, q, m, bd_config->bd_id, mp->context);
             }
         }
     }
@@ -3386,7 +3400,15 @@ static void vl_api_sr_tunnel_add_del_t_handler
     a->is_del = (mp->is_add == 0);
     a->rx_table_id = ntohl(mp->outer_vrf_id);
     a->tx_table_id = ntohl(mp->inner_vrf_id);
-
+    
+    a->name = format(0, "%s", mp->name);
+    if (!(vec_len(a->name)))
+      a->name = 0;
+    
+    a->policy_name = format(0, "%s", mp->policy_name);
+    if (!(vec_len(a->policy_name)))
+      a->policy_name = 0;
+    
     /* Yank segments and tags out of the API message */
     this_address = (ip6_address_t *)mp->segs_and_tags;
     for (i = 0; i < mp->n_segments; i++) {
@@ -3411,6 +3433,101 @@ out:
 #endif
 }
 
+static void vl_api_sr_policy_add_del_t_handler
+(vl_api_sr_policy_add_del_t *mp)
+{
+#if IPV6SR == 0
+    clib_warning ("unimplemented");
+#else
+    ip6_sr_add_del_policy_args_t _a, *a=&_a;
+    int rv = 0;
+    vl_api_sr_policy_add_del_reply_t * rmp;
+    int i;
+
+    memset (a, 0, sizeof (*a));
+    a->is_del = (mp->is_add == 0);
+    
+    a->name = format(0, "%s", mp->name);
+    if (!(vec_len(a->name)))
+      {
+        rv = VNET_API_ERROR_NO_SUCH_NODE2;
+       goto out;
+      }      
+
+    if (!(mp->tunnel_names[0]))
+      {
+        rv = VNET_API_ERROR_NO_SUCH_NODE2;
+       goto out;
+      }
+
+    // start deserializing tunnel_names
+    int num_tunnels = mp->tunnel_names[0]; //number of tunnels
+    u8 * deser_tun_names = mp->tunnel_names;
+    deser_tun_names += 1; //moving along
+
+    u8 * tun_name = 0;
+    int tun_name_len = 0;
+
+    for (i=0; i < num_tunnels; i++)
+      {
+       tun_name_len= *deser_tun_names;
+       deser_tun_names += 1;
+       vec_resize (tun_name, tun_name_len);
+       memcpy(tun_name, deser_tun_names, tun_name_len);
+       vec_add1 (a->tunnel_names, tun_name);
+       deser_tun_names += tun_name_len;
+       tun_name = 0;
+      }
+    
+    rv = ip6_sr_add_del_policy (a);
+
+out:
+
+    REPLY_MACRO(VL_API_SR_POLICY_ADD_DEL_REPLY);
+#endif
+}
+
+static void vl_api_sr_multicast_map_add_del_t_handler
+(vl_api_sr_multicast_map_add_del_t *mp)
+{
+#if IPV6SR == 0
+    clib_warning ("unimplemented");
+#else
+    ip6_sr_add_del_multicastmap_args_t _a, *a=&_a;
+    int rv = 0;
+    vl_api_sr_multicast_map_add_del_reply_t * rmp;
+
+    memset (a, 0, sizeof (*a));
+    a->is_del = (mp->is_add == 0);
+    
+    a->multicast_address = (ip6_address_t *)&mp->multicast_address;
+    a->policy_name = format(0, "%s", mp->policy_name);
+
+    if (a->multicast_address == 0)
+      {
+        rv = -1 ; 
+       goto out;
+      }      
+
+    if (!(a->policy_name))
+      {
+        rv = -2 ; 
+       goto out;
+      }
+
+#if DPDK > 0 /* Cannot call replicate without DPDK */
+    rv = ip6_sr_add_del_multicastmap (a);
+#else
+    clib_warning ("multicast replication without DPDK not implemented");
+    rv = VNET_API_ERROR_UNIMPLEMENTED;
+#endif /* DPDK */
+
+out:
+
+    REPLY_MACRO(VL_API_SR_MULTICAST_MAP_ADD_DEL_REPLY);
+#endif
+}
+
 #define foreach_classify_add_del_table_field    \
 _(table_index)                                  \
 _(nbuckets)                                     \
@@ -3783,7 +3900,8 @@ static void send_ip_address_details (vpe_api_main_t * am,
                                      unix_shared_memory_queue_t * q,
                                      u8 * ip,
                                      u16 prefix_length,
-                                     u8 is_ipv6)
+                                     u8 is_ipv6,
+                                     u32 context)
 {
     vl_api_ip_address_details_t * mp;
 
@@ -3798,6 +3916,7 @@ static void send_ip_address_details (vpe_api_main_t * am,
         *tp = ntohl(*(u32*)ip);
     }
     mp->prefix_length = prefix_length;
+    mp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&mp);
 }
@@ -3815,6 +3934,9 @@ vl_api_ip_address_dump_t_handler (vl_api_ip_address_dump_t *mp)
     ip_lookup_main_t * lm4 = &im4->lookup_main;
     ip_interface_address_t * ia = 0;
     u32 sw_if_index = ~0;
+    int rv __attribute__ ((unused)) = 0;
+
+    VALIDATE_SW_IF_INDEX(mp);
 
     sw_if_index = ntohl(mp->sw_if_index);
 
@@ -3829,7 +3951,7 @@ vl_api_ip_address_dump_t_handler (vl_api_ip_address_dump_t *mp)
         ({
             r6 = ip_interface_address_get_address (lm6, ia);
             u16 prefix_length = ia->address_length;
-            send_ip_address_details(am, q, (u8*)r6, prefix_length, 1);
+            send_ip_address_details(am, q, (u8*)r6, prefix_length, 1, mp->context);
         }));
     } else {
         foreach_ip_interface_address (lm4, ia, sw_if_index,
@@ -3837,14 +3959,16 @@ vl_api_ip_address_dump_t_handler (vl_api_ip_address_dump_t *mp)
         ({
             r4 = ip_interface_address_get_address (lm4, ia);
             u16 prefix_length = ia->address_length;
-            send_ip_address_details(am, q, (u8*)r4, prefix_length, 0);
+            send_ip_address_details(am, q, (u8*)r4, prefix_length, 0, mp->context);
         }));
     }
+    BAD_SW_IF_INDEX_LABEL;
 }
 
 static void send_ip_details (vpe_api_main_t * am,
                                unix_shared_memory_queue_t *q,
-                               u32 sw_if_index)
+                               u32 sw_if_index,
+                               u32 context)
 {
     vl_api_ip_details_t * mp;
 
@@ -3853,6 +3977,7 @@ static void send_ip_details (vpe_api_main_t * am,
     mp->_vl_msg_id = ntohs(VL_API_IP_DETAILS);
 
     mp->sw_if_index = ntohl(sw_if_index);
+    mp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&mp);
 }
@@ -3879,7 +4004,8 @@ vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (
 
 static void send_sw_interface_tap_details (vpe_api_main_t * am,
                                        unix_shared_memory_queue_t *q,
-                                       tapcli_interface_details_t *tap_if)
+                                       tapcli_interface_details_t *tap_if,
+                                       u32 context)
 {
     vl_api_sw_interface_tap_details_t * mp;
     mp = vl_msg_api_alloc (sizeof (*mp));
@@ -3888,6 +4014,7 @@ static void send_sw_interface_tap_details (vpe_api_main_t * am,
     mp->sw_if_index = ntohl(tap_if->sw_if_index);
     strncpy((char *)mp->dev_name,
             (char *)tap_if->dev_name, ARRAY_LEN(mp->dev_name)-1);
+    mp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&mp);
 }
@@ -3911,7 +4038,7 @@ vl_api_sw_interface_tap_dump_t_handler (
         return;
 
     vec_foreach(tap_if, tapifs) {
-        send_sw_interface_tap_details(am, q, tap_if);
+        send_sw_interface_tap_details(am, q, tap_if, mp->context);
     }
 
     vec_free(tapifs);
@@ -3944,7 +4071,7 @@ vl_api_ip_dump_t_handler (vl_api_ip_dump_t *mp)
                 continue;
             }
             sw_if_index = si->sw_if_index;
-            send_ip_details(am, q, sw_if_index);
+            send_ip_details(am, q, sw_if_index, mp->context);
         }
     }
 }
@@ -4229,7 +4356,7 @@ out:
 }
 
 static void send_vxlan_tunnel_details
-(vxlan_tunnel_t * t, unix_shared_memory_queue_t * q)
+(vxlan_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
 {
     vl_api_vxlan_tunnel_details_t * rmp;
     ip4_main_t * im4 = &ip4_main;
@@ -4252,6 +4379,7 @@ static void send_vxlan_tunnel_details
     rmp->decap_next_index = htonl(t->decap_next_index);
     rmp->sw_if_index = htonl(t->sw_if_index);
     rmp->is_ipv6 = is_ipv6;
+    rmp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&rmp);
 }
@@ -4274,7 +4402,7 @@ static void vl_api_vxlan_tunnel_dump_t_handler
     if (~0 == sw_if_index) {
         pool_foreach (t, vxm->tunnels,
         ({
-            send_vxlan_tunnel_details(t, q);
+            send_vxlan_tunnel_details(t, q, mp->context);
         }));
     } else {
         if ((sw_if_index >= vec_len(vxm->tunnel_index_by_sw_if_index)) ||
@@ -4282,7 +4410,97 @@ static void vl_api_vxlan_tunnel_dump_t_handler
             return;
         }
         t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]];
-        send_vxlan_tunnel_details(t, q);
+        send_vxlan_tunnel_details(t, q, mp->context);
+    }
+}
+
+static void vl_api_gre_add_del_tunnel_t_handler
+(vl_api_gre_add_del_tunnel_t * mp)
+{
+    vl_api_gre_add_del_tunnel_reply_t * rmp;
+    int rv = 0;
+    vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
+    u32 outer_table_id;
+    uword * p;
+    ip4_main_t * im = &ip4_main;
+    u32 sw_if_index = ~0;
+
+    p = hash_get (im->fib_index_by_table_id, ntohl(mp->outer_table_id));
+    if (! p) {
+        rv = VNET_API_ERROR_NO_SUCH_FIB;
+        goto out;
+    }
+    outer_table_id = p[0];
+
+    /* Check src & dst are different */
+    if (memcmp(&mp->src_address, &mp->dst_address, 4) == 0) {
+        rv = VNET_API_ERROR_SAME_SRC_DST;
+        goto out;
+    }
+
+    memset (a, 0, sizeof (*a));
+
+    a->is_add = mp->is_add;
+
+    /* ip addresses sent in network byte order */
+    a->src.as_u32 = mp->src_address;
+    a->dst.as_u32 = mp->dst_address;
+
+    a->outer_table_id = outer_table_id;
+    rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
+
+out:
+    REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
+    ({
+        rmp->sw_if_index = ntohl (sw_if_index);
+    }));
+}
+
+static void send_gre_tunnel_details
+(gre_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
+{
+    vl_api_gre_tunnel_details_t * rmp;
+    ip4_main_t * im = &ip4_main;
+
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_GRE_TUNNEL_DETAILS);
+    rmp->src_address = t->tunnel_src.data_u32;
+    rmp->dst_address = t->tunnel_dst.data_u32;
+    rmp->outer_table_id = htonl(im->fibs[t->outer_fib_index].table_id);
+    rmp->sw_if_index = htonl(t->sw_if_index);
+    rmp->context = context;
+
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void vl_api_gre_tunnel_dump_t_handler
+(vl_api_gre_tunnel_dump_t * mp)
+{
+    unix_shared_memory_queue_t * q;
+    gre_main_t * gm = &gre_main;
+    gre_tunnel_t * t;
+    u32 sw_if_index;
+
+    q = vl_api_client_index_to_input_queue (mp->client_index);
+    if (q == 0) {
+        return;
+    }
+
+    sw_if_index = ntohl(mp->sw_if_index);
+
+    if (~0 == sw_if_index) {
+        pool_foreach (t, gm->tunnels,
+        ({
+            send_gre_tunnel_details(t, q, mp->context);
+        }));
+    } else {
+        if ((sw_if_index >= vec_len(gm->tunnel_index_by_sw_if_index)) ||
+                (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index])) {
+            return;
+        }
+        t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]];
+        send_gre_tunnel_details(t, q, mp->context);
     }
 }
 
@@ -4334,7 +4552,7 @@ vl_api_nsh_gre_add_del_tunnel_t_handler
     decap_next_index = ntohl(mp->decap_next_index);
 
     /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
-    if (decap_next_index == NSH_INPUT_NEXT_IP4_INPUT) {
+    if (decap_next_index == NSH_GRE_INPUT_NEXT_IP4_INPUT) {
         p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
         if (! p) {
             rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
@@ -4354,20 +4572,20 @@ vl_api_nsh_gre_add_del_tunnel_t_handler
     a->encap_fib_index = encap_fib_index;
     a->decap_fib_index = decap_fib_index;
     a->decap_next_index = decap_next_index;
-    a->ver_o_c = mp->ver_o_c;
-    a->length = mp->length;
-    a->md_type = mp->md_type;
-    a->next_protocol = mp->next_protocol;
-    a->spi_si = ntohl(mp->spi_si);
-    a->c1 = ntohl(mp->c1);
-    a->c2 = ntohl(mp->c2);
-    a->c3 = ntohl(mp->c3);
-    a->c4 = ntohl(mp->c4);
+    a->nsh_hdr.ver_o_c = mp->ver_o_c;
+    a->nsh_hdr.length = mp->length;
+    a->nsh_hdr.md_type = mp->md_type;
+    a->nsh_hdr.next_protocol = mp->next_protocol;
+    a->nsh_hdr.spi_si = ntohl(mp->spi_si);
+    a->nsh_hdr.c1 = ntohl(mp->c1);
+    a->nsh_hdr.c2 = ntohl(mp->c2);
+    a->nsh_hdr.c3 = ntohl(mp->c3);
+    a->nsh_hdr.c4 = ntohl(mp->c4);
 
     for (i = 0; i < mp->tlv_len_in_words; i++)
         vec_add1 (tlvs, ntohl(mp->tlvs[i]));
 
-    a->tlvs = tlvs;
+    a->nsh_hdr.tlvs = tlvs;
 
     rv = vnet_nsh_gre_add_del_tunnel (a, &sw_if_index);
     
@@ -4403,7 +4621,7 @@ vl_api_nsh_vxlan_gpe_add_del_tunnel_t_handler
     decap_next_index = ntohl(mp->decap_next_index);
 
     /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
-    if (decap_next_index == NSH_INPUT_NEXT_IP4_INPUT) {
+    if (decap_next_index == NSH_GRE_INPUT_NEXT_IP4_INPUT) {
         p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
         if (! p) {
             rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
@@ -4424,20 +4642,20 @@ vl_api_nsh_vxlan_gpe_add_del_tunnel_t_handler
     a->decap_fib_index = decap_fib_index;
     a->decap_next_index = decap_next_index;
     a->vni = ntohl(mp->vni);
-    a->ver_o_c = mp->ver_o_c;
-    a->length = mp->length;
-    a->md_type = mp->md_type;
-    a->next_protocol = mp->next_protocol;
-    a->spi_si = ntohl(mp->spi_si);
-    a->c1 = ntohl(mp->c1);
-    a->c2 = ntohl(mp->c2);
-    a->c3 = ntohl(mp->c3);
-    a->c4 = ntohl(mp->c4);
+    a->nsh_hdr.ver_o_c = mp->ver_o_c;
+    a->nsh_hdr.length = mp->length;
+    a->nsh_hdr.md_type = mp->md_type;
+    a->nsh_hdr.next_protocol = mp->next_protocol;
+    a->nsh_hdr.spi_si = ntohl(mp->spi_si);
+    a->nsh_hdr.c1 = ntohl(mp->c1);
+    a->nsh_hdr.c2 = ntohl(mp->c2);
+    a->nsh_hdr.c3 = ntohl(mp->c3);
+    a->nsh_hdr.c4 = ntohl(mp->c4);
 
     for (i = 0; i < mp->tlv_len_in_words; i++)
         vec_add1 (tlvs, ntohl(mp->tlvs[i]));
 
-    a->tlvs = tlvs;
+    a->nsh_hdr.tlvs = tlvs;
 
     rv = vnet_nsh_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
     
@@ -4448,64 +4666,6 @@ out:
     }));
 }
 
-static void
-vl_api_lisp_gpe_add_del_tunnel_t_handler 
-(vl_api_lisp_gpe_add_del_tunnel_t * mp)
-{
-    vl_api_lisp_gpe_add_del_tunnel_reply_t * rmp;
-    int rv = 0;
-    vnet_lisp_gpe_add_del_tunnel_args_t _a, *a = &_a;
-    u32 encap_fib_index, decap_fib_index;
-    u32 decap_next_index;
-    uword * p;
-    ip4_main_t * im = &ip4_main;
-    u32 sw_if_index = ~0;
-
-    p = hash_get (im->fib_index_by_table_id, ntohl(mp->encap_vrf_id));
-    if (! p) {
-        rv = VNET_API_ERROR_NO_SUCH_FIB;
-        goto out;
-    }
-    encap_fib_index = p[0];
-
-    decap_next_index = ntohl(mp->decap_next_index);
-
-    /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
-    if (decap_next_index == NSH_INPUT_NEXT_IP4_INPUT) {
-        p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
-        if (! p) {
-            rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
-            goto out;
-        }
-        decap_fib_index = p[0];
-    } else {
-        decap_fib_index = ntohl(mp->decap_vrf_id);
-    }
-
-    memset (a, 0, sizeof (*a));
-
-    a->is_add = mp->is_add;
-    /* ip addresses sent in network byte order */
-    a->src.as_u32 = mp->src;
-    a->dst.as_u32 = mp->dst;
-    a->encap_fib_index = encap_fib_index;
-    a->decap_fib_index = decap_fib_index;
-    a->decap_next_index = decap_next_index;
-    a->flags = mp->flags;
-    a->ver_res = mp->ver_res;
-    a->res = mp->res;
-    a->next_protocol = mp->next_protocol;
-    a->vni = clib_net_to_host_u32 (mp->iid);
-
-    rv = vnet_lisp_gpe_add_del_tunnel (a, &sw_if_index);
-    
-out:
-    REPLY_MACRO2(VL_API_LISP_GPE_ADD_DEL_TUNNEL_REPLY,
-    ({
-        rmp->sw_if_index = ntohl (sw_if_index);
-    }));
-}
-
 static void
 vl_api_lisp_add_del_locator_set_t_handler(vl_api_lisp_add_del_locator_set_t *mp)
 {
@@ -4666,7 +4826,6 @@ vl_api_lisp_gpe_add_del_fwd_entry_t_handler(
     vl_api_lisp_gpe_add_del_fwd_entry_reply_t *rmp;
     int rv = 0;
     ip_address_t slocator, dlocator;
-    ip_prefix_t * prefp = NULL;
     gid_address_t eid;
     vnet_lisp_gpe_add_del_fwd_entry_args_t a;
 
@@ -4678,9 +4837,6 @@ vl_api_lisp_gpe_add_del_fwd_entry_t_handler(
     a.deid = eid;
     a.slocator = slocator;
     a.dlocator = dlocator;
-    prefp = &gid_address_ippref(&a.deid);
-    a.decap_next_index = (ip_prefix_version(prefp) == IP4) ?
-    LISP_GPE_INPUT_NEXT_IP4_INPUT : LISP_GPE_INPUT_NEXT_IP6_INPUT;
     rv = vnet_lisp_gpe_add_del_fwd_entry (&a, 0);
 
     REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
@@ -4727,6 +4883,17 @@ vl_api_lisp_gpe_enable_disable_t_handler(
     REPLY_MACRO(VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
 }
 
+static void
+vl_api_lisp_enable_disable_t_handler(
+    vl_api_lisp_enable_disable_t *mp)
+{
+    vl_api_lisp_enable_disable_reply_t *rmp;
+    int rv = 0;
+
+    vnet_lisp_enable_disable (mp->is_en);
+    REPLY_MACRO(VL_API_LISP_ENABLE_DISABLE_REPLY);
+}
+
 static void
 vl_api_lisp_gpe_add_del_iface_t_handler(
     vl_api_lisp_gpe_add_del_iface_t *mp)
@@ -4743,25 +4910,57 @@ vl_api_lisp_gpe_add_del_iface_t_handler(
     REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
 }
 
+static void
+send_lisp_locator_set_details_set_address
+(vl_api_lisp_locator_set_details_t *rmp,
+ gid_address_t *gid_address)
+{
+    ip_prefix_t *ip_addr;
+
+    if (gid_address_type(gid_address) != GID_ADDR_IP_PREFIX) {
+        return;
+    }
+
+    ip_addr = &gid_address_ippref(gid_address);
+    rmp->prefix_len = ip_prefix_len(ip_addr);
+    rmp->is_ipv6 = ip_prefix_version(ip_addr);
+    ip_address_copy_addr(rmp->ip_address, &ip_prefix_addr(ip_addr));
+}
+
 static void
 send_lisp_locator_set_details (lisp_cp_main_t *lcm,
                                locator_set_t *lsit,
-                               unix_shared_memory_queue_t *q)
+                               unix_shared_memory_queue_t *q,
+                               u32 context,
+                               u32 index)
 {
     vl_api_lisp_locator_set_details_t *rmp;
     locator_t *loc = NULL;
     u32 * locit = NULL;
+    u8 * str = NULL;
 
     vec_foreach (locit, lsit->locator_indices) {
         loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
         rmp = vl_msg_api_alloc (sizeof (*rmp));
         memset (rmp, 0, sizeof (*rmp));
         rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCATOR_SET_DETAILS);
-        strncpy((char *) rmp->locator_set_name,
-                (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1);
-        rmp->sw_if_index = htonl(loc->sw_if_index);
+        rmp->local = lsit->local;
+        if (lsit->local) {
+            ASSERT(lsit->name != NULL);
+            strncpy((char *) rmp->locator_set_name,
+                    (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1);
+            rmp->sw_if_index = htonl(loc->sw_if_index);
+        } else {
+            str = format(0, "remote-%d", index);
+            strncpy((char *) rmp->locator_set_name, (char *) str,
+                    ARRAY_LEN(rmp->locator_set_name) - 1);
+            send_lisp_locator_set_details_set_address(rmp, &loc->address);
+
+            vec_free(str);
+        }
         rmp->priority = loc->priority;
         rmp->weight = loc->weight;
+        rmp->context = context;
 
         vl_msg_api_send_shmem (q, (u8 *)&rmp);
     }
@@ -4773,27 +4972,31 @@ vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t *mp)
     unix_shared_memory_queue_t * q = NULL;
     lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
     locator_set_t * lsit = NULL;
+    u32 index;
 
     q = vl_api_client_index_to_input_queue (mp->client_index);
     if (q == 0) {
         return;
     }
 
+    index = 0;
     pool_foreach (lsit, lcm->locator_set_pool,
         ({
-            send_lisp_locator_set_details(lcm, lsit, q);
+            send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
         }));
 }
 
 static void
 send_lisp_local_eid_table_details (mapping_t *mapit,
-                                   unix_shared_memory_queue_t *q)
+                                   unix_shared_memory_queue_t *q,
+                                   u32 context)
 {
     vl_api_lisp_local_eid_table_details_t *rmp = NULL;
     lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
     locator_set_t *ls = NULL;
     gid_address_t *gid = NULL;
     ip_prefix_t *ip_prefix = NULL;
+    u8 * str = NULL;
     u8 type = ~0;
 
     ls = pool_elt_at_index (lcm->locator_set_pool,
@@ -4811,8 +5014,16 @@ send_lisp_local_eid_table_details (mapping_t *mapit,
     rmp = vl_msg_api_alloc (sizeof (*rmp));
     memset (rmp, 0, sizeof (*rmp));
     rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCAL_EID_TABLE_DETAILS);
-    strncpy((char *) rmp->locator_set_name,
-            (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1);
+    if (ls->local) {
+        ASSERT(ls->name != NULL);
+        strncpy((char *) rmp->locator_set_name,
+                (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1);
+    } else {
+            str = format(0, "remote-%d", mapit->locator_set_index);
+            strncpy((char *) rmp->locator_set_name, (char *) str,
+                    ARRAY_LEN(rmp->locator_set_name) - 1);
+            vec_free(str);
+    }
 
     switch (ip_prefix_version(ip_prefix)) {
         case IP4:
@@ -4831,6 +5042,7 @@ send_lisp_local_eid_table_details (mapping_t *mapit,
             ASSERT(0);
     }
     rmp->eid_prefix_len = ip_prefix_len(ip_prefix);
+    rmp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&rmp);
 }
@@ -4850,13 +5062,14 @@ vl_api_lisp_local_eid_table_dump_t_handler (
 
     pool_foreach (mapit, lcm->mapping_pool,
         ({
-            send_lisp_local_eid_table_details(mapit, q);
+            send_lisp_local_eid_table_details(mapit, q, mp->context);
         }));
 }
 
 static void
 send_lisp_gpe_tunnel_details (lisp_gpe_tunnel_t *tunnel,
-                              unix_shared_memory_queue_t *q)
+                              unix_shared_memory_queue_t *q,
+                              u32 context)
 {
     vl_api_lisp_gpe_tunnel_details_t *rmp;
     lisp_gpe_main_t * lgm = &lisp_gpe_main;
@@ -4880,6 +5093,7 @@ send_lisp_gpe_tunnel_details (lisp_gpe_tunnel_t *tunnel,
     rmp->ver_res = tunnel->ver_res;
     rmp->res = tunnel->res;
     rmp->iid = htonl(tunnel->vni);
+    rmp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&rmp);
 }
@@ -4903,13 +5117,14 @@ vl_api_lisp_gpe_tunnel_dump_t_handler (
 
     pool_foreach(tunnel, lgm->tunnels,
                  ({
-                     send_lisp_gpe_tunnel_details(tunnel, q);
+                     send_lisp_gpe_tunnel_details(tunnel, q, mp->context);
                 }));
 }
 
 static void
 send_lisp_map_resolver_details (ip_address_t *ip,
-                                unix_shared_memory_queue_t *q)
+                                unix_shared_memory_queue_t *q,
+                                u32 context)
 {
     vl_api_lisp_map_resolver_details_t *rmp = NULL;
 
@@ -4931,6 +5146,7 @@ send_lisp_map_resolver_details (ip_address_t *ip,
         default:
             ASSERT(0);
     }
+    rmp->context = context;
 
     vl_msg_api_send_shmem (q, (u8 *)&rmp);
 }
@@ -4949,9 +5165,40 @@ vl_api_lisp_map_resolver_dump_t_handler (
     }
 
     vec_foreach(ip, lcm->map_resolvers) {
-        send_lisp_map_resolver_details(ip, q);
+        send_lisp_map_resolver_details(ip, q, mp->context);
+    }
+
+}
+
+static void
+send_lisp_enable_disable_details (unix_shared_memory_queue_t *q,
+                                      u32 context)
+{
+    vl_api_lisp_enable_disable_status_details_t *rmp = NULL;
+
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_LISP_ENABLE_DISABLE_STATUS_DETAILS);
+
+    rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
+    rmp->feature_status = vnet_lisp_enable_disable_status ();
+    rmp->context = context;
+
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void
+vl_api_lisp_enable_disable_status_dump_t_handler
+(vl_api_lisp_enable_disable_status_dump_t *mp)
+{
+    unix_shared_memory_queue_t * q = NULL;
+
+    q = vl_api_client_index_to_input_queue (mp->client_index);
+    if (q == 0) {
+        return;
     }
 
+    send_lisp_enable_disable_details(q, mp->context);
 }
 
 static void 
@@ -5669,6 +5916,44 @@ static void vl_api_trace_profile_del_t_handler
     REPLY_MACRO(VL_API_TRACE_PROFILE_DEL_REPLY);
 }
 
+static void
+vl_api_af_packet_create_t_handler
+(vl_api_af_packet_create_t *mp)
+{
+    vlib_main_t *vm = vlib_get_main();
+    vl_api_af_packet_create_reply_t *rmp;
+    int rv = 0;
+    u8 *host_if_name = NULL;
+
+    host_if_name = format(0, "%s", mp->host_if_name);
+    vec_add1 (host_if_name, 0);
+
+    rv = af_packet_create_if(vm, host_if_name,
+                             mp->use_random_hw_addr ? 0 : mp->hw_addr);
+
+    vec_free(host_if_name);
+
+    REPLY_MACRO(VL_API_AF_PACKET_CREATE_REPLY);
+}
+
+static void
+vl_api_af_packet_delete_t_handler
+(vl_api_af_packet_delete_t *mp)
+{
+    vlib_main_t * vm = vlib_get_main();
+    vl_api_af_packet_delete_reply_t *rmp;
+    int rv = 0;
+    u8 *host_if_name = NULL;
+
+    host_if_name = format(0, "%s", mp->host_if_name);
+    vec_add1 (host_if_name, 0);
+
+    rv = af_packet_delete_if(vm, host_if_name);
+
+    vec_free(host_if_name);
+
+    REPLY_MACRO(VL_API_AF_PACKET_DELETE_REPLY);
+}
 
 #define BOUNCE_HANDLER(nn)                                              \
 static void vl_api_##nn##_t_handler (                                   \
@@ -5735,6 +6020,19 @@ vpe_api_hookup (vlib_main_t *vm)
                              vl_api_sr_tunnel_add_del_t_print,
                              256, 1);
 
+
+    /* 
+     * Manually register the sr policy add del msg, so we trace
+     * enough bytes to capture a typical tunnel name list
+     */
+    vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD_DEL, 
+                             "sr_policy_add_del",
+                             vl_api_sr_policy_add_del_t_handler,
+                             vl_noop_handler,
+                             vl_api_sr_policy_add_del_t_endian,
+                             vl_api_sr_policy_add_del_t_print,
+                             256, 1);
+
     /* 
      * Trace space for 8 MPLS encap labels, classifier mask+match
      */