From: Radu Nicolau Date: Wed, 14 Nov 2018 12:19:09 +0000 (+0000) Subject: examples/bond: fix crash when there is no active slave X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=292fdb76024fce3263e3c33009d37f46c10eddc5;p=dpdk.git examples/bond: fix crash when there is no active slave If bond_ethdev_rx_burst() called more times with no active slaves the active slave index will point out of bounds, resulting in a segfault. The configured slaves needs to be checked, and if none became active there is no point going further. Do not start the packet processing threads until all configured slaves become active. Fixes: cc7e8ae84faa ("examples/bond: add example application for link bonding mode 6") Cc: stable@dpdk.org Signed-off-by: Radu Nicolau Acked-by: Chas Williams --- diff --git a/examples/bond/main.c b/examples/bond/main.c index 65f3c39806..ef86194fff 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -220,6 +220,7 @@ bond_port_init(struct rte_mempool *mbuf_pool) struct rte_eth_rxconf rxq_conf; struct rte_eth_txconf txq_conf; struct rte_eth_conf local_port_conf = port_conf; + uint16_t wait_counter = 20; retval = rte_eth_bond_create("net_bonding0", BONDING_MODE_ALB, 0 /*SOCKET_ID_ANY*/); @@ -274,6 +275,20 @@ bond_port_init(struct rte_mempool *mbuf_pool) if (retval < 0) rte_exit(retval, "Start port %d failed (res=%d)", BOND_PORT, retval); + printf("Waiting for slaves to become active..."); + while (wait_counter) { + uint16_t act_slaves[16] = {0}; + if (rte_eth_bond_active_slaves_get(BOND_PORT, act_slaves, 16) == + slaves_count) { + printf("\n"); + break; + } + sleep(1); + printf("..."); + if (--wait_counter == 0) + rte_exit(-1, "\nFailed to activate slaves\n"); + } + rte_eth_promiscuous_enable(BOND_PORT); struct ether_addr addr;