udhcpc6: additional fix for ppp interface type

Invent a fictitious MAC only once

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-01-23 16:46:31 +01:00
parent 66ad9be603
commit 30b290f996

View File

@ -69,8 +69,12 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_
if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) { if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) {
*ifindex = ifr.ifr_ifindex; *ifindex = ifr.ifr_ifindex;
log2("ifindex %d", *ifindex); log2("ifindex %d", *ifindex);
if (((uint32_t*)mac)[0] == 0) {
/* invent a fictitious MAC (once) */
((uint32_t*)mac)[0] = rand(); ((uint32_t*)mac)[0] = rand();
((uint16_t*)mac)[2] = rand(); ((uint16_t*)mac)[2] = rand();
mac[0] &= 0xfc; /* make sure it's not bcast */
}
retval &= (3 - (1<<0)); retval &= (3 - (1<<0));
} }
close(fd); close(fd);