diff options
author | Matias Elo <matias.elo@nokia.com> | 2015-10-23 16:01:27 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-10-26 15:07:09 +0300 |
commit | 78872639460a3f454fa69a72f7ea5ab4c547a2b8 (patch) | |
tree | 86a9184263bc36c6c5548af4375e5eb21d70fa20 /test/performance | |
parent | 0456486d3f56adf84a0eecfc6ff9197042b75221 (diff) |
test: l2fwd: add option to disable filling eth addresses
By default every packet's source MAC address is filled to
match the output port. Add option to disable this to enable
testing packet forwarding without touching the packets.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test/performance')
-rw-r--r-- | test/performance/odp_l2fwd.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 1385291c0..fb5f6569e 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -70,6 +70,7 @@ typedef struct { int accuracy; /**< Number of seconds to get and print statistics */ char *if_str; /**< Storage for interface names */ int dst_change; /**< Change destination eth addresses > */ + int src_change; /**< Change source eth addresses > */ } appl_args_t; static int exit_threads; /**< Break workers loop if set to 1 */ @@ -626,11 +627,16 @@ static void fill_eth_addrs(odp_packet_t pkt_tbl[], unsigned num, int dst_port) odph_ethhdr_t *eth; unsigned i; + if (!gbl_args->appl.dst_change && !gbl_args->appl.src_change) + return; + for (i = 0; i < num; ++i) { pkt = pkt_tbl[i]; if (odp_packet_has_eth(pkt)) { eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); - eth->src = gbl_args->port_eth_addr[dst_port]; + + if (gbl_args->appl.src_change) + eth->src = gbl_args->port_eth_addr[dst_port]; if (gbl_args->appl.dst_change) eth->dst = gbl_args->dst_eth_addr[dst_port]; @@ -659,15 +665,17 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) {"interface", required_argument, NULL, 'i'}, {"mode", required_argument, NULL, 'm'}, {"dst_change", required_argument, NULL, 'd'}, + {"src_change", required_argument, NULL, 's'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0} }; appl_args->time = 0; /* loop forever if time to run is 0 */ appl_args->accuracy = 1; /* get and print pps stats second */ + appl_args->src_change = 1; /* change eth src address by default */ while (1) { - opt = getopt_long(argc, argv, "+c:+t:+a:i:m:d:h", + opt = getopt_long(argc, argv, "+c:+t:+a:i:m:d:s:h", longopts, &long_index); if (opt == -1) @@ -737,6 +745,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) case 'd': appl_args->dst_change = atoi(optarg); break; + case 's': + appl_args->src_change = atoi(optarg); + break; case 'h': usage(argv[0]); exit(EXIT_SUCCESS); @@ -822,6 +833,8 @@ static void usage(char *progname) " (default is 1 second).\n" " -d, --dst_change 0: Don't change packets' dst eth addresses (default)\n" " 1: Change packets' dst eth addresses\n" + " -s, --src_change 0: Don't change packets' src eth addresses\n" + " 1: Change packets' src eth addresses (default)\n" " -h, --help Display help and exit.\n\n" " environment variables: ODP_PKTIO_DISABLE_NETMAP\n" " ODP_PKTIO_DISABLE_SOCKET_MMAP\n" |