[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <8157326c0d02ef31e9441950d29c3a5f3b3a6770.1295734271.git.mirq-linux@rere.qmqm.pl>
Date: Sat, 22 Jan 2011 23:14:13 +0100 (CET)
From: Michał Mirosław <mirq-linux@...e.qmqm.pl>
To: netdev@...r.kernel.org
Cc: Ben Hutchings <bhutchings@...arflare.com>
Subject: [PATCH v2 11/16] bonding: convert to ndo_fix_features
Note: Updating of vlan_features is and was broken, as its not propagated
to vlan devices already created ontop of the bond.
Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
drivers/net/bonding/bond_main.c | 45 +++++++++++++++++++++++++-------------
1 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f4373e8..575c2df 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1368,29 +1368,42 @@ static int bond_sethwaddr(struct net_device *bond_dev,
* feature bits are managed elsewhere, so preserve those feature bits
* on the master device.
*/
-static int bond_compute_features(struct bonding *bond)
+static u32 bond_fix_features(struct net_device *bond_dev, u32 features)
{
+ struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
- struct net_device *bond_dev = bond->dev;
- u32 features = bond_dev->features;
- u32 vlan_features = 0;
- 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);
features |= NETIF_F_GSO_MASK | NETIF_F_NO_CSUM;
if (!bond->first_slave)
- goto done;
+ return features;
features &= ~NETIF_F_ONE_FOR_ALL;
- vlan_features = bond->first_slave->dev->vlan_features;
bond_for_each_slave(bond, slave, i) {
features = netdev_increment_features(features,
slave->dev->features,
NETIF_F_ONE_FOR_ALL);
+ }
+
+ return features;
+}
+
+static int bond_set_features(struct net_device *bond_dev, u32 features)
+{
+ struct bonding *bond = netdev_priv(bond_dev);
+ struct slave *slave;
+ unsigned short max_hard_header_len = ETH_HLEN;
+ u32 vlan_features = 0;
+ int i;
+
+ if (!bond->first_slave)
+ return 0;
+
+ vlan_features = bond->first_slave->dev->vlan_features;
+ bond_for_each_slave(bond, slave, i) {
vlan_features = netdev_increment_features(vlan_features,
slave->dev->vlan_features,
NETIF_F_ONE_FOR_ALL);
@@ -1398,10 +1411,8 @@ static int bond_compute_features(struct bonding *bond)
max_hard_header_len = slave->dev->hard_header_len;
}
-done:
- features |= (bond_dev->features & BOND_VLAN_FEATURES);
- bond_dev->features = netdev_fix_features(bond_dev, features);
- bond_dev->vlan_features = netdev_fix_features(bond_dev, vlan_features);
+ /* vlan_features will be trimmed by vlan devices */
+ bond_dev->vlan_features = vlan_features;
bond_dev->hard_header_len = max_hard_header_len;
return 0;
@@ -1661,7 +1672,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
new_slave->delay = 0;
new_slave->link_failure_count = 0;
- bond_compute_features(bond);
+ netdev_update_features(bond_dev);
write_unlock_bh(&bond->lock);
@@ -1905,7 +1916,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
/* release the slave from its bond */
bond_detach_slave(bond, slave);
- bond_compute_features(bond);
+ netdev_update_features(bond_dev);
if (bond->primary_slave == slave)
bond->primary_slave = NULL;
@@ -2090,7 +2101,7 @@ static int bond_release_all(struct net_device *bond_dev)
bond_alb_deinit_slave(bond, slave);
}
- bond_compute_features(bond);
+ netdev_update_features(bond_dev);
bond_destroy_slave_symlinks(bond_dev, slave_dev);
bond_del_vlans_from_slave(bond, slave_dev);
@@ -3563,7 +3574,7 @@ static int bond_slave_netdev_event(unsigned long event,
*/
break;
case NETDEV_FEAT_CHANGE:
- bond_compute_features(bond);
+ netdev_update_features(bond_dev);
break;
default:
break;
@@ -4653,6 +4664,8 @@ static const struct net_device_ops bond_netdev_ops = {
.ndo_netpoll_cleanup = bond_netpoll_cleanup,
.ndo_poll_controller = bond_poll_controller,
#endif
+ .ndo_fix_features = bond_fix_features,
+ .ndo_set_features = bond_set_features,
};
static void bond_destructor(struct net_device *bond_dev)
--
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists