From: Andre Noll Date: Thu, 20 Mar 2025 13:24:55 +0000 (+0100) Subject: Use random mac addresses by default. X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=fadf3c96c515e8002a6f0dd1b0c1c348560bcd33;p=micoforia.git Use random mac addresses by default. --- diff --git a/micoforia.c b/micoforia.c index 9afd269..1b03f92 100644 --- a/micoforia.c +++ b/micoforia.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "micoforia.lsg.h" @@ -368,8 +369,8 @@ static void check_options(void) c->num_ifspecs = 1; c->ifspec = xmalloc(sizeof(struct ifspec)); c->ifspec[0].bridge = xstrdup(br); - memset(c->ifspec[0].hwaddr, 0, 6); - continue; + if (getrandom(c->ifspec[0].hwaddr, 6, 0) < 0) + WARNING_LOG("%s: getrandom error: %m\n", c->name); } } } diff --git a/util.c b/util.c index 08f4832..8ef6181 100644 --- a/util.c +++ b/util.c @@ -646,11 +646,8 @@ bool set_hwaddr(const char *iface, const uint8_t *hwaddr) struct nlmsghdr *nlh; struct ifinfomsg *ifm; bool success; - const uint8_t zero[6] = {0}; char pretty_hwaddr[18]; - if (!memcmp(hwaddr, zero, 6)) - return true; /* no hwaddr specified, nothing to do */ pretty_print_hwaddr(hwaddr, pretty_hwaddr); INFO_LOG("hardware address of %s: %s\n", iface, pretty_hwaddr); if (!(nl = get_and_bind_netlink_socket()))