From 072afcdffca7de7416bf71f82a9b5bcc869afad2 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 2 Mar 2020 02:45:57 +0000 Subject: [PATCH] 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 Differential Revision: https://reviews.freebsd.org/D23842 --- sys/net/if_edsc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/net/if_edsc.c b/sys/net/if_edsc.c index 4e262a64991..85a8e8cca2d 100644 --- a/sys/net/if_edsc.c +++ b/sys/net/if_edsc.c @@ -98,7 +98,7 @@ edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params) { 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. @@ -148,12 +148,16 @@ edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params) */ 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