X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Flisp-gpe%2Flisp_gpe.c;h=c7b3d887cfa80187d27d72e19c4d7db447820386;hb=1553197f9a1a3258b6954adeb9536bbe0191683d;hp=ea6c143d917ec83ca651039f6a29ccbc67e4d5f8;hpb=a4e63e5593d53692b8085dc666f8670ece135f32;p=vpp.git diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c index ea6c143d917..c7b3d887cfa 100644 --- a/src/vnet/lisp-gpe/lisp_gpe.c +++ b/src/vnet/lisp-gpe/lisp_gpe.c @@ -91,8 +91,8 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm, unformat_ip_address, &lloc, unformat_ip_address, &rloc, &w)) { - pair.lcl_loc = lloc; - pair.rmt_loc = rloc; + ip_address_copy (&pair.lcl_loc, &lloc); + ip_address_copy (&pair.rmt_loc, &rloc); pair.weight = w; pair.priority = 0; vec_add1 (pairs, pair); @@ -321,7 +321,7 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm, /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) - return 0; + return clib_error_return (0, "expected enable | disable"); while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -404,8 +404,9 @@ gpe_show_native_fwd_rpath_command_fn (vlib_main_t * vm, vec_foreach (rpath, lgm->native_fwd_rpath[IP4]) { vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u", - format_ip46_address, &rpath->frp_addr, 1, - rpath->frp_fib_index, rpath->frp_sw_if_index); + format_ip46_address, &rpath->frp_addr, + IP46_TYPE_IP4, rpath->frp_fib_index, + rpath->frp_sw_if_index); } } if (vec_len (lgm->native_fwd_rpath[IP6])) @@ -413,7 +414,7 @@ gpe_show_native_fwd_rpath_command_fn (vlib_main_t * vm, vec_foreach (rpath, lgm->native_fwd_rpath[IP6]) { vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u", - format_ip46_address, &rpath->frp_addr, 1, + format_ip46_address, &rpath->frp_addr, IP46_TYPE_IP6, rpath->frp_fib_index, rpath->frp_sw_if_index); } } @@ -453,7 +454,7 @@ vnet_gpe_add_del_native_fwd_rpath (vnet_gpe_native_fwd_rpath_args_t * a) fib_route_path_t *rpath; u8 ip_version; - ip_version = a->rpath.frp_proto == FIB_PROTOCOL_IP4 ? IP4 : IP6; + ip_version = a->rpath.frp_proto == DPO_PROTO_IP4 ? IP4 : IP6; if (a->is_add) { @@ -510,7 +511,7 @@ gpe_native_forward_command_fn (vlib_main_t * vm, unformat_input_t * input, &rpath.frp_sw_if_index)) { rpath.frp_weight = 1; - rpath.frp_proto = FIB_PROTOCOL_IP4; + rpath.frp_proto = DPO_PROTO_IP4; } else if (unformat (line_input, "via %U %U", unformat_ip6_address, @@ -519,21 +520,21 @@ gpe_native_forward_command_fn (vlib_main_t * vm, unformat_input_t * input, &rpath.frp_sw_if_index)) { rpath.frp_weight = 1; - rpath.frp_proto = FIB_PROTOCOL_IP6; + rpath.frp_proto = DPO_PROTO_IP6; } else if (unformat (line_input, "via %U", unformat_ip4_address, &rpath.frp_addr.ip4)) { rpath.frp_weight = 1; rpath.frp_sw_if_index = ~0; - rpath.frp_proto = FIB_PROTOCOL_IP4; + rpath.frp_proto = DPO_PROTO_IP4; } else if (unformat (line_input, "via %U", unformat_ip6_address, &rpath.frp_addr.ip6)) { rpath.frp_weight = 1; rpath.frp_sw_if_index = ~0; - rpath.frp_proto = FIB_PROTOCOL_IP6; + rpath.frp_proto = DPO_PROTO_IP6; } else { @@ -548,7 +549,8 @@ gpe_native_forward_command_fn (vlib_main_t * vm, unformat_input_t * input, } else { - rpath.frp_fib_index = fib_table_find (rpath.frp_proto, table_id); + rpath.frp_fib_index = + fib_table_find (dpo_proto_to_fib (rpath.frp_proto), table_id); if ((u32) ~ 0 == rpath.frp_fib_index) { error = clib_error_return (0, "Nonexistent table id %d", table_id); @@ -630,6 +632,89 @@ vnet_gpe_get_encap_mode (void) return lgm->encap_mode; } +static clib_error_t * +lisp_gpe_test_send_nsh_packet (u8 * file_name) +{ + vlib_frame_t *f; + vlib_buffer_t *b; + lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main (); + pcap_main_t pm; + clib_error_t *error = 0; + + if (!file_name) + return clib_error_create ("no pcap file specified!"); + + memset (&pm, 0, sizeof (pm)); + pm.file_name = (char *) file_name; + error = pcap_read (&pm); + if (error) + return error; + + u32 bi; + if (vlib_buffer_alloc (lgm->vlib_main, &bi, 1) != 1) + return clib_error_create ("cannot allocate memory!"); + + b = vlib_get_buffer (lgm->vlib_main, bi); + tunnel_lookup_t *nsh_ifaces = &lgm->nsh_ifaces; + uword *hip; + vnet_hw_interface_t *hi; + + hip = hash_get (nsh_ifaces->hw_if_index_by_dp_table, 0); + if (hip == 0) + return clib_error_create ("The NSH 0 interface doesn't exist"); + + hi = vnet_get_hw_interface (lgm->vnet_main, hip[0]); + + vnet_buffer (b)->sw_if_index[VLIB_TX] = hi->sw_if_index; + u8 *p = vlib_buffer_put_uninit (b, vec_len (pm.packets_read[0])); + clib_memcpy (p, pm.packets_read[0], vec_len (pm.packets_read[0])); + vlib_buffer_pull (b, sizeof (ethernet_header_t)); + + vlib_node_t *n = vlib_get_node_by_name (lgm->vlib_main, + (u8 *) "interface-tx"); + f = vlib_get_frame_to_node (lgm->vlib_main, n->index); + u32 *to_next = vlib_frame_vector_args (f); + to_next[0] = bi; + f->n_vectors = 1; + vlib_put_frame_to_node (lgm->vlib_main, n->index, f); + + return error; +} + +static clib_error_t * +lisp_test_nsh_command_fn (vlib_main_t * vm, unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + clib_error_t *error = 0; + u8 *file_name = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "pcap %v", &file_name)) + { + error = lisp_gpe_test_send_nsh_packet (file_name); + goto done; + } + else + { + error = clib_error_create ("unknown input `%U'", + format_unformat_error, input); + goto done; + } + } + +done: + return error; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (lisp_test_nsh_command, static) = { + .path = "test one nsh", + .short_help = "test gpe nsh pcap ", + .function = lisp_test_nsh_command_fn, +}; +/* *INDENT-ON* */ + VLIB_INIT_FUNCTION (lisp_gpe_init); /*