Skip to content

Commit 21b1702

Browse files
julianwiedmanndavem330
authored andcommitted
s390/qeth: improve fallback to random MAC address
If READ MAC fails to fetch a valid MAC address, allow some more device types (IQD and z/VM OSD) to fall back to a random address. Also use eth_hw_addr_random(), for indicating to userspace that the address type is NET_ADDR_RANDOM. Note that while z/VM has various protection schemes to prohibit custom addresses on its NICs, they are all optional. So we should at least give it a try. Signed-off-by: Julian Wiedmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d7e6ed9 commit 21b1702

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

drivers/s390/net/qeth_l2_main.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
439439
static int qeth_l2_request_initial_mac(struct qeth_card *card)
440440
{
441441
int rc = 0;
442-
char vendor_pre[] = {0x02, 0x00, 0x00};
443442

444443
QETH_DBF_TEXT(SETUP, 2, "l2reqmac");
445444
QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card));
@@ -459,16 +458,20 @@ static int qeth_l2_request_initial_mac(struct qeth_card *card)
459458
card->info.type == QETH_CARD_TYPE_OSX ||
460459
card->info.guestlan) {
461460
rc = qeth_setadpparms_change_macaddr(card);
462-
if (rc) {
463-
QETH_DBF_MESSAGE(2, "couldn't get MAC address on "
464-
"device %s: x%x\n", CARD_BUS_ID(card), rc);
465-
QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc);
466-
return rc;
467-
}
468-
} else {
469-
eth_random_addr(card->dev->dev_addr);
470-
memcpy(card->dev->dev_addr, vendor_pre, 3);
461+
if (!rc)
462+
goto out;
463+
QETH_DBF_MESSAGE(2, "READ_MAC Assist failed on device %s: x%x\n",
464+
CARD_BUS_ID(card), rc);
465+
QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc);
466+
/* fall back once more: */
471467
}
468+
469+
/* some devices don't support a custom MAC address: */
470+
if (card->info.type == QETH_CARD_TYPE_OSM ||
471+
card->info.type == QETH_CARD_TYPE_OSX)
472+
return (rc) ? rc : -EADDRNOTAVAIL;
473+
eth_hw_addr_random(card->dev);
474+
472475
out:
473476
QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, card->dev->addr_len);
474477
return 0;

0 commit comments

Comments
 (0)