]> git.tuebingen.mpg.de Git - micoforia.git/commitdiff
Use random mac addresses by default.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 20 Mar 2025 13:24:55 +0000 (14:24 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 20 Mar 2025 13:24:55 +0000 (14:24 +0100)
micoforia.c
util.c

index 9afd269c1d5d18c05d6b55d4c47934a0454a2b2a..1b03f92db09b9942b1f548a767be30e853f520a4 100644 (file)
@@ -13,6 +13,7 @@
 #include <sys/socket.h>
 #include <sys/capability.h>
 #include <sys/syscall.h>
+#include <sys/random.h>
 
 #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 08f4832956d5ed1e6003d86b37494bb2a69793e7..8ef618144d9a17a3967f41f30730675831977f96 100644 (file)
--- 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()))