summaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorVeaceslav Falico2013-06-24 11:49:29 +0200
committerDavid S. Miller2013-06-26 01:58:37 +0200
commit87a7b84b588c2ddbde890890855aef18ec34174e (patch)
tree5c050d6899bcb84d0366dedefbf690e8fbdc3dc1 /drivers/net/bonding/bond_main.c
parentnet: davinci_mdio: gaurd the DT code with IS_ENABLED(CONFIG_OF) (diff)
downloadkernel-qcow2-linux-87a7b84b588c2ddbde890890855aef18ec34174e.tar.gz
kernel-qcow2-linux-87a7b84b588c2ddbde890890855aef18ec34174e.tar.xz
kernel-qcow2-linux-87a7b84b588c2ddbde890890855aef18ec34174e.zip
bonding: add helper function bond_get_targets_ip(targets, ip)
Add function bond_get_targets_ip(targets, ip) which searches through targets array of ips (arp_targets) and returns the position of first match. If ip == 0, returns the first free slot. On failure to find the ip or free slot, return -1. Use it to verify if the arp we've received is valid and in sysfs. v1->v2: Fix "[2/6] bonding: add helper function bond_get_targets_ip(targets, ip)", per Nikolay's advice, to verify if source ip != 0.0.0.0, otherwise we might update 'null' arp_ip_targets' last_rx. Also, address style. Signed-off-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3b31c19972d4..976d28e3498a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2610,19 +2610,16 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip)
{
- int i;
- __be32 *targets = bond->params.arp_targets;
+ if (!sip || !bond_has_this_ip(bond, tip)) {
+ pr_debug("bva: sip %pI4 tip %pI4 not found\n", &sip, &tip);
+ return;
+ }
- for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
- pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
- &sip, &tip, i, &targets[i],
- bond_has_this_ip(bond, tip));
- if (sip == targets[i]) {
- if (bond_has_this_ip(bond, tip))
- slave->last_arp_rx = jiffies;
- return;
- }
+ if (bond_get_targets_ip(bond->params.arp_targets, sip) == -1) {
+ pr_debug("bva: sip %pI4 not found in targets\n", &sip);
+ return;
}
+ slave->last_arp_rx = jiffies;
}
static int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond,
@@ -4839,7 +4836,7 @@ static int __net_init bond_net_init(struct net *net)
bond_create_proc_dir(bn);
bond_create_sysfs(bn);
-
+
return 0;
}