[PPC64] pseries llan: fix MAC address

There was an issue in pseries llan driver, that resulted in the first 2 bytes
of the MAC address getting stripped, and the last 2 being always 0.

In most cases the network interface still worked, despite the MAC being
different of what was specified to QEMU, but when some other host or DHCP
server expected a specific MAC, this would fail.

This change fixes this by shifting right by 2 the local-mac-address read from
device tree, if its length is 6 instead of 8, as observed in QEMU DT, that
always presents a 6 bytes value for this property.

PR:		237471
Reported by:	Alfredo Dal'Ava Junior
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D20843
This commit is contained in:
Leandro Lupori 2019-07-04 12:31:24 +00:00
parent e86b909626
commit 57d0d4a271

View File

@ -157,14 +157,23 @@ llan_attach(device_t dev)
struct llan_softc *sc;
phandle_t node;
int error, i;
ssize_t len;
sc = device_get_softc(dev);
sc->dev = dev;
/* Get firmware properties */
node = ofw_bus_get_node(dev);
OF_getprop(node, "local-mac-address", sc->mac_address,
len = OF_getprop(node, "local-mac-address", sc->mac_address,
sizeof(sc->mac_address));
/* If local-mac-address property has only 6 bytes (ETHER_ADDR_LEN)
* instead of 8 (sizeof(sc->mac_address)), then its value must be
* shifted 2 bytes to the right. */
if (len == ETHER_ADDR_LEN) {
bcopy(sc->mac_address, &sc->mac_address[2], len);
/* Zero out the first 2 bytes. */
bzero(sc->mac_address, 2);
}
OF_getencprop(node, "reg", &sc->unit, sizeof(sc->unit));
mtx_init(&sc->io_lock, "llan", NULL, MTX_DEF);
@ -504,7 +513,7 @@ llan_set_multicast(struct llan_softc *sc)
{
struct ifnet *ifp = sc->ifp;
struct ifmultiaddr *inm;
uint64_t macaddr;
uint64_t macaddr = 0;
mtx_assert(&sc->io_lock, MA_OWNED);