Skip to content

Commit 05d91cd

Browse files
paulfertserdavem330
authored andcommitted
net/ncsi: use dev_set_mac_address() for Get MC MAC Address handling
Copy of the rationale from 7900713: Change ndo_set_mac_address to dev_set_mac_address because dev_set_mac_address provides a way to notify network layer about MAC change. In other case, services may not aware about MAC change and keep using old one which set from network adapter driver. As example, DHCP client from systemd do not update MAC address without notification from net subsystem which leads to the problem with acquiring the right address from DHCP server. Since dev_set_mac_address requires RTNL lock the operation can not be performed directly in the response handler, see 9e2bbab. The way of selecting the first suitable MAC address from the list is changed, instead of having the driver check it this patch just assumes any valid MAC should be good. Fixes: b8291cf ("net/ncsi: Add NC-SI 1.2 Get MC MAC Address command") Signed-off-by: Paul Fertser <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 15a9013 commit 05d91cd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

net/ncsi/ncsi-rsp.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,14 +1089,12 @@ static int ncsi_rsp_handler_netlink(struct ncsi_request *nr)
10891089
static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr)
10901090
{
10911091
struct ncsi_dev_priv *ndp = nr->ndp;
1092+
struct sockaddr *saddr = &ndp->pending_mac;
10921093
struct net_device *ndev = ndp->ndev.dev;
10931094
struct ncsi_rsp_gmcma_pkt *rsp;
1094-
struct sockaddr saddr;
1095-
int ret = -1;
10961095
int i;
10971096

10981097
rsp = (struct ncsi_rsp_gmcma_pkt *)skb_network_header(nr->rsp);
1099-
saddr.sa_family = ndev->type;
11001098
ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
11011099

11021100
netdev_info(ndev, "NCSI: Received %d provisioned MAC addresses\n",
@@ -1108,20 +1106,20 @@ static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr)
11081106
rsp->addresses[i][4], rsp->addresses[i][5]);
11091107
}
11101108

1109+
saddr->sa_family = ndev->type;
11111110
for (i = 0; i < rsp->address_count; i++) {
1112-
memcpy(saddr.sa_data, &rsp->addresses[i], ETH_ALEN);
1113-
ret = ndev->netdev_ops->ndo_set_mac_address(ndev, &saddr);
1114-
if (ret < 0) {
1111+
if (!is_valid_ether_addr(rsp->addresses[i])) {
11151112
netdev_warn(ndev, "NCSI: Unable to assign %pM to device\n",
1116-
saddr.sa_data);
1113+
rsp->addresses[i]);
11171114
continue;
11181115
}
1119-
netdev_warn(ndev, "NCSI: Set MAC address to %pM\n", saddr.sa_data);
1116+
memcpy(saddr->sa_data, rsp->addresses[i], ETH_ALEN);
1117+
netdev_warn(ndev, "NCSI: Will set MAC address to %pM\n", saddr->sa_data);
11201118
break;
11211119
}
11221120

1123-
ndp->gma_flag = ret == 0;
1124-
return ret;
1121+
ndp->gma_flag = 1;
1122+
return 0;
11251123
}
11261124

11271125
static struct ncsi_rsp_handler {

0 commit comments

Comments
 (0)