#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__
_(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) \
_(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_GPE_ENABLE_DISABLE_STATUS_DUMP, \
- lisp_gpe_enable_disable_status_dump) \
-_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del)
+_(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)
goto out;
}
- if (!(mp->tunnel_names))
+ if (!(mp->tunnel_names[0]))
{
rv = VNET_API_ERROR_NO_SUCH_NODE2;
goto 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_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;
- 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)
{
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;
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);
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)
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,
- u32 context)
+ 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;
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, mp->context);
+ send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
}));
}
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,
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:
}
static void
-send_lisp_gpe_enable_disable_details (unix_shared_memory_queue_t *q,
+send_lisp_enable_disable_details (unix_shared_memory_queue_t *q,
u32 context)
{
- vl_api_lisp_gpe_enable_disable_status_details_t *rmp = NULL;
- u8 is_en;
+ 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_GPE_ENABLE_DISABLE_STATUS_DETAILS);
+ rmp->_vl_msg_id = ntohs(VL_API_LISP_ENABLE_DISABLE_STATUS_DETAILS);
- is_en = vnet_lisp_gpe_enable_disable_status();
- rmp->is_en = is_en;
+ 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_gpe_enable_disable_status_dump_t_handler
-(vl_api_lisp_gpe_enable_disable_status_dump_t *mp)
+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;
return;
}
- send_lisp_gpe_enable_disable_details(q, mp->context);
+ send_lisp_enable_disable_details(q, mp->context);
}
static void
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 ( \