* [dpdk-dev] [PATCH] examples/ip_pipeline: fix pcap file parsing
@ 2016-04-01 9:55 Fan Zhang
2016-04-01 20:55 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Fan Zhang @ 2016-04-01 9:55 UTC (permalink / raw)
To: dev
Fixes: fe5d046 ("examples/ip_pipeline: add pcap file dump")
This patch fixes the pcap file parsing in ip_pipeline. Originally, the
parser recognizes the pcap related entries regardless of the RTE_PORT_PCAP
macro definition status.
Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
examples/ip_pipeline/config_parse.c | 90 ++++++++++++++++++++++++++++++-------
1 file changed, 74 insertions(+), 16 deletions(-)
diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c
index 152889d..e83f1d6 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -989,11 +989,6 @@ parse_pipeline_pcap_source(struct app_params *app,
if (p->n_pktq_in == 0)
return -EINVAL;
- for (i = 0; i < p->n_pktq_in; i++) {
- if (p->pktq_in[i].type != APP_PKTQ_IN_SOURCE)
- return -EINVAL;
- }
-
i = 0;
while (*next != '\0') {
uint32_t id;
@@ -1068,11 +1063,6 @@ parse_pipeline_pcap_sink(struct app_params *app,
if (p->n_pktq_out == 0)
return -EINVAL;
- for (i = 0; i < p->n_pktq_out; i++) {
- if (p->pktq_out[i].type != APP_PKTQ_OUT_SINK)
- return -EINVAL;
- }
-
i = 0;
while (*next != '\0') {
uint32_t id;
@@ -1478,7 +1468,13 @@ parse_pipeline(struct app_params *app,
}
if (strcmp(ent->name, "pcap_file_rd") == 0) {
- int status = parse_pipeline_pcap_source(app,
+ int status;
+
+#ifndef RTE_PORT_PCAP
+ PARSE_ERROR_INVALID(0, section_name, ent->name);
+#endif
+
+ status = parse_pipeline_pcap_source(app,
param, ent->value, NULL);
PARSE_ERROR((status == 0), section_name,
@@ -1487,7 +1483,13 @@ parse_pipeline(struct app_params *app,
}
if (strcmp(ent->name, "pcap_bytes_rd_per_pkt") == 0) {
- int status = parse_pipeline_pcap_source(app,
+ int status;
+
+#ifndef RTE_PORT_PCAP
+ PARSE_ERROR_INVALID(0, section_name, ent->name);
+#endif
+
+ status = parse_pipeline_pcap_source(app,
param, NULL, ent->value);
PARSE_ERROR((status == 0), section_name,
@@ -1496,7 +1498,13 @@ parse_pipeline(struct app_params *app,
}
if (strcmp(ent->name, "pcap_file_wr") == 0) {
- int status = parse_pipeline_pcap_sink(app, param,
+ int status;
+
+#ifndef RTE_PORT_PCAP
+ PARSE_ERROR_INVALID(0, section_name, ent->name);
+#endif
+
+ status = parse_pipeline_pcap_sink(app, param,
ent->value, NULL);
PARSE_ERROR((status == 0), section_name,
@@ -1505,7 +1513,13 @@ parse_pipeline(struct app_params *app,
}
if (strcmp(ent->name, "pcap_n_pkt_wr") == 0) {
- int status = parse_pipeline_pcap_sink(app, param,
+ int status;
+
+#ifndef RTE_PORT_PCAP
+ PARSE_ERROR_INVALID(0, section_name, ent->name);
+#endif
+
+ status = parse_pipeline_pcap_sink(app, param,
NULL, ent->value);
PARSE_ERROR((status == 0), section_name,
@@ -2163,6 +2177,8 @@ parse_source(struct app_params *app,
struct rte_cfgfile_entry *entries;
int n_entries, i;
ssize_t param_idx;
+ uint32_t pcap_file_present = 0;
+ uint32_t pcap_size_present = 0;
n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
@@ -2205,18 +2221,31 @@ parse_source(struct app_params *app,
}
if (strcmp(ent->name, "pcap_file_rd")) {
+ PARSE_ERROR_DUPLICATE((pcap_file_present == 0),
+ section_name, ent->name);
+
param->file_name = strdup(ent->value);
PARSE_ERROR_MALLOC(param->file_name != NULL);
+ pcap_file_present = 1;
+
continue;
}
if (strcmp(ent->name, "pcap_bytes_rd_per_pkt") == 0) {
- int status = parser_read_uint32(
+ int status;
+
+ PARSE_ERROR_DUPLICATE((pcap_size_present == 0),
+ section_name, ent->name);
+
+ status = parser_read_uint32(
¶m->n_bytes_per_pkt, ent->value);
PARSE_ERROR((status == 0), section_name,
ent->name);
+ pcap_size_present = 1;
+
+ continue;
}
/* unrecognized */
@@ -2237,6 +2266,8 @@ parse_sink(struct app_params *app,
struct rte_cfgfile_entry *entries;
int n_entries, i;
ssize_t param_idx;
+ uint32_t pcap_file_present = 0;
+ uint32_t pcap_n_pkt_present = 0;
n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
@@ -2255,18 +2286,28 @@ parse_sink(struct app_params *app,
struct rte_cfgfile_entry *ent = &entries[i];
if (strcmp(ent->name, "pcap_file_wr")) {
+ PARSE_ERROR_DUPLICATE((pcap_file_present == 0),
+ section_name, ent->name);
+
param->file_name = strdup(ent->value);
PARSE_ERROR_MALLOC((param->file_name != NULL));
+
continue;
}
if (strcmp(ent->name, "pcap_n_pkt_wr")) {
- int status = parser_read_uint32(
+ int status;
+
+ PARSE_ERROR_DUPLICATE((pcap_n_pkt_present == 0),
+ section_name, ent->name);
+
+ status = parser_read_uint32(
¶m->n_pkts_to_dump, ent->value);
PARSE_ERROR((status == 0), section_name,
ent->name);
+
continue;
}
@@ -2580,6 +2621,23 @@ app_config_parse(struct app_params *app, const char *file_name)
APP_PARAM_COUNT(app->msgq_params, app->n_msgq);
APP_PARAM_COUNT(app->pipeline_params, app->n_pipelines);
+#ifdef RTE_PORT_PCAP
+ for (i = 0; i < (int)app->n_pktq_source; i++) {
+ struct app_pktq_source_params *p = &app->source_params[i];
+
+ APP_CHECK((p->file_name), "Parse error: missing "
+ "mandatory field \"pcap_file_rd\" for \"%s\"",
+ p->name);
+ }
+#else
+ for (i = 0; i < (int)app->n_pktq_source; i++) {
+ struct app_pktq_source_params *p = &app->source_params[i];
+
+ APP_CHECK((!p->file_name), "Parse error: invalid field "
+ "\"pcap_file_rd\" for \"%s\"", p->name);
+ }
+#endif
+
if (app->port_mask == 0)
assign_link_pmd_id_from_pci_bdf(app);
--
2.5.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-01 20:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 9:55 [dpdk-dev] [PATCH] examples/ip_pipeline: fix pcap file parsing Fan Zhang
2016-04-01 20:55 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).