ClatdController - populate ebpf ingress clat map on start and stop
and also attach/detach tc clsact egress qdisc and filter.
Test: atest netd_unit_test netd_integration_test
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I865403ae320b95cec59659b34a69a4f304e1f082
diff --git a/server/ClatdController.h b/server/ClatdController.h
index cd5ad14..ceebde6 100644
--- a/server/ClatdController.h
+++ b/server/ClatdController.h
@@ -28,6 +28,8 @@
#include "Fwmark.h"
#include "NetdConstants.h"
+#include "bpf/BpfMap.h"
+#include "netdbpf/bpf_shared.h"
#include "netdutils/DumpWriter.h"
namespace android {
@@ -40,6 +42,8 @@
explicit ClatdController(NetworkController* controller);
virtual ~ClatdController();
+ void Init(void);
+
int startClatd(const std::string& interface, const std::string& nat64Prefix,
std::string* v6Addr);
int stopClatd(const std::string& interface);
@@ -80,6 +84,18 @@
in6_addr* v6);
static void makeChecksumNeutral(in6_addr* v6, const in_addr v4, const in6_addr& nat64Prefix);
+ enum eClatEbpfMode {
+ ClatEbpfDisabled, // <4.9 kernel || <P api shipping level -- will not work
+ ClatEbpfMaybe, // >=4.9 kernel && P api shipping level -- might work
+ ClatEbpfEnabled, // >=4.9 kernel && >=Q api shipping level -- must work
+ };
+ eClatEbpfMode mClatEbpfMode;
+ base::unique_fd mNetlinkFd;
+ bpf::BpfMap<ClatIngressKey, ClatIngressValue> mClatIngressMap;
+
+ void maybeStartBpf(const ClatdTracker& tracker);
+ void maybeStopBpf(const ClatdTracker& tracker);
+
// For testing.
friend class ClatdControllerTest;