summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2013-07-24 04:24:21 +0000
committermarcel <marcel@FreeBSD.org>2013-07-24 04:24:21 +0000
commit4ca16da195c36ede5b081eb06be9cf18b7025fc4 (patch)
tree5a9b936ca0a1586a327a35bf012dd92454f71b1c /sys/net
parent512fdf0a5e5fc67140a2137d3923a289e4a06d1f (diff)
downloadFreeBSD-src-4ca16da195c36ede5b081eb06be9cf18b7025fc4.zip
FreeBSD-src-4ca16da195c36ede5b081eb06be9cf18b7025fc4.tar.gz
Decouple the UUID generator from network interfaces by having MAC
addresses added to the UUID generator using uuid_ether_add(). The UUID generator keeps an arbitrary number of MAC addresses, under the assumption that they are rarely removed (= uuid_ether_del()). This achieves the following: 1. It brings up closer to having the network stack as a loadable module. 2. It allows the UUID generator to filter MAC addresses for best results (= highest chance of uniqeness). 3. MAC addresses can come from anywhere, irrespactive of whether it's used for an interface or not. A side-effect of the change is that when no MAC addresses have been added, a random multicast MAC address is created once and re-used if needed. Previusly, when a random MAC address was needed, it was created for every call. Thus, a change in behaviour is introduced for when no MAC addresses exist. Obtained from: Juniper Networks, Inc.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_ethersubr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 3fd6c9d..4f9672d 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -48,6 +48,7 @@
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
+#include <sys/uuid.h>
#include <net/if.h>
#include <net/if_arp.h>
@@ -926,6 +927,8 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
break;
if (i != ifp->if_addrlen)
if_printf(ifp, "Ethernet address: %6D\n", lla, ":");
+
+ uuid_ether_add(LLADDR(sdl));
}
/*
@@ -934,6 +937,11 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
void
ether_ifdetach(struct ifnet *ifp)
{
+ struct sockaddr_dl *sdl;
+
+ sdl = (struct sockaddr_dl *)(ifp->if_addr->ifa_addr);
+ uuid_ether_del(LLADDR(sdl));
+
if (IFP2AC(ifp)->ac_netgraph != NULL) {
KASSERT(ng_ether_detach_p != NULL,
("ng_ether_detach_p is NULL"));
OpenPOWER on IntegriCloud