aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bonding.h
diff options
context:
space:
mode:
authorAndy Gospodarek <andy@greyhouse.net>2012-03-22 12:14:29 -0400
committerDavid S. Miller <davem@davemloft.net>2012-03-22 22:36:17 -0400
commiteaddcd76903c28e84bb452a35835babb0800a2c4 (patch)
tree97e512e21955da69d434a34b4e073ba880ec7d3d /drivers/net/bonding/bonding.h
parent523f610e1be2a4afca605962e137064378883c5f (diff)
bonding: remove entries for master_ip and vlan_ip and query devices instead
The following patch aimed to resolve an issue where secondary, tertiary, etc. addresses added to bond interfaces could overwrite the bond->master_ip and vlan_ip values. commit 917fbdb32f37e9a93b00bb12ee83532982982df3 Author: Henrik Saavedra Persson <henrik.e.persson@ericsson.com> Date: Wed Nov 23 23:37:15 2011 +0000 bonding: only use primary address for ARP That patch was good because it prevented bonds using ARP monitoring from sending frames with an invalid source IP address. Unfortunately, it didn't always work as expected. When using an ioctl (like ifconfig does) to set the IP address and netmask, 2 separate ioctls are actually called to set the IP and netmask if the mask chosen doesn't match the standard mask for that class of address. The first ioctl did not have a mask that matched the one in the primary address and would still cause the device address to be overwritten. The second ioctl that was called to set the mask would then detect as secondary and ignored, but the damage was already done. This was not an issue when using an application that used netlink sockets as the setting of IP and netmask came down at once. The inconsistent behavior between those two interfaces was something that needed to be resolved. While I was thinking about how I wanted to resolve this, Ralf Zeidler came with a patch that resolved this on a RHEL kernel by keeping a full shadow of the entries in dev->ifa_list for the bonding device and vlan devices in the bonding driver. I didn't like the duplication of the list as I want to see the 'bonding' struct and code shrink rather than grow, but liked the general idea. As the Subject indicates this patch drops the master_ip and vlan_ip elements from the 'bonding' and 'vlan_entry' structs, respectively. This can be done because a device's address-list is now traversed to determine the optimal source IP address for ARP requests and for checks to see if the bonding device has a particular IP address. This code could have all be contained inside the bonding driver, but it made more sense to me to EXPORT and call inet_confirm_addr since it did exactly what was needed. I tested this and a backported patch and everything works as expected. Ralf also helped with verification of the backported patch. Thanks to Ralf for all his help on this. v2: Whitespace and organizational changes based on suggestions from Jay Vosburgh and Dave Miller. v3: Fixup incorrect usage of rcu_read_unlock based on Dave Miller's suggestion. Signed-off-by: Andy Gospodarek <andy@greyhouse.net> CC: Ralf Zeidler <ralf.zeidler@nsn.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bonding.h')
-rw-r--r--drivers/net/bonding/bonding.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 1aecc37e5b4d..9f2bae6616d3 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -21,6 +21,7 @@
21#include <linux/cpumask.h> 21#include <linux/cpumask.h>
22#include <linux/in6.h> 22#include <linux/in6.h>
23#include <linux/netpoll.h> 23#include <linux/netpoll.h>
24#include <linux/inetdevice.h>
24#include "bond_3ad.h" 25#include "bond_3ad.h"
25#include "bond_alb.h" 26#include "bond_alb.h"
26 27
@@ -166,7 +167,6 @@ struct bond_parm_tbl {
166 167
167struct vlan_entry { 168struct vlan_entry {
168 struct list_head vlan_list; 169 struct list_head vlan_list;
169 __be32 vlan_ip;
170 unsigned short vlan_id; 170 unsigned short vlan_id;
171}; 171};
172 172
@@ -232,7 +232,6 @@ struct bonding {
232 struct list_head bond_list; 232 struct list_head bond_list;
233 struct netdev_hw_addr_list mc_list; 233 struct netdev_hw_addr_list mc_list;
234 int (*xmit_hash_policy)(struct sk_buff *, int); 234 int (*xmit_hash_policy)(struct sk_buff *, int);
235 __be32 master_ip;
236 u16 rr_tx_counter; 235 u16 rr_tx_counter;
237 struct ad_bond_info ad_info; 236 struct ad_bond_info ad_info;
238 struct alb_bond_info alb_info; 237 struct alb_bond_info alb_info;
@@ -378,6 +377,21 @@ static inline bool bond_is_slave_inactive(struct slave *slave)
378 return slave->inactive; 377 return slave->inactive;
379} 378}
380 379
380static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be32 local)
381{
382 struct in_device *in_dev;
383 __be32 addr = 0;
384
385 rcu_read_lock();
386 in_dev = __in_dev_get_rcu(dev);
387
388 if (in_dev)
389 addr = inet_confirm_addr(in_dev, dst, local, RT_SCOPE_HOST);
390
391 rcu_read_unlock();
392 return addr;
393}
394
381struct bond_net; 395struct bond_net;
382 396
383struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); 397struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);