From: Moni Shoua <monis@voltaire.com>
To: Jay Vosburgh <fubar@us.ibm.com>
Cc: netdev <netdev@vger.kernel.org>, Olga Stern <olgas@voltaire.com>,
Or Gerlitz <ogerlitz@voltaire.com>
Subject: [PATCH]: net/bonding: Enable to change device type before enslaving
Date: Thu, 10 Apr 2008 18:09:51 +0300 [thread overview]
Message-ID: <47FE2DBF.7080803@voltaire.com> (raw)
The bonding network device is being created with device type ARPHDR_ETHER.
Although the device type changes with first slave we want to be able to change
it when it has zero slaves. The reason is to make the kernel choose the right
function for multicast address translation (ib_xxx_mc_map) which is determined by
device type even when no slaves are enslaved. If not so, the kernel picks a wrong
translation function and wrong HW addresses will be passed to slaves when the
bonding device tries to set their multicast lists.
Signed-off-by: Moni Shoua <monis@voltaire.com>
---
drivers/net/bonding/bond_sysfs.c | 48 +++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+)
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 90a1f31..86fec7e 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -950,6 +950,7 @@ out:
}
static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp);
+
/*
* Show and set the MII monitor interval. There are two tricky bits
* here. First, if MII monitoring is activated, then we must disable
@@ -1039,6 +1040,52 @@ out:
static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon);
/*
+ * Show and set the device type of the bonding device
+ */
+static ssize_t bonding_show_devtype(struct device *d,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct bonding *bond = to_bond(d);
+
+ return sprintf(buf, "%d\n", bond->dev->type);
+}
+
+static ssize_t bonding_store_devtype(struct device *d,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int new_value, ret = count;
+ struct bonding *bond = to_bond(d);
+
+ if (sscanf(buf, "%d", &new_value) != 1) {
+ printk(KERN_ERR DRV_NAME
+ ": %s: no device type value specified.\n",
+ bond->dev->name);
+ ret = -EINVAL;
+ goto out;
+ }
+ if (bond->slave_cnt > 0) {
+ printk(KERN_ERR DRV_NAME
+ ": %s: Can't change device type when slaves are present; rejected.\n",
+ bond->dev->name);
+ ret = -EINVAL;
+ goto out;
+ }
+ if (new_value <= 0) {
+ printk(KERN_ERR DRV_NAME
+ ": %s: Invalid device type %d not in range %d-%d; rejected.\n",
+ bond->dev->name, new_value, 1, INT_MAX);
+ ret = -EINVAL;
+ goto out;
+ }
+ bond->dev->type = new_value;
+out:
+ return ret;
+}
+static DEVICE_ATTR(devtype, S_IRUGO | S_IWUSR, bonding_show_devtype, bonding_store_devtype);
+
+/*
* Show and set the primary slave. The store function is much
* simpler than bonding_store_slaves function because it only needs to
* handle one interface name.
@@ -1387,6 +1434,7 @@ static struct attribute *per_bond_attrs[
&dev_attr_updelay.attr,
&dev_attr_lacp_rate.attr,
&dev_attr_xmit_hash_policy.attr,
+ &dev_attr_devtype.attr,
&dev_attr_miimon.attr,
&dev_attr_primary.attr,
&dev_attr_use_carrier.attr,
next reply other threads:[~2008-04-10 14:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 15:09 Moni Shoua [this message]
2008-04-10 20:48 ` [PATCH]: net/bonding: Enable to change device type before enslaving Jay Vosburgh
2008-04-13 14:09 ` Moni Shoua
2008-04-16 19:27 ` Jay Vosburgh
2008-04-17 6:29 ` Moni Shoua
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=47FE2DBF.7080803@voltaire.com \
--to=monis@voltaire.com \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@voltaire.com \
--cc=olgas@voltaire.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).