From f524fb8e614091a4820bce92ab749a67cefd4225 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 13 Nov 2017 23:26:37 +0100 Subject: [PATCH] nic_router: support domain-local IPv4 If an IPv4 packet targets an IP local to the domain it comes from and doesn't target the routers IP of that domain, forward it to all other interfaces of the domain without considering any other routing. Issue #2609 --- repos/os/src/server/nic_router/interface.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index 28d74d2f27..bab38d5723 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -562,6 +562,18 @@ void Interface::_handle_ip(Ethernet_frame ð, Ipv4_packet &ip = *new (eth.data()) Ipv4_packet(eth_size - sizeof(Ethernet_frame)); + /* try handling subnet-local IP packets */ + if (_ip_config().interface.prefix_matches(ip.dst()) && + ip.dst() != _router_ip()) + { + /* + * Packet targets IP local to the domain's subnet and doesn't target + * the router. Thus, forward it to all other interfaces of the domain. + */ + _domain_broadcast(eth, eth_size); + return; + } + /* try to route via transport layer rules */ try { L3_protocol const prot = ip.protocol();