bond_arp_send_all() will pass the vlan tags supplied by
the user to bond_arp_send(). If vlan tags have not been
supplied the vlans in the path to the target will be
discovered by bond_verify_device_path().

bond_uninit() is also updated to free vlan tags when a
bond is destroyed.

Signed-off-by: David Wilder <[email protected]>
---
 drivers/net/bonding/bond_main.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3f35303b4920..9817be7c3c5b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3064,18 +3064,21 @@ struct bond_vlan_tag *bond_verify_device_path(struct 
net_device *start_dev,
 
 static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 {
-       struct rtable *rt;
-       struct bond_vlan_tag *tags;
        struct bond_arp_target *targets = bond->params.arp_targets;
+       char pbuf[BOND_OPTION_STRING_MAX_SIZE];
+       struct bond_vlan_tag *tags;
        __be32 target_ip, addr;
+       struct rtable *rt;
+       u32 flags;
        int i;
 
        for (i = 0; i < BOND_MAX_ARP_TARGETS && targets[i].target_ip; i++) {
                target_ip = targets[i].target_ip;
                tags = targets[i].tags;
+               flags = targets[i].flags;
 
-               slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n",
-                         __func__, &target_ip);
+               slave_dbg(bond->dev, slave->dev, "%s: target %s\n", __func__,
+                         bond_arp_target_to_string(&targets[i], pbuf, 
sizeof(pbuf)));
 
                /* Find out through which dev should the packet go */
                rt = ip_route_output(dev_net(bond->dev), target_ip, 0, 0, 0,
@@ -3097,9 +3100,11 @@ static void bond_arp_send_all(struct bonding *bond, 
struct slave *slave)
                if (rt->dst.dev == bond->dev)
                        goto found;
 
-               rcu_read_lock();
-               tags = bond_verify_device_path(bond->dev, rt->dst.dev, 0);
-               rcu_read_unlock();
+               if (!(flags & BOND_TARGET_USERTAGS)) {
+                       rcu_read_lock();
+                       tags = bond_verify_device_path(bond->dev, rt->dst.dev, 
0);
+                       rcu_read_unlock();
+               }
 
                if (!IS_ERR_OR_NULL(tags))
                        goto found;
@@ -3115,7 +3120,8 @@ static void bond_arp_send_all(struct bonding *bond, 
struct slave *slave)
                addr = bond_confirm_addr(rt->dst.dev, target_ip, 0);
                ip_rt_put(rt);
                bond_arp_send(slave, ARPOP_REQUEST, target_ip, addr, tags);
-               kfree(tags);
+               if (!(flags & BOND_TARGET_USERTAGS))
+                       kfree(tags);
        }
 }
 
@@ -6047,6 +6053,7 @@ static void bond_uninit(struct net_device *bond_dev)
        bond_for_each_slave(bond, slave, iter)
                __bond_release_one(bond_dev, slave->dev, true, true);
        netdev_info(bond_dev, "Released all slaves\n");
+       bond_free_vlan_tags(bond->params.arp_targets);
 
 #ifdef CONFIG_XFRM_OFFLOAD
        mutex_destroy(&bond->ipsec_lock);
-- 
2.50.1


Reply via email to