X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fpg%2Fcli.c;h=9336ca406d72e0ac751d342c424aff3ac332aa1a;hb=e5d34919b4561a5ee11e41dec6b0184537b39696;hp=a8451d74e1e6c2f2c7dc7cf1ae1835b090b869f0;hpb=22e9cfd760be613f33a4135e9247729b64619cc6;p=vpp.git diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c index a8451d74e1e..9336ca406d7 100644 --- a/src/vnet/pg/cli.c +++ b/src/vnet/pg/cli.c @@ -86,14 +86,17 @@ pg_capture (pg_capture_args_t * a) if (a->is_enabled == 1) { struct stat sb; - if (stat ((char *) a->pcap_file_name, &sb) != -1) - return clib_error_return (0, "pcap file '%s' does not exist.", + if (stat (a->pcap_file_name, &sb) != -1) + return clib_error_return (0, "pcap file '%s' already exists.", a->pcap_file_name); } pi = pool_elt_at_index (pg->interfaces, a->dev_instance); vec_free (pi->pcap_file_name); + if ((pi->pcap_main.flags & PCAP_MAIN_INIT_DONE)) + pcap_close (&pi->pcap_main); clib_memset (&pi->pcap_main, 0, sizeof (pi->pcap_main)); + pi->pcap_main.file_descriptor = -1; if (a->is_enabled == 0) return 0; @@ -336,7 +339,7 @@ new_stream (vlib_main_t * vm, { clib_error_t *error = 0; u8 *tmp = 0; - u32 hw_if_index; + u32 maxframe, hw_if_index; unformat_input_t sub_input = { 0 }; int sub_input_given = 0; vnet_main_t *vnm = vnet_get_main (); @@ -349,7 +352,9 @@ new_stream (vlib_main_t * vm, s.max_packet_bytes = s.min_packet_bytes = 64; s.buffer_bytes = vlib_buffer_get_default_data_size (vm); s.if_id = 0; + s.n_max_frame = VLIB_FRAME_SIZE; pcap_file_name = 0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "name %v", &tmp)) @@ -374,7 +379,8 @@ new_stream (vlib_main_t * vm, else if (unformat (input, "node %U", unformat_vlib_node, vm, &s.node_index)) ; - + else if (unformat (input, "maxframe %u", &maxframe)) + s.n_max_frame = s.n_max_frame < maxframe ? s.n_max_frame : maxframe; else if (unformat (input, "worker %u", &s.worker_index)) ; @@ -485,7 +491,9 @@ VLIB_CLI_COMMAND (new_stream_cli, static) = { "interface STRING interface for stream output \n" "node NODE-NAME node for stream output\n" "data STRING specifies packet data\n" - "pcap FILENAME read packet data from pcap file\n", + "pcap FILENAME read packet data from pcap file\n" + "rate PPS rate to transfer packet data\n" + "maxframe NPKTS maximum number of packets per frame\n", }; /* *INDENT-ON* */ @@ -624,7 +632,7 @@ pg_capture_cmd_fn (vlib_main_t * vm, a->hw_if_index = hw_if_index; a->dev_instance = hi->dev_instance; a->is_enabled = !is_disable; - a->pcap_file_name = pcap_file_name; + a->pcap_file_name = (char *) pcap_file_name; a->count = count; error = pg_capture (a);