diff options
author | Veaceslav Falico <vfalico@gmail.com> | 2014-05-15 15:39:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-16 16:34:32 -0400 |
commit | 2807a9feb2393648f4db114fdf3fa99860ff6a36 (patch) | |
tree | 90a3995c88e73f5fc82ccf339d25676e3aa5def9 | |
parent | 01844098ecd9564cd5f903e3ff6c1ea96355772d (diff) |
bonding: make IS_IP_TARGET_UNUSABLE_ADDRESS an inline function
Also, use standard IP primitives to check the address.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_main.c | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 4 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 8 |
3 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 744c47111045..1af2be53ebb5 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4195,7 +4195,7 @@ static int bond_check_params(struct bond_params *params) | |||
4195 | catch mistakes */ | 4195 | catch mistakes */ |
4196 | __be32 ip; | 4196 | __be32 ip; |
4197 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || | 4197 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || |
4198 | IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) { | 4198 | !bond_is_ip_target_ok(ip)) { |
4199 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", | 4199 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", |
4200 | arp_ip_target[i]); | 4200 | arp_ip_target[i]); |
4201 | arp_interval = 0; | 4201 | arp_interval = 0; |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index dd7292fa4665..0cf4c1a9bb7b 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -942,7 +942,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) | |||
942 | __be32 *targets = bond->params.arp_targets; | 942 | __be32 *targets = bond->params.arp_targets; |
943 | int ind; | 943 | int ind; |
944 | 944 | ||
945 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | 945 | if (!bond_is_ip_target_ok(target)) { |
946 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", | 946 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", |
947 | bond->dev->name, &target); | 947 | bond->dev->name, &target); |
948 | return -EINVAL; | 948 | return -EINVAL; |
@@ -987,7 +987,7 @@ static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) | |||
987 | unsigned long *targets_rx; | 987 | unsigned long *targets_rx; |
988 | int ind, i; | 988 | int ind, i; |
989 | 989 | ||
990 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | 990 | if (!bond_is_ip_target_ok(target)) { |
991 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", | 991 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", |
992 | bond->dev->name, &target); | 992 | bond->dev->name, &target); |
993 | return -EINVAL; | 993 | return -EINVAL; |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index bb663a4db137..ac75b0fbf768 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -54,9 +54,6 @@ | |||
54 | ((slave)->link == BOND_LINK_UP) && \ | 54 | ((slave)->link == BOND_LINK_UP) && \ |
55 | bond_is_active_slave(slave)) | 55 | bond_is_active_slave(slave)) |
56 | 56 | ||
57 | #define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \ | ||
58 | ((htonl(INADDR_BROADCAST) == a) || \ | ||
59 | ipv4_is_zeronet(a)) | ||
60 | /* | 57 | /* |
61 | * Less bad way to call ioctl from within the kernel; this needs to be | 58 | * Less bad way to call ioctl from within the kernel; this needs to be |
62 | * done some other way to get the call out of interrupt context. | 59 | * done some other way to get the call out of interrupt context. |
@@ -406,6 +403,11 @@ static inline int slave_do_arp_validate_only(struct bonding *bond) | |||
406 | return bond->params.arp_validate & BOND_ARP_FILTER; | 403 | return bond->params.arp_validate & BOND_ARP_FILTER; |
407 | } | 404 | } |
408 | 405 | ||
406 | static inline int bond_is_ip_target_ok(__be32 addr) | ||
407 | { | ||
408 | return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr); | ||
409 | } | ||
410 | |||
409 | /* Get the oldest arp which we've received on this slave for bond's | 411 | /* Get the oldest arp which we've received on this slave for bond's |
410 | * arp_targets. | 412 | * arp_targets. |
411 | */ | 413 | */ |