From: Jay Vosburgh <fubar@us.ibm.com>
To: netdev@vger.kernel.org, rdreier@cisco.com, monis@voltaire.com
Cc: monisonlists@gmail.com, ogerlitz@voltaire.com, jgarzik@pobox.com,
davem@davemloft.net, general@lists.openfabrics.org,
Moni Shoua <monis@voltaire.com>
Subject: [PATCH 08/11] net/bonding: Handle wrong assumptions that slave is always an Ethernet device
Date: Fri, 14 Sep 2007 16:40:27 -0700 [thread overview]
Message-ID: <11898132452802-git-send-email-fubar@us.ibm.com> (raw)
In-Reply-To: <11898132441599-git-send-email-fubar@us.ibm.com>
From: Moni Shoua <monis@voltaire.com>
bonding sometimes uses Ethernet constants (such as MTU and address length) which
are not good when it enslaves non Ethernet devices (such as InfiniBand).
Signed-off-by: Moni Shoua <monis@voltaire.com>
Acked-by: Jay Vosburgh <fubar@us.ibm.com>
---
drivers/net/bonding/bond_main.c | 3 ++-
drivers/net/bonding/bond_sysfs.c | 19 +++++++++++++------
drivers/net/bonding/bonding.h | 1 +
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a1fe87a..9ff2cf6 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1224,7 +1224,8 @@ static int bond_compute_features(struct bonding *bond)
struct slave *slave;
struct net_device *bond_dev = bond->dev;
unsigned long features = bond_dev->features;
- unsigned short max_hard_header_len = ETH_HLEN;
+ unsigned short max_hard_header_len = max((u16)ETH_HLEN,
+ bond_dev->hard_header_len);
int i;
features &= ~(NETIF_F_ALL_CSUM | BOND_VLAN_FEATURES);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 073841f..71db5d9 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -163,9 +163,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
printk(KERN_INFO DRV_NAME
": %s is being deleted...\n",
bond->dev->name);
- bond_deinit(bond->dev);
- bond_destroy_sysfs_entry(bond);
- unregister_netdevice(bond->dev);
+ bond_destroy(bond);
rtnl_unlock();
goto out;
}
@@ -259,6 +257,7 @@ static ssize_t bonding_store_slaves(struct device *d,
char command[IFNAMSIZ + 1] = { 0, };
char *ifname;
int i, res, found, ret = count;
+ u32 original_mtu;
struct slave *slave;
struct net_device *dev = NULL;
struct bonding *bond = to_bond(d);
@@ -324,6 +323,7 @@ static ssize_t bonding_store_slaves(struct device *d,
}
/* Set the slave's MTU to match the bond */
+ original_mtu = dev->mtu;
if (dev->mtu != bond->dev->mtu) {
if (dev->change_mtu) {
res = dev->change_mtu(dev,
@@ -338,6 +338,9 @@ static ssize_t bonding_store_slaves(struct device *d,
}
rtnl_lock();
res = bond_enslave(bond->dev, dev);
+ bond_for_each_slave(bond, slave, i)
+ if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0)
+ slave->original_mtu = original_mtu;
rtnl_unlock();
if (res) {
ret = res;
@@ -350,13 +353,17 @@ static ssize_t bonding_store_slaves(struct device *d,
bond_for_each_slave(bond, slave, i)
if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
dev = slave->dev;
+ original_mtu = slave->original_mtu;
break;
}
if (dev) {
printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n",
bond->dev->name, dev->name);
rtnl_lock();
- res = bond_release(bond->dev, dev);
+ if (bond->setup_by_slave)
+ res = bond_release_and_destroy(bond->dev, dev);
+ else
+ res = bond_release(bond->dev, dev);
rtnl_unlock();
if (res) {
ret = res;
@@ -364,9 +371,9 @@ static ssize_t bonding_store_slaves(struct device *d,
}
/* set the slave MTU to the default */
if (dev->change_mtu) {
- dev->change_mtu(dev, 1500);
+ dev->change_mtu(dev, original_mtu);
} else {
- dev->mtu = 1500;
+ dev->mtu = original_mtu;
}
}
else {
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 700d40a..b7b4f4a 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -156,6 +156,7 @@ struct slave {
s8 link; /* one of BOND_LINK_XXXX */
s8 state; /* one of BOND_STATE_XXXX */
u32 original_flags;
+ u32 original_mtu;
u32 link_failure_count;
u16 speed;
u8 duplex;
--
1.5.2-rc2.GIT
next prev parent reply other threads:[~2007-09-14 23:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-14 23:40 [ofa-general] [PATCH 00/11] IPoIB support for bonding Jay Vosburgh
2007-09-14 23:40 ` [PATCH 01/11] IB/ipoib: Export call to call_netdevice_notifiers and add new private flag Jay Vosburgh
2007-09-14 23:40 ` [ofa-general] [PATCH 02/11] IB/ipoib: Notify the world before doing unregister Jay Vosburgh
2007-09-14 23:40 ` [PATCH 03/11] IB/ipoib: Bound the net device to the ipoib_neigh structue Jay Vosburgh
2007-09-14 23:40 ` [PATCH 04/11] IB/ipoib: Verify address handle validity on send Jay Vosburgh
2007-09-14 23:40 ` [PATCH 05/11] net/bonding: Enable bonding to enslave non ARPHRD_ETHER Jay Vosburgh
2007-09-14 23:40 ` [PATCH 06/11] net/bonding: Enable bonding to enslave netdevices not supporting set_mac_address() Jay Vosburgh
2007-09-14 23:40 ` [PATCH 07/11] net/bonding: Enable IP multicast for bonding IPoIB devices Jay Vosburgh
2007-09-14 23:40 ` Jay Vosburgh [this message]
2007-09-14 23:40 ` [PATCH 9/11] net/bonding: Delay sending of gratuitous ARP to avoid failure Jay Vosburgh
2007-09-14 23:40 ` [PATCH 10/11] net/bonding: Destroy bonding master when last slave is gone Jay Vosburgh
2007-09-14 23:40 ` [PATCH 11/11] bonding: Optionally allow ethernet slaves to keep own MAC Jay Vosburgh
2007-09-17 22:20 ` [PATCH 04/11] IB/ipoib: Verify address handle validity on send Roland Dreier
2007-09-17 22:23 ` [ofa-general] Re: [PATCH 03/11] IB/ipoib: Bound the net device to the ipoib_neigh structue Roland Dreier
2007-09-17 22:22 ` [ofa-general] Re: [PATCH 02/11] IB/ipoib: Notify the world before doing unregister Roland Dreier
2007-09-17 22:25 ` Roland Dreier
2007-09-17 23:23 ` Jay Vosburgh
2007-09-17 23:33 ` Roland Dreier
2007-09-18 17:42 ` [ofa-general] " Roland Dreier
2007-09-19 16:41 ` Moni Shoua
2007-09-19 16:44 ` Roland Dreier
2007-09-17 22:17 ` [ofa-general] Re: [PATCH 01/11] IB/ipoib: Export call to call_netdevice_notifiers and add new private flag Roland Dreier
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=11898132452802-git-send-email-fubar@us.ibm.com \
--to=fubar@us.ibm.com \
--cc=davem@davemloft.net \
--cc=general@lists.openfabrics.org \
--cc=jgarzik@pobox.com \
--cc=monis@voltaire.com \
--cc=monisonlists@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@voltaire.com \
--cc=rdreier@cisco.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).