svn commit: r349723 - head/sys/powerpc/pseries

Leandro Lupori luporl at FreeBSD.org
Thu Jul 4 12:31:26 UTC 2019


Author: luporl
Date: Thu Jul  4 12:31:24 2019
New Revision: 349723
URL: https://svnweb.freebsd.org/changeset/base/349723

Log:
  [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

Modified:
  head/sys/powerpc/pseries/phyp_llan.c

Modified: head/sys/powerpc/pseries/phyp_llan.c
==============================================================================
--- head/sys/powerpc/pseries/phyp_llan.c	Thu Jul  4 10:41:09 2019	(r349722)
+++ head/sys/powerpc/pseries/phyp_llan.c	Thu Jul  4 12:31:24 2019	(r349723)
@@ -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);
 


More information about the svn-src-all mailing list