patchpanel: datapath facilities for routing devices
This patch introduces a pair of high level functions in Datapath for
setting up layer 3 routing between a "downstream device" (tethering) or
internal device (container veth device or vm tap device) and an "upstream"
externally facing device (physical device managed by shill, or shill's
logical default network).
For now this pair of functions are equivalent to the inbound and
outbound iptables setup done for ARC virtual devices. Follow-up patches
will add traffic tagging. More iptables setup will be added in follow-up
patches.
There is no functional changes in this patch.
BUG=b:161507671
BUG=b:161508179
TEST=Unit tests. Compiled, flashed rammus, checked ARC++ connectivity.
Change-Id: I27df3c890887451b20c7db11c7a1302d60db6bbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2359935
Tested-by: Hugo Benichi <hugobenichi@google.com>
Commit-Queue: Hugo Benichi <hugobenichi@google.com>
Reviewed-by: Taoyu Li <taoyl@chromium.org>
diff --git a/patchpanel/mock_datapath.h b/patchpanel/mock_datapath.h
index 878a9be..f867bdc 100644
--- a/patchpanel/mock_datapath.h
+++ b/patchpanel/mock_datapath.h
@@ -52,12 +52,19 @@
bool up,
bool multicast));
MOCK_METHOD1(RemoveInterface, void(const std::string& ifname));
- MOCK_METHOD2(AddInboundIPv4DNAT,
- bool(const std::string& ifname, const std::string& ipv4_addr));
- MOCK_METHOD2(RemoveInboundIPv4DNAT,
- void(const std::string& ifname, const std::string& ipv4_addr));
+ MOCK_METHOD4(StartRoutingDevice,
+ void(const std::string& ext_ifname,
+ const std::string& int_ifname,
+ uint32_t int_ipv4_addr,
+ TrafficSource source));
+ MOCK_METHOD4(StopRoutingDevice,
+ void(const std::string& ext_ifname,
+ const std::string& int_ifname,
+ uint32_t int_ipv4_addr,
+ TrafficSource source));
MOCK_METHOD1(AddOutboundIPv4, bool(const std::string& ifname));
MOCK_METHOD1(RemoveOutboundIPv4, void(const std::string& ifname));
+
MOCK_METHOD3(MaskInterfaceFlags,
bool(const std::string& ifname, uint16_t on, uint16_t off));
MOCK_METHOD2(AddIPv6Forwarding,