From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 768F637B0 for ; Tue, 12 Mar 2019 13:20:26 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2019 05:20:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,471,1544515200"; d="scan'208";a="326549628" Received: from silpixa00383879.ir.intel.com (HELO silpixa00383879.ger.corp.intel.com) ([10.237.222.142]) by fmsmga006.fm.intel.com with ESMTP; 12 Mar 2019 05:20:23 -0700 From: Radu Nicolau To: stable@dpdk.org Cc: yskoh@mellanox.com, Radu Nicolau Date: Tue, 12 Mar 2019 12:13:50 +0000 Message-Id: <1552392830-6198-1-git-send-email-radu.nicolau@intel.com> X-Mailer: git-send-email 2.7.5 Subject: [dpdk-stable] [17.11] examples/bond: fix crash when there is no active slave X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 12:20:26 -0000 [ backported from upstream commit 292fdb76024f ] 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") Signed-off-by: Radu Nicolau Acked-by: Chas Williams --- examples/bond/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/bond/main.c b/examples/bond/main.c index 4f533e2..317e217 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -225,6 +225,7 @@ bond_port_init(struct rte_mempool *mbuf_pool) uint8_t i; uint16_t nb_rxd = RTE_RX_DESC_DEFAULT; uint16_t nb_txd = RTE_TX_DESC_DEFAULT; + uint16_t wait_counter = 20; retval = rte_eth_bond_create("net_bonding0", BONDING_MODE_ALB, 0 /*SOCKET_ID_ANY*/); @@ -271,6 +272,21 @@ 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; -- 2.7.5