* [PATCH net-next-2.6] bonding: set primary param via sysfs
@ 2009-09-18 12:13 Jiri Pirko
2009-09-18 20:21 ` [Bonding-devel] " Nicolas de Pesloüan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jiri Pirko @ 2009-09-18 12:13 UTC (permalink / raw)
To: netdev; +Cc: davem, fubar, bonding-devel
Primary module parameter passed to bonding is pernament. That means if you
release the primary slave and enslave it again, it becomes the primary slave
again. But if you set primary slave via sysfs, the primary slave is only set
once and it's not remembered in bond->params structure. Therefore the setting is
lost after releasing the primary slave. This simple one-liner fixes this.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 6044e12..ff449de 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1182,6 +1182,7 @@ static ssize_t bonding_store_primary(struct device *d,
": %s: Setting %s as primary slave.\n",
bond->dev->name, slave->dev->name);
bond->primary_slave = slave;
+ strcpy(bond->params.primary, slave->dev->name);
bond_select_active_slave(bond);
goto out;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Bonding-devel] [PATCH net-next-2.6] bonding: set primary param via sysfs
2009-09-18 12:13 [PATCH net-next-2.6] bonding: set primary param via sysfs Jiri Pirko
@ 2009-09-18 20:21 ` Nicolas de Pesloüan
2009-09-18 23:02 ` Jay Vosburgh
2009-10-01 21:39 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Nicolas de Pesloüan @ 2009-09-18 20:21 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, fubar, davem, bonding-devel
Jiri Pirko wrote:
> Primary module parameter passed to bonding is pernament. That means if you
typo in "permanent".
> release the primary slave and enslave it again, it becomes the primary slave
> again. But if you set primary slave via sysfs, the primary slave is only set
> once and it's not remembered in bond->params structure. Therefore the setting is
> lost after releasing the primary slave. This simple one-liner fixes this.
You patch also has the side effect of fixing this strange behavior:
If you move the primary slave from one bond device to another one, it becomes
the primary for this other bond device, ignoring what you might have set as the
primary for this other bond device.
#modprobe bonding mode=active-backup primary=eth0
#echo +eth0 > /sys/class/net/bond0/bonding/slaves
#cat /sys/class/net/bond0/bonding/primary
eth0
#echo -eth0 > /sys/class/net/bond0/bonding/slaves
#echo +eth1 > /sys/class/net/bond1/bonding/slaves
#echo eth1 > /sys/class/net/bond1/bonding/primary
#cat /sys/class/net/bond1/bonding/primary
eth1
#echo +eth0 > /sys/class/net/bond1/bonding/slaves
#cat /sys/class/net/bond1/bonding/primary
eth0
=> Primary just changed, for no good reason.
Can someone imagine that some current configurations rely on this incredible
side effect ?
Nicolas.
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
> diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
> index 6044e12..ff449de 100644
> --- a/drivers/net/bonding/bond_sysfs.c
> +++ b/drivers/net/bonding/bond_sysfs.c
> @@ -1182,6 +1182,7 @@ static ssize_t bonding_store_primary(struct device *d,
> ": %s: Setting %s as primary slave.\n",
> bond->dev->name, slave->dev->name);
> bond->primary_slave = slave;
> + strcpy(bond->params.primary, slave->dev->name);
> bond_select_active_slave(bond);
> goto out;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] bonding: set primary param via sysfs
2009-09-18 12:13 [PATCH net-next-2.6] bonding: set primary param via sysfs Jiri Pirko
2009-09-18 20:21 ` [Bonding-devel] " Nicolas de Pesloüan
@ 2009-09-18 23:02 ` Jay Vosburgh
2009-10-01 21:39 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Jay Vosburgh @ 2009-09-18 23:02 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, bonding-devel
Jiri Pirko <jpirko@redhat.com> wrote:
>Primary module parameter passed to bonding is pernament. That means if you
>release the primary slave and enslave it again, it becomes the primary slave
>again. But if you set primary slave via sysfs, the primary slave is only set
>once and it's not remembered in bond->params structure. Therefore the setting is
>lost after releasing the primary slave. This simple one-liner fixes this.
>
>Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>index 6044e12..ff449de 100644
>--- a/drivers/net/bonding/bond_sysfs.c
>+++ b/drivers/net/bonding/bond_sysfs.c
>@@ -1182,6 +1182,7 @@ static ssize_t bonding_store_primary(struct device *d,
> ": %s: Setting %s as primary slave.\n",
> bond->dev->name, slave->dev->name);
> bond->primary_slave = slave;
>+ strcpy(bond->params.primary, slave->dev->name);
> bond_select_active_slave(bond);
> goto out;
> }
Looks good, fixes another bug I'd not heard of previously.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] bonding: set primary param via sysfs
2009-09-18 12:13 [PATCH net-next-2.6] bonding: set primary param via sysfs Jiri Pirko
2009-09-18 20:21 ` [Bonding-devel] " Nicolas de Pesloüan
2009-09-18 23:02 ` Jay Vosburgh
@ 2009-10-01 21:39 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-10-01 21:39 UTC (permalink / raw)
To: jpirko; +Cc: netdev, fubar, bonding-devel
From: Jiri Pirko <jpirko@redhat.com>
Date: Fri, 18 Sep 2009 14:13:22 +0200
> Primary module parameter passed to bonding is pernament. That means if you
> release the primary slave and enslave it again, it becomes the primary slave
> again. But if you set primary slave via sysfs, the primary slave is only set
> once and it's not remembered in bond->params structure. Therefore the setting is
> lost after releasing the primary slave. This simple one-liner fixes this.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied, thanks Jiri.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-01 21:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-18 12:13 [PATCH net-next-2.6] bonding: set primary param via sysfs Jiri Pirko
2009-09-18 20:21 ` [Bonding-devel] " Nicolas de Pesloüan
2009-09-18 23:02 ` Jay Vosburgh
2009-10-01 21:39 ` David Miller
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).