Author: kevans
Date: Mon Mar  2 02:45:57 2020
New Revision: 358515
URL: https://svnweb.freebsd.org/changeset/base/358515

Log:
  if_edsc: generate an arbitrary MAC address
  
  When generating an cloned interface instance in edsc_clone_create(),
  generate a MAC address from the FF OUI with ether_gen_addr(). This allows us
  to have unique local-link addresses. Previously, the MAC address was zero.
  
  Submitted by: Neel Chauhan <neel AT neelc DOT org>
  Differential Revision:        https://reviews.freebsd.org/D23842

Modified:
  head/sys/net/if_edsc.c

Modified: head/sys/net/if_edsc.c
==============================================================================
--- head/sys/net/if_edsc.c      Mon Mar  2 02:45:52 2020        (r358514)
+++ head/sys/net/if_edsc.c      Mon Mar  2 02:45:57 2020        (r358515)
@@ -98,7 +98,7 @@ edsc_clone_create(struct if_clone *ifc, int unit, cadd
 {
        struct edsc_softc       *sc;
        struct ifnet            *ifp;
-       static u_char            eaddr[ETHER_ADDR_LEN]; /* 0:0:0:0:0:0 */
+       struct ether_addr       eaddr;
 
        /*
         * Allocate soft and ifnet structures.  Link each to the other.
@@ -149,11 +149,15 @@ edsc_clone_create(struct if_clone *ifc, int unit, cadd
        ifp->if_snd.ifq_maxlen = ifqmaxlen;
 
        /*
+        * Generate an arbitrary MAC address for the cloned interface.
+        */
+       ether_gen_addr(ifp, &eaddr);
+
+       /*
         * Do ifnet initializations common to all Ethernet drivers
         * and attach to the network interface framework.
-        * TODO: Pick a non-zero link level address.
         */
-       ether_ifattach(ifp, eaddr);
+       ether_ifattach(ifp, eaddr.octet);
 
        /*
         * Now we can mark the interface as running, i.e., ready
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to