From f56d08158ffcc29a6b77fa66048cae48d3194ff8 Mon Sep 17 00:00:00 2001 From: Intel Date: Mon, 3 Jun 2013 00:00:00 +0000 Subject: [PATCH] examples/l2fwd: if no port configured, exit Signed-off-by: Intel --- examples/l2fwd/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index e420b7b0c2..851d767b61 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -583,6 +583,7 @@ MAIN(int argc, char **argv) struct rte_eth_dev_info dev_info; int ret; uint8_t nb_ports; + uint8_t nb_ports_available; uint8_t portid, last_port; unsigned lcore_id, rx_lcore_id; unsigned nb_ports_in_mask = 0; @@ -648,7 +649,7 @@ MAIN(int argc, char **argv) rte_eth_dev_info_get(portid, &dev_info); } - if (nb_ports_in_mask < 2 || nb_ports_in_mask % 2) { + if (nb_ports_in_mask % 2) { printf("Notice: odd number of ports in portmask.\n"); l2fwd_dst_ports[last_port] = last_port; } @@ -680,11 +681,14 @@ MAIN(int argc, char **argv) printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid); } + nb_ports_available = nb_ports; + /* Initialise each port */ for (portid = 0; portid < nb_ports; portid++) { /* skip ports that are not enabled */ if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) { printf("Skipping disabled port %u\n", (unsigned) portid); + nb_ports_available--; continue; } /* init port */ @@ -737,6 +741,11 @@ MAIN(int argc, char **argv) memset(&port_statistics, 0, sizeof(port_statistics)); } + if (!nb_ports_available) { + rte_exit(EXIT_FAILURE, + "All available ports are disabled. Please set portmask.\n"); + } + check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask); /* launch per-lcore init on every lcore */ -- 2.20.1