L2TP: Add option for custom fib id for outgoing encapsulated packets
[vpp.git] / vpp / vpp-api / api.c
index 4d4c71c..6a5a152 100644 (file)
@@ -368,7 +368,8 @@ _(CLASSIFY_TABLE_INFO,classify_table_info)                              \
 _(CLASSIFY_SESSION_DUMP,classify_session_dump)                          \
 _(CLASSIFY_SESSION_DETAILS,classify_session_details)                    \
 _(IPFIX_ENABLE,ipfix_enable)                                            \
-_(IPFIX_DUMP,ipfix_dump)
+_(IPFIX_DUMP,ipfix_dump)                                                \
+_(GET_NEXT_INDEX, get_next_index)
 
 #define QUOTE_(x) #x
 #define QUOTE(x) QUOTE_(x)
@@ -4243,6 +4244,48 @@ static void vl_api_get_node_index_t_handler
     }))
 }
 
+static void vl_api_get_next_index_t_handler
+(vl_api_get_next_index_t * mp)
+{
+    vlib_main_t * vm = vlib_get_main();
+    vl_api_get_next_index_reply_t * rmp;
+    vlib_node_t * node, * next_node;
+    int rv = 0;
+    u32 next_node_index = ~0, next_index = ~0;
+    uword * p;
+
+    node = vlib_get_node_by_name (vm, mp->node_name);
+
+    if (node == 0) {
+        rv = VNET_API_ERROR_NO_SUCH_NODE;
+        goto out;
+    }
+
+    next_node = vlib_get_node_by_name (vm, mp->next_name);
+
+    if (next_node == 0) {
+        rv = VNET_API_ERROR_NO_SUCH_NODE2;
+        goto out;
+    }
+    else
+        next_node_index = next_node->index;
+
+    p = hash_get (node->next_slot_by_node, next_node_index);
+
+    if (p == 0) {
+        rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+        goto out;
+    }
+    else
+        next_index = p[0];
+
+ out:
+    REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
+    ({
+        rmp->next_index = ntohl(next_index);
+    }));
+}
+
 static void vl_api_add_node_next_t_handler
 (vl_api_add_node_next_t * mp)
 {
@@ -4286,6 +4329,20 @@ static void vl_api_l2tpv3_create_tunnel_t_handler
         goto out;
     }
 
+    u32 encap_fib_index;
+
+    if (mp->encap_vrf_id != ~0) {
+        uword *p;
+        ip6_main_t *im = &ip6_main;
+        if (!(p = hash_get (im->fib_index_by_table_id, ntohl(mp->encap_vrf_id)))) {
+            rv = VNET_API_ERROR_NO_SUCH_FIB;
+            goto out;
+        }
+        encap_fib_index = p[0];
+    } else {
+        encap_fib_index = ~0;
+    }
+
     rv = create_l2tpv3_ipv6_tunnel (lm,
                                (ip6_address_t *) mp->client_address,
                                (ip6_address_t *) mp->our_address,
@@ -4294,6 +4351,7 @@ static void vl_api_l2tpv3_create_tunnel_t_handler
                                clib_net_to_host_u64(mp->local_cookie),
                                clib_net_to_host_u64(mp->remote_cookie),
                                mp->l2_sublayer_present,
+                               encap_fib_index,
                                &sw_if_index);
 
 out:
@@ -5453,6 +5511,23 @@ vl_api_lisp_map_resolver_dump_t_handler (
 
 }
 
+static void
+send_eid_table_map_pair (hash_pair_t * p,
+                         unix_shared_memory_queue_t * q,
+                         u32 context)
+{
+    vl_api_lisp_eid_table_map_details_t * rmp = NULL;
+
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS);
+
+    rmp->vni = clib_host_to_net_u32 (p->key);
+    rmp->vrf = clib_host_to_net_u32 (p->value[0]);
+    rmp->context = context;
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
 static void
 vl_api_lisp_eid_table_map_dump_t_handler (
     vl_api_lisp_eid_table_map_dump_t *mp)
@@ -5466,12 +5541,7 @@ vl_api_lisp_eid_table_map_dump_t_handler (
         return;
     }
     hash_foreach_pair (p, lcm->table_id_by_vni, {
-        vl_api_lisp_eid_table_map_details_t * rmp = NULL;
-        memset (rmp, 0, sizeof (*rmp));
-        rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS);
-        rmp->vni = p->key;
-        rmp->vrf = p->value[0];
-        rmp->context = mp->context;
+        send_eid_table_map_pair (p, q, mp->context);
     });
 }
 
@@ -6328,6 +6398,12 @@ vl_api_policer_add_del_t_handler
     cfg.rb.kbps.eir_kbps = mp->eir;
     cfg.rb.kbps.cb_bytes = mp->cb;
     cfg.rb.kbps.eb_bytes = mp->eb;
+    cfg.conform_action.action_type = mp->conform_action_type;
+    cfg.conform_action.dscp = mp->conform_dscp;
+    cfg.exceed_action.action_type = mp->exceed_action_type;
+    cfg.exceed_action.dscp = mp->exceed_dscp;
+    cfg.violate_action.action_type = mp->violate_action_type;
+    cfg.violate_action.dscp = mp->violate_dscp;
 
     error = policer_add_del(vm, name, &cfg, mp->is_add);
 
@@ -6357,6 +6433,12 @@ send_policer_details (u8 *name,
     mp->rate_type = config->rate_type;
     mp->round_type = config->rnd_type;
     mp->type = config->rfc;
+    mp->conform_action_type = config->conform_action.action_type;
+    mp->conform_dscp = config->conform_action.dscp;
+    mp->exceed_action_type = config->exceed_action.action_type;
+    mp->exceed_dscp = config->exceed_action.dscp;
+    mp->violate_action_type = config->violate_action.action_type;
+    mp->violate_dscp = config->violate_action.dscp;
     mp->single_rate = templ->single_rate ? 1 : 0;
     mp->color_aware = templ->color_aware ? 1 : 0;
     mp->scale = htonl(templ->scale);
@@ -7009,8 +7091,8 @@ static void vl_api_ipfix_enable_t_handler (vl_api_ipfix_enable_t *mp)
     collector_port = ntohs(mp->collector_port);
     if (collector_port == (u16)~0)
         collector_port = UDP_DST_PORT_ipfix;
-       memcpy(src.data, mp->src_address, sizeof(src.data));
-       fib_id = ntohl(mp->vrf_id);
+    memcpy(src.data, mp->src_address, sizeof(src.data));
+    fib_id = ntohl(mp->vrf_id);
 
     ip4_main_t * im = &ip4_main;
     uword * p = hash_get (im->fib_index_by_table_id, fib_id);