aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2011-02-12 01:48:36 -0500
committerDavid S. Miller <davem@davemloft.net>2011-02-13 13:42:07 -0500
commit1765a575334f1a232c1478accdee5c7d19f4b3e3 (patch)
tree6613f53ce9095b799048d891f0b4b6e34a479fe0 /net/core
parentd59cfde2fb960b5970ccb5a38cea25d38b37a8e8 (diff)
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>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index d874fd1baf49..a4132766d363 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3146,7 +3146,6 @@ static int __netif_receive_skb(struct sk_buff *skb)
3146 struct packet_type *ptype, *pt_prev; 3146 struct packet_type *ptype, *pt_prev;
3147 rx_handler_func_t *rx_handler; 3147 rx_handler_func_t *rx_handler;
3148 struct net_device *orig_dev; 3148 struct net_device *orig_dev;
3149 struct net_device *master;
3150 struct net_device *null_or_orig; 3149 struct net_device *null_or_orig;
3151 struct net_device *orig_or_bond; 3150 struct net_device *orig_or_bond;
3152 int ret = NET_RX_DROP; 3151 int ret = NET_RX_DROP;
@@ -3173,15 +3172,19 @@ static int __netif_receive_skb(struct sk_buff *skb)
3173 */ 3172 */
3174 null_or_orig = NULL; 3173 null_or_orig = NULL;
3175 orig_dev = skb->dev; 3174 orig_dev = skb->dev;
3176 master = ACCESS_ONCE(orig_dev->master);
3177 if (skb->deliver_no_wcard) 3175 if (skb->deliver_no_wcard)
3178 null_or_orig = orig_dev; 3176 null_or_orig = orig_dev;
3179 else if (master) { 3177 else if (netif_is_bond_slave(orig_dev)) {
3180 if (__skb_bond_should_drop(skb, master)) { 3178 struct net_device *bond_master = ACCESS_ONCE(orig_dev->master);
3181 skb->deliver_no_wcard = 1; 3179
3182 null_or_orig = orig_dev; /* deliver only exact match */ 3180 if (likely(bond_master)) {
3183 } else 3181 if (__skb_bond_should_drop(skb, bond_master)) {
3184 skb->dev = master; 3182 skb->deliver_no_wcard = 1;
3183 /* deliver only exact match */
3184 null_or_orig = orig_dev;
3185 } else
3186 skb->dev = bond_master;
3187 }
3185 } 3188 }
3186 3189
3187 __this_cpu_inc(softnet_data.processed); 3190 __this_cpu_inc(softnet_data.processed);
@@ -4346,15 +4349,14 @@ static int __init dev_proc_init(void)
4346 4349
4347 4350
4348/** 4351/**
4349 * netdev_set_master - set up master/slave pair 4352 * netdev_set_master - set up master pointer
4350 * @slave: slave device 4353 * @slave: slave device
4351 * @master: new master device 4354 * @master: new master device
4352 * 4355 *
4353 * Changes the master device of the slave. Pass %NULL to break the 4356 * Changes the master device of the slave. Pass %NULL to break the
4354 * bonding. The caller must hold the RTNL semaphore. On a failure 4357 * bonding. The caller must hold the RTNL semaphore. On a failure
4355 * a negative errno code is returned. On success the reference counts 4358 * a negative errno code is returned. On success the reference counts
4356 * are adjusted, %RTM_NEWLINK is sent to the routing socket and the 4359 * are adjusted and the function returns zero.
4357 * function returns zero.
4358 */ 4360 */
4359int netdev_set_master(struct net_device *slave, struct net_device *master) 4361int netdev_set_master(struct net_device *slave, struct net_device *master)
4360{ 4362{
@@ -4374,6 +4376,29 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
4374 synchronize_net(); 4376 synchronize_net();
4375 dev_put(old); 4377 dev_put(old);
4376 } 4378 }
4379 return 0;
4380}
4381EXPORT_SYMBOL(netdev_set_master);
4382
4383/**
4384 * netdev_set_bond_master - set up bonding master/slave pair
4385 * @slave: slave device
4386 * @master: new master device
4387 *
4388 * Changes the master device of the slave. Pass %NULL to break the
4389 * bonding. The caller must hold the RTNL semaphore. On a failure
4390 * a negative errno code is returned. On success %RTM_NEWLINK is sent
4391 * to the routing socket and the function returns zero.
4392 */
4393int netdev_set_bond_master(struct net_device *slave, struct net_device *master)
4394{
4395 int err;
4396
4397 ASSERT_RTNL();
4398
4399 err = netdev_set_master(slave, master);
4400 if (err)
4401 return err;
4377 if (master) 4402 if (master)
4378 slave->flags |= IFF_SLAVE; 4403 slave->flags |= IFF_SLAVE;
4379 else 4404 else
@@ -4382,7 +4407,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
4382 rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE); 4407 rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);
4383 return 0; 4408 return 0;
4384} 4409}
4385EXPORT_SYMBOL(netdev_set_master); 4410EXPORT_SYMBOL(netdev_set_bond_master);
4386 4411
4387static void dev_change_rx_flags(struct net_device *dev, int flags) 4412static void dev_change_rx_flags(struct net_device *dev, int flags)
4388{ 4413{