]> git.ipfire.org Git - network.git/commitdiff
networkd: Check if Ethernet addresses from config are usable
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Feb 2023 12:10:15 +0000 (12:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Feb 2023 12:10:15 +0000 (12:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/address.h
src/networkd/port.c

index 0885d755d68f3add8062ea3a2a0d6eabd58f7f07..d284a0bb1899081e0e69bb04d8559b74742a2ee2 100644 (file)
@@ -74,4 +74,8 @@ static inline int nw_address_generate(nw_address_t* addr) {
        return 0;
 }
 
+static inline int nw_address_is_multicast(const nw_address_t* addr) {
+       return (addr->ether_addr_octet[0] & NW_ADDRESS_MULTICAST);
+}
+
 #endif /* NETWORKD_ADDRESS_H */
index 4c325924c0806fc3a012cdca68b39f101f51fdba..89f31812b10851f790d91edfe3b6789d44c7d92b 100644 (file)
@@ -85,7 +85,12 @@ static int nw_port_setup_address(struct nw_port* port) {
                goto ERROR;
        }
 
-       // XXX Do we need to check for multicast here?
+       // Check if this address is usable
+       r = nw_address_is_multicast(&port->address);
+       if (r) {
+               DEBUG("Port %s: Multicast bit is set on Ethernet address\n", port->name);
+               goto ERROR;
+       }
 
        return 0;