X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ffib%2Ffib_api.c;h=12c4f0de13fe9935cc938ff383abffc5a5f184ab;hb=8feeaff56fa9a4fbdfc06131f28a1060ffd9645d;hp=a2f7e79b03c31cdf23ec495493b9daa3d885b3f4;hpb=8145842bf273823192140c57fc773bb92d9db64f;p=vpp.git diff --git a/src/vnet/fib/fib_api.c b/src/vnet/fib/fib_api.c index a2f7e79b03c..12c4f0de13f 100644 --- a/src/vnet/fib/fib_api.c +++ b/src/vnet/fib/fib_api.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -49,18 +50,28 @@ fib_path_api_parse (const vl_api_fib_path_t *in, path_flags = FIB_ROUTE_PATH_FLAG_NONE; next_hop_via_label = ntohl (in->via_label); - memset(out, 0, sizeof(*out)); + clib_memset(out, 0, sizeof(*out)); out->frp_sw_if_index = ~0; out->frp_proto = in->afi; // .frp_addr = (NULL == next_hop ? zero_addr : *next_hop), out->frp_sw_if_index = ntohl(in->sw_if_index); - out->frp_fib_index = ntohl(in->table_id); out->frp_weight = in->weight; out->frp_preference = in->preference; + if (DPO_PROTO_IP4 == out->frp_proto || + DPO_PROTO_IP6 == out->frp_proto || + DPO_PROTO_MPLS == out->frp_proto) + { + out->frp_fib_index = fib_table_find (dpo_proto_to_fib(out->frp_proto), + ntohl (in->table_id)); + + if (~0 == out->frp_fib_index) + return (VNET_API_ERROR_NO_SUCH_FIB); + } + /* - * the special INVALID label meams we are not recursing via a + * the special INVALID label means we are not recursing via a * label. Exp-null value is never a valid via-label so that * also means it's not a via-label and means clients that set * it to 0 by default get the expected behaviour @@ -207,7 +218,9 @@ void fib_api_path_encode (const fib_route_path_encode_t * api_rpath, vl_api_fib_path_t *out) { - memset (out, 0, sizeof (*out)); + int ii; + + clib_memset (out, 0, sizeof (*out)); switch (api_rpath->dpo.dpoi_type) { case DPO_RECEIVE: @@ -217,7 +230,7 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath, out->is_drop = true; break; case DPO_IP_NULL: - switch (api_rpath->dpo.dpoi_index) + switch (ip_null_dpo_get_action(api_rpath->dpo.dpoi_index)) { case IP_NULL_ACTION_NONE: out->is_drop = true; @@ -241,18 +254,25 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath, out->afi = api_rpath->rpath.frp_proto; fib_api_path_copy_next_hop (api_rpath, out); - if (~0 == api_rpath->rpath.frp_sw_if_index && - !ip46_address_is_zero(&api_rpath->rpath.frp_addr)) + if (0 != api_rpath->rpath.frp_fib_index) { if ((DPO_PROTO_IP6 == api_rpath->rpath.frp_proto) || - (DPO_PROTO_IP6 == api_rpath->rpath.frp_proto)) + (DPO_PROTO_IP4 == api_rpath->rpath.frp_proto)) { - fib_table_t *fib; - - fib = fib_table_get (api_rpath->rpath.frp_fib_index, - dpo_proto_to_fib(api_rpath->rpath.frp_proto)); - - out->table_id = htonl (fib->ft_table_id); + if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_RPF_ID) + { + out->table_id = + htonl(mfib_table_get_table_id( + api_rpath->rpath.frp_fib_index, + dpo_proto_to_fib(api_rpath->rpath.frp_proto))); + } + else + { + out->table_id = + htonl(fib_table_get_table_id( + api_rpath->rpath.frp_fib_index, + dpo_proto_to_fib(api_rpath->rpath.frp_proto))); + } } } @@ -265,4 +285,71 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath, out->is_udp_encap = 1; out->next_hop_id = api_rpath->rpath.frp_udp_encap_id; } + if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_INTF_RX) + { + out->is_interface_rx = 1; + } + if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_LOCAL) + { + out->is_local = 1; + } + if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_RESOLVE_VIA_HOST) + { + out->is_resolve_host = 1; + } + if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED) + { + out->is_resolve_attached = 1; + } + /* if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_ATTACHED) { */ + /* out->is_attached = 1; */ + /* } */ + /* if (api_rpath->rpath.frp_flags & FIB_ROUTE_PATH_CONNECTED) { */ + /* out->is_connected = 1; */ + /* } */ + if (api_rpath->rpath.frp_label_stack) + { + for (ii = 0; ii < vec_len(api_rpath->rpath.frp_label_stack); ii++) + { + out->label_stack[ii].label = + htonl(api_rpath->rpath.frp_label_stack[ii].fml_value); + out->label_stack[ii].ttl = + api_rpath->rpath.frp_label_stack[ii].fml_ttl; + out->label_stack[ii].exp = + api_rpath->rpath.frp_label_stack[ii].fml_exp; + } + out->n_labels = ii; + } +} + +fib_protocol_t +fib_proto_from_api_address_family (int af) +{ + switch (clib_net_to_host_u32 (af)) + { + case ADDRESS_IP4: + return (FIB_PROTOCOL_IP4); + case ADDRESS_IP6: + return (FIB_PROTOCOL_IP6); + } + + ASSERT(0); + return (FIB_PROTOCOL_IP4); +} + +int +fib_proto_to_api_address_family (fib_protocol_t fproto) +{ + switch (fproto) + { + case FIB_PROTOCOL_IP4: + return (clib_net_to_host_u32 (ADDRESS_IP4)); + case FIB_PROTOCOL_IP6: + return (clib_net_to_host_u32 (ADDRESS_IP6)); + default: + break; + } + + ASSERT(0); + return (clib_net_to_host_u32 (ADDRESS_IP4)); }