Subject: Re: [PATCH net 2/3] bonding:check mode when modify primary_reselect

From: Nicolas de Pesloüan<[email-masked]>
Date: Mon, 11 Jun 2012 21:42:17 +0200

Le 11/06/2012 11:00, Weiping Pan a écrit :
> Using a primary_reselect only makes sense in active backup, TLB or ALB modes.
>
> Signed-off-by: Weiping Pan<[email-masked]>
> ---
>   drivers/net/bonding/bond_sysfs.c |    7 +++++++
>   1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
> index 485bedb..1b0f3cd 100644
> --- a/drivers/net/bonding/bond_sysfs.c
> +++ b/drivers/net/bonding/bond_sysfs.c
> @@ -1123,6 +1123,13 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
>   	if (!rtnl_trylock())
>   		return restart_syscall();
>
> +	if (!USES_PRIMARY(bond->params.mode)) {
> +		pr_err("%s: Unable to set primary_reselect; %s is in mode %d\n",
> +			bond->dev->name, bond->dev->name, bond->params.mode);
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
>   	new_value = bond_parse_parm(buf, pri_reselect_tbl);
>   	if (new_value<  0)  {
>   		pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",

May I suggest we only issue a warning, store the new value for primary_reselect, and avoid calling 
bond_select_active_slave(bond), if !USE_PRIMARY(bond->params.mode)?

That way, we do not add one more constraint on the order one must write into sysfs.

	Nicolas.