DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: "Min Hu (Connor)" <humin29@huawei.com>, <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <xiaoyun.li@intel.com>
Subject: Re: [PATCH] app/testpmd: fix bonding mode set
Date: Mon, 31 Jan 2022 16:13:35 +0000	[thread overview]
Message-ID: <c3883b05-ff7e-094a-d303-62af6cb459f7@intel.com> (raw)
In-Reply-To: <20220128023519.10027-1-humin29@huawei.com>

On 1/28/2022 2:35 AM, Min Hu (Connor) wrote:
> when start testpmd, and type command like this, it will lead to
> Segmentation fault, like:
> 
> testpmd> create bonded device 4 0
> testpmd> add bonding slave 0 2
> testpmd> add bonding slave 1 2
> testpmd> port start 2
> testpmd> set bonding mode 0 2
> testpmd> quit
> Stopping port 0...
> Stopping ports...
> ...
> Bye...
> Segmentation fault
> 
> The reason to the bug is that rte timer do not be cancelled when quit.
> That is, in 'bond_ethdev_start', resources are allocated according to
> different bonding mode. In 'bond_ethdev_stop', resources are free by
> the corresponding mode.
> 
> For example, 'bond_ethdev_start' start bond_mode_8023ad_ext_periodic_cb
> timer for bonding mode 4. and 'bond_ethdev_stop' cancel the timer only
> when the current bonding mode is 4. If the bonding mode is changed,
> and directly quit the process, the timer will still on, and freed memory
> will be accessed, then segmentation fault.
> 
> 'bonding mode'changed means resources changed, reallocate resources for

'bonding mode' changed ...

> different mode should be done, that is, device should be restarted.
> 
> Fixes: 2950a769315e ("bond: testpmd support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.

> ---
>   app/test-pmd/cmdline.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index e626b1c7d9..2c47ab0f18 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -5915,6 +5915,19 @@ static void cmd_set_bonding_mode_parsed(void *parsed_result,
>   {
>   	struct cmd_set_bonding_mode_result *res = parsed_result;
>   	portid_t port_id = res->port_id;
> +	struct rte_port *port = &ports[port_id];
> +
> +	/*
> +	 * Bonding mode changed means resources of device changed, like whether
> +	 * started rte timer or not. Device should be restarted when resources
> +	 * of device changed.
> +	 */
> +	if (port->port_status != RTE_PORT_STOPPED) {
> +		fprintf(stderr,
> +			"\t Error: Can't config bonding mode when port %d is not stopped\n",

Updated as "... Can't set bonding mode ..."

> +			port_id);
> +		return;
> +	}
>   
>   	/* Set the bonding mode for the relevant port. */
>   	if (0 != rte_eth_bond_mode_set(port_id, res->value))


      reply	other threads:[~2022-01-31 16:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28  2:35 Min Hu (Connor)
2022-01-31 16:13 ` Ferruh Yigit [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3883b05-ff7e-094a-d303-62af6cb459f7@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.com \
    --cc=thomas@monjalon.net \
    --cc=xiaoyun.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).