Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2807a9fe authored by Veaceslav Falico's avatar Veaceslav Falico Committed by David S. Miller
Browse files

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: default avatarVeaceslav Falico <vfalico@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 01844098
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -4195,7 +4195,7 @@ static int bond_check_params(struct bond_params *params)
		   catch mistakes */
		   catch mistakes */
		__be32 ip;
		__be32 ip;
		if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) ||
		if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) ||
		    IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) {
		    !bond_is_ip_target_ok(ip)) {
			pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
			pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
				arp_ip_target[i]);
				arp_ip_target[i]);
			arp_interval = 0;
			arp_interval = 0;
+2 −2
Original line number Original line Diff line number Diff line
@@ -942,7 +942,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
	__be32 *targets = bond->params.arp_targets;
	__be32 *targets = bond->params.arp_targets;
	int ind;
	int ind;


	if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) {
	if (!bond_is_ip_target_ok(target)) {
		pr_err("%s: invalid ARP target %pI4 specified for addition\n",
		pr_err("%s: invalid ARP target %pI4 specified for addition\n",
		       bond->dev->name, &target);
		       bond->dev->name, &target);
		return -EINVAL;
		return -EINVAL;
@@ -987,7 +987,7 @@ static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
	unsigned long *targets_rx;
	unsigned long *targets_rx;
	int ind, i;
	int ind, i;


	if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) {
	if (!bond_is_ip_target_ok(target)) {
		pr_err("%s: invalid ARP target %pI4 specified for removal\n",
		pr_err("%s: invalid ARP target %pI4 specified for removal\n",
		       bond->dev->name, &target);
		       bond->dev->name, &target);
		return -EINVAL;
		return -EINVAL;
+5 −3
Original line number Original line Diff line number Diff line
@@ -54,9 +54,6 @@
		     ((slave)->link == BOND_LINK_UP) && \
		     ((slave)->link == BOND_LINK_UP) && \
		     bond_is_active_slave(slave))
		     bond_is_active_slave(slave))


#define IS_IP_TARGET_UNUSABLE_ADDRESS(a)	\
	((htonl(INADDR_BROADCAST) == a) ||	\
	 ipv4_is_zeronet(a))
/*
/*
 * Less bad way to call ioctl from within the kernel; this needs to be
 * Less bad way to call ioctl from within the kernel; this needs to be
 * done some other way to get the call out of interrupt context.
 * 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)
	return bond->params.arp_validate & BOND_ARP_FILTER;
	return bond->params.arp_validate & BOND_ARP_FILTER;
}
}


static inline int bond_is_ip_target_ok(__be32 addr)
{
	return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr);
}

/* Get the oldest arp which we've received on this slave for bond's
/* Get the oldest arp which we've received on this slave for bond's
 * arp_targets.
 * arp_targets.
 */
 */