summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-07 18:55:42 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-10 17:26:17 +0200
commitc160c6b035ac86d53860631269d0f614b5f209a9 (patch)
tree9a12b8a9088b8389276d855889b5a1862aa4c21f /Kernel/Net
parenta569381037f4569d288486a48153ef08da1c9473 (diff)
downloadserenity-c160c6b035ac86d53860631269d0f614b5f209a9.zip
Kernel: Use correct destination MAC address for multicast packets
Previously we'd incorrectly use the default gateway's MAC address. Instead we must use destination MAC addresses that are derived from the multicast IPv4 address. With this patch applied I can query mDNS on a real network.
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/Routing.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 28e44057dd..e207cd35f4 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -122,6 +122,11 @@ bool RoutingDecision::is_zero() const
return adapter.is_null() || next_hop.is_zero();
}
+static MACAddress multicast_ethernet_address(IPv4Address const& address)
+{
+ return MACAddress { 0x01, 0x00, 0x5e, (u8)(address[1] & 0x7f), address[2], address[3] };
+}
+
RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, const RefPtr<NetworkAdapter> through)
{
auto matches = [&](auto& adapter) {
@@ -198,6 +203,9 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
if (target_addr == 0xffffffff && matches(adapter))
return { adapter, { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
+ if ((target_addr & IPv4Address { 240, 0, 0, 0 }.to_u32()) == IPv4Address { 224, 0, 0, 0 }.to_u32())
+ return { adapter, multicast_ethernet_address(target) };
+
{
Locker locker(arp_table().lock());
auto addr = arp_table().resource().get(next_hop_ip);