diff options
author | Casper Andersson <casper.casan@gmail.com> | 2022-08-25 11:28:35 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-08-29 12:57:38 +0100 |
commit | e8013f8edaa30e17fd583a326daff1fa86b75c82 (patch) | |
tree | e88ae3bf54e8bb71b35ed9a9a6bf6d1f12ed7794 /include | |
parent | 9c5d03d362519f36cd551aec596388f895c93d2d (diff) | |
download | linux-stable-e8013f8edaa30e17fd583a326daff1fa86b75c82.tar.gz linux-stable-e8013f8edaa30e17fd583a326daff1fa86b75c82.tar.bz2 linux-stable-e8013f8edaa30e17fd583a326daff1fa86b75c82.zip |
ethernet: Add helpers to recognize addresses mapped to IP multicast
IP multicast must sometimes be discriminated from non-IP multicast,
e.g. when determining the forwarding behavior of a given group in the
presence of multicast router ports on an offloaded bridge. Therefore,
provide helpers to identify these groups.
Signed-off-by: Casper Andersson <casper.casan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/etherdevice.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 92b10e67d5f8..a541f0c4f146 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -428,6 +428,28 @@ static inline bool ether_addr_equal_masked(const u8 *addr1, const u8 *addr2, return true; } +static inline bool ether_addr_is_ipv4_mcast(const u8 *addr) +{ + u8 base[ETH_ALEN] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 }; + u8 mask[ETH_ALEN] = { 0xff, 0xff, 0xff, 0x80, 0x00, 0x00 }; + + return ether_addr_equal_masked(addr, base, mask); +} + +static inline bool ether_addr_is_ipv6_mcast(const u8 *addr) +{ + u8 base[ETH_ALEN] = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 }; + u8 mask[ETH_ALEN] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }; + + return ether_addr_equal_masked(addr, base, mask); +} + +static inline bool ether_addr_is_ip_mcast(const u8 *addr) +{ + return ether_addr_is_ipv4_mcast(addr) || + ether_addr_is_ipv6_mcast(addr); +} + /** * ether_addr_to_u64 - Convert an Ethernet address into a u64 value. * @addr: Pointer to a six-byte array containing the Ethernet address |