Skip to content

Commit 3121a1e

Browse files
author
Paolo Abeni
committed
Merge branch 'bonding-fix-incorrect-mac-address-setting'
Hangbin Liu says: ==================== bonding: fix incorrect mac address setting The mac address on backup slave should be convert from Solicited-Node Multicast address, not from bonding unicast target address. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents f5d83cf + 9318dc2 commit 3121a1e

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

drivers/net/bonding/bond_options.c

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,10 +1242,28 @@ static bool slave_can_set_ns_maddr(const struct bonding *bond, struct slave *sla
12421242
slave->dev->flags & IFF_MULTICAST;
12431243
}
12441244

1245+
/**
1246+
* slave_set_ns_maddrs - add/del all NS mac addresses for slave
1247+
* @bond: bond device
1248+
* @slave: slave device
1249+
* @add: add or remove all the NS mac addresses
1250+
*
1251+
* This function tries to add or delete all the NS mac addresses on the slave
1252+
*
1253+
* Note, the IPv6 NS target address is the unicast address in Neighbor
1254+
* Solicitation (NS) message. The dest address of NS message should be
1255+
* solicited-node multicast address of the target. The dest mac of NS message
1256+
* is converted from the solicited-node multicast address.
1257+
*
1258+
* This function is called when
1259+
* * arp_validate changes
1260+
* * enslaving, releasing new slaves
1261+
*/
12451262
static void slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add)
12461263
{
12471264
struct in6_addr *targets = bond->params.ns_targets;
12481265
char slot_maddr[MAX_ADDR_LEN];
1266+
struct in6_addr mcaddr;
12491267
int i;
12501268

12511269
if (!slave_can_set_ns_maddr(bond, slave))
@@ -1255,7 +1273,8 @@ static void slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool
12551273
if (ipv6_addr_any(&targets[i]))
12561274
break;
12571275

1258-
if (!ndisc_mc_map(&targets[i], slot_maddr, slave->dev, 0)) {
1276+
addrconf_addr_solict_mult(&targets[i], &mcaddr);
1277+
if (!ndisc_mc_map(&mcaddr, slot_maddr, slave->dev, 0)) {
12591278
if (add)
12601279
dev_mc_add(slave->dev, slot_maddr);
12611280
else
@@ -1278,23 +1297,43 @@ void bond_slave_ns_maddrs_del(struct bonding *bond, struct slave *slave)
12781297
slave_set_ns_maddrs(bond, slave, false);
12791298
}
12801299

1300+
/**
1301+
* slave_set_ns_maddr - set new NS mac address for slave
1302+
* @bond: bond device
1303+
* @slave: slave device
1304+
* @target: the new IPv6 target
1305+
* @slot: the old IPv6 target in the slot
1306+
*
1307+
* This function tries to replace the old mac address to new one on the slave.
1308+
*
1309+
* Note, the target/slot IPv6 address is the unicast address in Neighbor
1310+
* Solicitation (NS) message. The dest address of NS message should be
1311+
* solicited-node multicast address of the target. The dest mac of NS message
1312+
* is converted from the solicited-node multicast address.
1313+
*
1314+
* This function is called when
1315+
* * An IPv6 NS target is added or removed.
1316+
*/
12811317
static void slave_set_ns_maddr(struct bonding *bond, struct slave *slave,
12821318
struct in6_addr *target, struct in6_addr *slot)
12831319
{
1284-
char target_maddr[MAX_ADDR_LEN], slot_maddr[MAX_ADDR_LEN];
1320+
char mac_addr[MAX_ADDR_LEN];
1321+
struct in6_addr mcast_addr;
12851322

12861323
if (!bond->params.arp_validate || !slave_can_set_ns_maddr(bond, slave))
12871324
return;
12881325

1289-
/* remove the previous maddr from slave */
1326+
/* remove the previous mac addr from slave */
1327+
addrconf_addr_solict_mult(slot, &mcast_addr);
12901328
if (!ipv6_addr_any(slot) &&
1291-
!ndisc_mc_map(slot, slot_maddr, slave->dev, 0))
1292-
dev_mc_del(slave->dev, slot_maddr);
1329+
!ndisc_mc_map(&mcast_addr, mac_addr, slave->dev, 0))
1330+
dev_mc_del(slave->dev, mac_addr);
12931331

1294-
/* add new maddr on slave if target is set */
1332+
/* add new mac addr on slave if target is set */
1333+
addrconf_addr_solict_mult(target, &mcast_addr);
12951334
if (!ipv6_addr_any(target) &&
1296-
!ndisc_mc_map(target, target_maddr, slave->dev, 0))
1297-
dev_mc_add(slave->dev, target_maddr);
1335+
!ndisc_mc_map(&mcast_addr, mac_addr, slave->dev, 0))
1336+
dev_mc_add(slave->dev, mac_addr);
12981337
}
12991338

13001339
static void _bond_options_ns_ip6_target_set(struct bonding *bond, int slot,

tools/testing/selftests/drivers/net/bonding/bond_options.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ ALL_TESTS="
1111

1212
lib_dir=$(dirname "$0")
1313
source ${lib_dir}/bond_topo_3d1c.sh
14-
c_maddr="33:33:00:00:00:10"
15-
g_maddr="33:33:00:00:02:54"
14+
c_maddr="33:33:ff:00:00:10"
15+
g_maddr="33:33:ff:00:02:54"
1616

1717
skip_prio()
1818
{

0 commit comments

Comments
 (0)