return 0;
}
+/**
+ * Mangle the MAC address to avoid duplicates.
+ *
+ * With bonds, we have duplicate MAC address on different physical
+ * interfaces. We need to alter the source MAC address when we send on
+ * an inactive slave. We try to set "local" bit to 1 first. If it is
+ * already set to 1, use an unused MAC address instead.
+ */
+static void
+iface_mangle_mac(char *buffer)
+{
+ if (buffer[0] & 2) {
+ /* Already a locally administered MAC address, use a fixed MAC
+ * address (an old 3c905 MAC address of a card that I own). */
+ char arbitrary[] = { 0x00, 0x60, 0x08, 0x69, 0x97, 0xef};
+ memcpy(buffer, arbitrary, sizeof(arbitrary));
+ return;
+ }
+ buffer[0] |= 2;
+}
+
static int
iface_bond_send(struct lldpd *cfg, struct lldpd_hardware *hardware,
char *buffer, size_t size)
{
- /* With bonds, we have duplicate MAC address on different physical
- * interfaces. We need to alter the source MAC address when we send on
- * an inactive slave. To avoid any future problem, we always set the
- * source MAC address to 0. */
log_debug("interfaces", "send PDU to bonded device %s",
hardware->h_ifname);
if (size < 2 * ETHER_ADDR_LEN) {
hardware->h_ifname);
return 0;
}
- memset(buffer + ETHER_ADDR_LEN, 0, ETHER_ADDR_LEN);
+ iface_mangle_mac(buffer + ETHER_ADDR_LEN);
return write(hardware->h_sendfd,
buffer, size);
}