mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
net: make dev->master general
dev->master is now tightly connected to bonding driver. This patch makes this pointer more general and ready to be used by others. - netdev_set_master() - bond specifics moved to new function netdev_set_bond_master() - introduced netif_is_bond_slave() to check if device is a bonding slave Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d59cfde2fb
commit
1765a57533
6 changed files with 54 additions and 20 deletions
|
@ -153,7 +153,8 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
|
||||||
nesdev, nesdev->netdev[0]->name);
|
nesdev, nesdev->netdev[0]->name);
|
||||||
netdev = nesdev->netdev[0];
|
netdev = nesdev->netdev[0];
|
||||||
nesvnic = netdev_priv(netdev);
|
nesvnic = netdev_priv(netdev);
|
||||||
is_bonded = (netdev->master == event_netdev);
|
is_bonded = netif_is_bond_slave(netdev) &&
|
||||||
|
(netdev->master == event_netdev);
|
||||||
if ((netdev == event_netdev) || is_bonded) {
|
if ((netdev == event_netdev) || is_bonded) {
|
||||||
if (nesvnic->rdma_enabled == 0) {
|
if (nesvnic->rdma_enabled == 0) {
|
||||||
nes_debug(NES_DBG_NETDEV, "Returning without processing event for %s since"
|
nes_debug(NES_DBG_NETDEV, "Returning without processing event for %s since"
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nesvnic->netdev->master)
|
if (netif_is_bond_slave(netdev))
|
||||||
netdev = nesvnic->netdev->master;
|
netdev = nesvnic->netdev->master;
|
||||||
else
|
else
|
||||||
netdev = nesvnic->netdev;
|
netdev = nesvnic->netdev;
|
||||||
|
|
|
@ -1594,9 +1594,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = netdev_set_master(slave_dev, bond_dev);
|
res = netdev_set_bond_master(slave_dev, bond_dev);
|
||||||
if (res) {
|
if (res) {
|
||||||
pr_debug("Error %d calling netdev_set_master\n", res);
|
pr_debug("Error %d calling netdev_set_bond_master\n", res);
|
||||||
goto err_restore_mac;
|
goto err_restore_mac;
|
||||||
}
|
}
|
||||||
/* open the slave since the application closed it */
|
/* open the slave since the application closed it */
|
||||||
|
@ -1812,7 +1812,7 @@ err_close:
|
||||||
dev_close(slave_dev);
|
dev_close(slave_dev);
|
||||||
|
|
||||||
err_unset_master:
|
err_unset_master:
|
||||||
netdev_set_master(slave_dev, NULL);
|
netdev_set_bond_master(slave_dev, NULL);
|
||||||
|
|
||||||
err_restore_mac:
|
err_restore_mac:
|
||||||
if (!bond->params.fail_over_mac) {
|
if (!bond->params.fail_over_mac) {
|
||||||
|
@ -1992,7 +1992,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
|
||||||
netif_addr_unlock_bh(bond_dev);
|
netif_addr_unlock_bh(bond_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
netdev_set_master(slave_dev, NULL);
|
netdev_set_bond_master(slave_dev, NULL);
|
||||||
|
|
||||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||||
read_lock_bh(&bond->lock);
|
read_lock_bh(&bond->lock);
|
||||||
|
@ -2114,7 +2114,7 @@ static int bond_release_all(struct net_device *bond_dev)
|
||||||
netif_addr_unlock_bh(bond_dev);
|
netif_addr_unlock_bh(bond_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
netdev_set_master(slave_dev, NULL);
|
netdev_set_bond_master(slave_dev, NULL);
|
||||||
|
|
||||||
/* close slave before restoring its mac address */
|
/* close slave before restoring its mac address */
|
||||||
dev_close(slave_dev);
|
dev_close(slave_dev);
|
||||||
|
|
|
@ -186,9 +186,10 @@ static struct net_device *get_iff_from_mac(struct adapter *adapter,
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
if (grp)
|
if (grp)
|
||||||
dev = vlan_group_get_device(grp, vlan);
|
dev = vlan_group_get_device(grp, vlan);
|
||||||
} else
|
} else if (netif_is_bond_slave(dev)) {
|
||||||
while (dev->master)
|
while (dev->master)
|
||||||
dev = dev->master;
|
dev = dev->master;
|
||||||
|
}
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2377,6 +2377,8 @@ extern int netdev_max_backlog;
|
||||||
extern int netdev_tstamp_prequeue;
|
extern int netdev_tstamp_prequeue;
|
||||||
extern int weight_p;
|
extern int weight_p;
|
||||||
extern int netdev_set_master(struct net_device *dev, struct net_device *master);
|
extern int netdev_set_master(struct net_device *dev, struct net_device *master);
|
||||||
|
extern int netdev_set_bond_master(struct net_device *dev,
|
||||||
|
struct net_device *master);
|
||||||
extern int skb_checksum_help(struct sk_buff *skb);
|
extern int skb_checksum_help(struct sk_buff *skb);
|
||||||
extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features);
|
extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features);
|
||||||
#ifdef CONFIG_BUG
|
#ifdef CONFIG_BUG
|
||||||
|
@ -2437,6 +2439,11 @@ static inline void netif_set_gso_max_size(struct net_device *dev,
|
||||||
dev->gso_max_size = size;
|
dev->gso_max_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int netif_is_bond_slave(struct net_device *dev)
|
||||||
|
{
|
||||||
|
return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
|
||||||
|
}
|
||||||
|
|
||||||
extern struct pernet_operations __net_initdata loopback_net_ops;
|
extern struct pernet_operations __net_initdata loopback_net_ops;
|
||||||
|
|
||||||
static inline int dev_ethtool_get_settings(struct net_device *dev,
|
static inline int dev_ethtool_get_settings(struct net_device *dev,
|
||||||
|
|
|
@ -3146,7 +3146,6 @@ static int __netif_receive_skb(struct sk_buff *skb)
|
||||||
struct packet_type *ptype, *pt_prev;
|
struct packet_type *ptype, *pt_prev;
|
||||||
rx_handler_func_t *rx_handler;
|
rx_handler_func_t *rx_handler;
|
||||||
struct net_device *orig_dev;
|
struct net_device *orig_dev;
|
||||||
struct net_device *master;
|
|
||||||
struct net_device *null_or_orig;
|
struct net_device *null_or_orig;
|
||||||
struct net_device *orig_or_bond;
|
struct net_device *orig_or_bond;
|
||||||
int ret = NET_RX_DROP;
|
int ret = NET_RX_DROP;
|
||||||
|
@ -3173,15 +3172,19 @@ static int __netif_receive_skb(struct sk_buff *skb)
|
||||||
*/
|
*/
|
||||||
null_or_orig = NULL;
|
null_or_orig = NULL;
|
||||||
orig_dev = skb->dev;
|
orig_dev = skb->dev;
|
||||||
master = ACCESS_ONCE(orig_dev->master);
|
|
||||||
if (skb->deliver_no_wcard)
|
if (skb->deliver_no_wcard)
|
||||||
null_or_orig = orig_dev;
|
null_or_orig = orig_dev;
|
||||||
else if (master) {
|
else if (netif_is_bond_slave(orig_dev)) {
|
||||||
if (__skb_bond_should_drop(skb, master)) {
|
struct net_device *bond_master = ACCESS_ONCE(orig_dev->master);
|
||||||
|
|
||||||
|
if (likely(bond_master)) {
|
||||||
|
if (__skb_bond_should_drop(skb, bond_master)) {
|
||||||
skb->deliver_no_wcard = 1;
|
skb->deliver_no_wcard = 1;
|
||||||
null_or_orig = orig_dev; /* deliver only exact match */
|
/* deliver only exact match */
|
||||||
|
null_or_orig = orig_dev;
|
||||||
} else
|
} else
|
||||||
skb->dev = master;
|
skb->dev = bond_master;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__this_cpu_inc(softnet_data.processed);
|
__this_cpu_inc(softnet_data.processed);
|
||||||
|
@ -4346,15 +4349,14 @@ static int __init dev_proc_init(void)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* netdev_set_master - set up master/slave pair
|
* netdev_set_master - set up master pointer
|
||||||
* @slave: slave device
|
* @slave: slave device
|
||||||
* @master: new master device
|
* @master: new master device
|
||||||
*
|
*
|
||||||
* Changes the master device of the slave. Pass %NULL to break the
|
* Changes the master device of the slave. Pass %NULL to break the
|
||||||
* bonding. The caller must hold the RTNL semaphore. On a failure
|
* bonding. The caller must hold the RTNL semaphore. On a failure
|
||||||
* a negative errno code is returned. On success the reference counts
|
* a negative errno code is returned. On success the reference counts
|
||||||
* are adjusted, %RTM_NEWLINK is sent to the routing socket and the
|
* are adjusted and the function returns zero.
|
||||||
* function returns zero.
|
|
||||||
*/
|
*/
|
||||||
int netdev_set_master(struct net_device *slave, struct net_device *master)
|
int netdev_set_master(struct net_device *slave, struct net_device *master)
|
||||||
{
|
{
|
||||||
|
@ -4374,6 +4376,29 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
|
||||||
synchronize_net();
|
synchronize_net();
|
||||||
dev_put(old);
|
dev_put(old);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(netdev_set_master);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* netdev_set_bond_master - set up bonding master/slave pair
|
||||||
|
* @slave: slave device
|
||||||
|
* @master: new master device
|
||||||
|
*
|
||||||
|
* Changes the master device of the slave. Pass %NULL to break the
|
||||||
|
* bonding. The caller must hold the RTNL semaphore. On a failure
|
||||||
|
* a negative errno code is returned. On success %RTM_NEWLINK is sent
|
||||||
|
* to the routing socket and the function returns zero.
|
||||||
|
*/
|
||||||
|
int netdev_set_bond_master(struct net_device *slave, struct net_device *master)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
ASSERT_RTNL();
|
||||||
|
|
||||||
|
err = netdev_set_master(slave, master);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
if (master)
|
if (master)
|
||||||
slave->flags |= IFF_SLAVE;
|
slave->flags |= IFF_SLAVE;
|
||||||
else
|
else
|
||||||
|
@ -4382,7 +4407,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
|
||||||
rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);
|
rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(netdev_set_master);
|
EXPORT_SYMBOL(netdev_set_bond_master);
|
||||||
|
|
||||||
static void dev_change_rx_flags(struct net_device *dev, int flags)
|
static void dev_change_rx_flags(struct net_device *dev, int flags)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue