main.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. #include <iostream>
  2. #include <phpcpp.h>
  3. #include <fstream>
  4. #include "bcc_common.h"
  5. #include "bpf_module.h"
  6. #include "libbpf.h"
  7. #include "BPF.h"
  8. #include <csignal>
  9. #include <atomic>
  10. #include <sstream>
  11. #include <utility>
  12. #include <vector>
  13. #include "table.cpp"
  14. constexpr const char *TRACE_PIPE_PATH = "/sys/kernel/debug/tracing/trace_pipe";
  15. // Php::out << "Value of fn: " << fnn << std::endl;
  16. const std::vector<std::string> syscall_prefixes = {
  17. "sys_",
  18. "__x64_sys_",
  19. "__x32_compat_sys_",
  20. "__ia32_compat_sys_",
  21. "__arm64_sys_",
  22. "__s390x_sys_",
  23. "__s390_sys_",
  24. "__riscv_sys_"
  25. };
  26. class EbpfExtension : public Php::Base {
  27. private:
  28. ebpf::BPF bpf;
  29. void *mod;
  30. Php::Object _perf_event;
  31. PerfEventArrayTable *_class_perf_event;
  32. static std::string add_prefix(const std::string &prefix, const std::string &name) {
  33. if (name.rfind(prefix, 0) != 0) {
  34. return prefix + name;
  35. }
  36. return name;
  37. }
  38. std::string fix_syscall_fnname(const std::string &name) {
  39. for (const auto &prefix: syscall_prefixes) {
  40. if (name.rfind(prefix, 0) == 0) {
  41. return bpf.get_syscall_fnname(name.substr(prefix.length()));
  42. }
  43. }
  44. return name;
  45. }
  46. void _trace_autoload() {
  47. size_t num_funcs = bpf.get_num_functions();
  48. for (size_t i = 0; i < num_funcs; i++) {
  49. const char *func_name = bpf.get_function_name(i);
  50. std::string fn_name(func_name);
  51. if (fn_name.rfind("kprobe__", 0) == 0) {
  52. std::string kernel_func = fix_syscall_fnname(fn_name.substr(8));
  53. bpf.attach_kprobe(kernel_func, fn_name);
  54. } else if (fn_name.rfind("kretprobe__", 0) == 0) {
  55. std::string kernel_func = fix_syscall_fnname(fn_name.substr(11));
  56. bpf.attach_kprobe(kernel_func, fn_name, 0, BPF_PROBE_RETURN);
  57. } else if (fn_name.rfind("tracepoint__", 0) == 0) {
  58. std::string tp_name = fn_name.substr(12);
  59. std::replace(tp_name.begin(), tp_name.end(), '_', ':');
  60. bpf.attach_tracepoint(tp_name, fn_name);
  61. } else if (fn_name.rfind("raw_tracepoint__", 0) == 0) {
  62. std::string tp_name = fn_name.substr(16);
  63. bpf.attach_raw_tracepoint(tp_name, fn_name);
  64. } else if (fn_name.rfind("kfunc__", 0) == 0) {
  65. fn_name = add_prefix("kfunc__", fn_name);
  66. attach_kfunc(fn_name);
  67. } else if (fn_name.rfind("kretfunc__", 0) == 0) {
  68. fn_name = add_prefix("kretfunc__", fn_name);
  69. attach_kfunc(fn_name);
  70. } else if (fn_name.rfind("lsm__", 0) == 0) {
  71. fn_name = add_prefix("lsm__", fn_name);
  72. attach_lsm(fn_name);
  73. }
  74. }
  75. }
  76. public:
  77. EbpfExtension() = default;
  78. virtual ~EbpfExtension() = default;
  79. Php::Value __get(const Php::Value &name) {
  80. int from_attr = 1;
  81. auto res = get_table_cls(name, from_attr); // 这里传递 std::vector<Php::Value>
  82. if (!res.isObject()) {
  83. return Php::Base::__get(name);
  84. } else {
  85. return res;
  86. }
  87. // printf("111111111\n");
  88. // if (name == "events") return _perf_event;
  89. //
  90. // auto a = new PerfEventArrayTable;
  91. // a->getMessage();
  92. //
  93. }
  94. void php_test(Php::Parameters &params) {
  95. int ty = bpf_table_type(this->mod, "counters");
  96. Php::out << "counters type]" << ty << std::endl;
  97. int ty2 = bpf_table_type(this->mod, "events");
  98. Php::out << "events type]" << ty2 << std::endl;
  99. // bpf.get_map_in_map_table<int>("").get_fd();
  100. // auto aaa = bpf.table<>()("counters");
  101. // aaa.get_value(0, reinterpret_cast<std::string &>(val));
  102. //
  103. // auto control_table_hdl = bpf.get_array_table<uint64_t>("counters");
  104. // auto res1 = control_table_hdl.get_value(1, val);
  105. // Php::out<< "ok]" <<res1.ok() <<std::endl;
  106. // Php::out<< "msg]" << res1.msg() <<std::endl;
  107. // Php::out <<"val]" << val <<std::endl;
  108. }
  109. void __construct(Php::Parameters &params) {
  110. std::string bpf_code = params[0].stringValue();
  111. auto init_res = bpf.init(bpf_code);
  112. if (!init_res.ok()) {
  113. throw Php::Exception("init error: " + init_res.msg());
  114. }
  115. this->mod = (void *) bpf.get_mod();
  116. _trace_autoload();
  117. }
  118. ebpf::StatusTuple attach_kfunc(const std::string &kfn) {
  119. int probe_fd;
  120. auto fn = bpf.load_func(kfn, BPF_PROG_TYPE_TRACING, probe_fd);
  121. int res_fd = bpf_attach_kfunc(probe_fd);
  122. if (res_fd < 0) {
  123. TRY2(bpf.unload_func(kfn));
  124. return ebpf::StatusTuple(-1, "Unable to attach kfunc using %s",
  125. kfn.c_str());
  126. }
  127. return ebpf::StatusTuple::OK();
  128. }
  129. ebpf::StatusTuple attach_lsm(const std::string &lsm) {
  130. int probe_fd;
  131. auto fn = bpf.load_func(lsm, BPF_PROG_TYPE_LSM, probe_fd);
  132. int res_fd = bpf_attach_lsm(probe_fd);
  133. if (res_fd < 0) {
  134. TRY2(bpf.unload_func(lsm));
  135. return ebpf::StatusTuple(-1, "Unable to attach lsm using %s",
  136. lsm.c_str());
  137. }
  138. return ebpf::StatusTuple::OK();
  139. }
  140. void php_attach_kprobe(Php::Parameters &params) {
  141. std::string kernel_func = params[0].stringValue();
  142. std::string probe_func = params[1].stringValue();
  143. auto attach_res = bpf.attach_kprobe(kernel_func, probe_func);
  144. if (!attach_res.ok()) {
  145. throw Php::Exception("attach error: " + attach_res.msg());
  146. }
  147. }
  148. void php_attach_tracepoint(Php::Parameters &params) {
  149. std::string tp_func = params[0].stringValue();
  150. std::string probe_func = params[1].stringValue();
  151. auto attach_res = bpf.attach_tracepoint(tp_func, probe_func);
  152. if (!attach_res.ok()) {
  153. throw Php::Exception("attach error: " + attach_res.msg());
  154. }
  155. }
  156. void php_attach_raw_tracepoint(Php::Parameters &params) {
  157. std::string tp_func = params[0].stringValue();
  158. std::string probe_func = params[1].stringValue();
  159. auto attach_res = bpf.attach_raw_tracepoint(tp_func, probe_func);
  160. if (!attach_res.ok()) {
  161. throw Php::Exception("attach error: " + attach_res.msg());
  162. }
  163. }
  164. void php_attach_kfunc(Php::Parameters &params) {
  165. std::string kfunc = params[0].stringValue();
  166. auto attach_res = attach_kfunc(kfunc);
  167. if (!attach_res.ok()) {
  168. throw Php::Exception("attach error: " + attach_res.msg());
  169. }
  170. }
  171. void php_attach_lsm(Php::Parameters &params) {
  172. std::string kfunc = params[0].stringValue();
  173. auto attach_res = attach_lsm(kfunc);
  174. if (!attach_res.ok()) {
  175. throw Php::Exception("attach error: " + attach_res.msg());
  176. }
  177. }
  178. void php_attach_uprobe(Php::Parameters &params) {
  179. std::string binary_path = params[0].stringValue();
  180. std::string symbol = params[1].stringValue();
  181. std::string probe_func = params[2].stringValue();
  182. int64_t symbol_addr = 0, symbol_offset = 0, pid_param;
  183. uint32_t ref_ctr_offset = 0;
  184. pid_t pid = -1;
  185. if (params.size() > 3) {
  186. Php::Value options = params[3];
  187. symbol_addr = options.get("symbol_addr").numericValue();
  188. symbol_offset = options.get("symbol_offset").numericValue();
  189. ref_ctr_offset = options.get("ref_ctr_offset").numericValue();
  190. pid_param = options.get("pid").numericValue();
  191. if (pid_param > 0) {
  192. pid = static_cast<pid_t>(pid_param);
  193. }
  194. }
  195. auto attach_res = bpf.attach_uprobe(binary_path, symbol, probe_func, symbol_addr, BPF_PROBE_ENTRY, pid,
  196. symbol_offset, ref_ctr_offset);
  197. if (!attach_res.ok()) {
  198. throw Php::Exception("attach error: " + attach_res.msg());
  199. }
  200. }
  201. void php_detach_kprobe(Php::Parameters &params) {
  202. std::string fn = params[0].stringValue();
  203. auto detach_res = bpf.detach_kprobe(fn);
  204. if (!detach_res.ok()) {
  205. throw Php::Exception("detach_kprobe error: " + detach_res.msg());
  206. }
  207. }
  208. void php_detach_uprobe(Php::Parameters &params) {
  209. std::string binary_path = params[0].stringValue();
  210. std::string symbol = params[1].stringValue();
  211. int64_t symbol_addr = 0, symbol_offset = 0, pid_param;
  212. pid_t pid = -1;
  213. if (params.size() > 2) {
  214. Php::Value options = params[2];
  215. symbol_addr = options.get("symbol_addr").numericValue();
  216. symbol_offset = options.get("symbol_offset").numericValue();
  217. pid_param = options.get("pid").numericValue();
  218. if (pid_param > 0) {
  219. pid = static_cast<pid_t>(pid_param);
  220. }
  221. }
  222. auto detach_res = bpf.detach_uprobe(binary_path, symbol, symbol_addr, BPF_PROBE_ENTRY, pid, symbol_offset);
  223. if (!detach_res.ok()) {
  224. throw Php::Exception("detach_kprobe error: " + detach_res.msg());
  225. }
  226. }
  227. [[noreturn]] static void php_trace_print() {
  228. std::ifstream pipe(TRACE_PIPE_PATH);
  229. std::string line;
  230. if (!pipe.is_open()) {
  231. throw Php::Exception("Failed to open trace_pipe");
  232. }
  233. std::cout << "Press Ctrl+C to stop..." << std::endl;
  234. while (true) {
  235. if (std::getline(pipe, line)) {
  236. std::cout << line << std::endl;
  237. }
  238. }
  239. }
  240. static Php::Value php_trace_fields(Php::Parameters &params) {
  241. std::ifstream traceFile(TRACE_PIPE_PATH);
  242. if (!traceFile.is_open()) {
  243. throw Php::Exception("Failed to open trace_pipe");
  244. }
  245. std::string line;
  246. while (std::getline(traceFile, line)) {
  247. if (line.empty()) {
  248. continue;
  249. }
  250. if (line.rfind("CPU:", 0) == 0) {
  251. continue;
  252. }
  253. std::string task = line.substr(0, 16);
  254. task.erase(0, task.find_first_not_of(" "));
  255. std::istringstream iss(line.substr(17));
  256. std::string pid, cpu, flags, ts, msg;
  257. char delim;
  258. if (!(iss >> pid >> delim >> cpu >> delim >> flags >> ts)) {
  259. continue;
  260. }
  261. size_t sym_end = iss.str().find(": ", iss.tellg());
  262. if (sym_end != std::string::npos) {
  263. msg = iss.str().substr(sym_end + 2);
  264. }
  265. Php::Array result;
  266. result[0] = task;
  267. result[1] = std::stoi(pid);
  268. result[2] = std::stoi(cpu.substr(1, cpu.size() - 2)); // 去掉方括号
  269. result[3] = flags;
  270. result[4] = std::stod(ts);
  271. result[5] = msg;
  272. return result;
  273. }
  274. return Php::Value();
  275. }
  276. Php::Value php_perf_event(Php::Parameters &params) {
  277. std::string event_name = params[0].stringValue(); // Get event_name from the parameters
  278. this->_class_perf_event = new PerfEventArrayTable(&this->bpf, event_name);
  279. return Php::Object("PerfEventArrayTable", this->_class_perf_event);
  280. }
  281. Php::Value get_table_cls(const char *table_name, int from_attr) {
  282. int ttype = bpf_table_type(this->mod, table_name);
  283. switch (ttype) {
  284. case BPF_MAP_TYPE_HASH:
  285. return Php::Object("HashTable", new HashTable(&this->bpf, table_name));
  286. case BPF_MAP_TYPE_ARRAY:
  287. return Php::Object("ArrayTable", new ArrayTable(&this->bpf, table_name));
  288. case BPF_MAP_TYPE_PROG_ARRAY:
  289. return Php::Object("ProgArrayTable", new ProgArrayTable(&this->bpf, table_name));
  290. case BPF_MAP_TYPE_PERF_EVENT_ARRAY:
  291. this->_class_perf_event = new PerfEventArrayTable(&this->bpf, table_name);
  292. return Php::Object("PerfEventArrayTable", this->_class_perf_event);
  293. case BPF_MAP_TYPE_PERCPU_HASH:
  294. return Php::Object("PerCpuHashTable", new PerCpuHashTable(&this->bpf, table_name));
  295. case BPF_MAP_TYPE_PERCPU_ARRAY:
  296. return Php::Object("PerCpuArrayTable", new PerCpuArrayTable(&this->bpf, table_name));
  297. case BPF_MAP_TYPE_LPM_TRIE:
  298. return Php::Object("LpmTrieTable", new LpmTrieTable(&this->bpf, table_name));
  299. case BPF_MAP_TYPE_STACK_TRACE:
  300. return Php::Object("StackTraceTable", new StackTraceTable(&this->bpf, table_name));
  301. case BPF_MAP_TYPE_LRU_HASH:
  302. return Php::Object("LruHashTable", new LruHashTable(&this->bpf, table_name));
  303. case BPF_MAP_TYPE_LRU_PERCPU_HASH:
  304. return Php::Object("LruPerCpuHashTable", new LruPerCpuHashTable(&this->bpf, table_name));
  305. case BPF_MAP_TYPE_CGROUP_ARRAY:
  306. return Php::Object("CgroupArrayTable", new CgroupArrayTable(&this->bpf, table_name));
  307. case BPF_MAP_TYPE_DEVMAP:
  308. return Php::Object("DevMapTable", new DevMapTable(&this->bpf, table_name));
  309. case BPF_MAP_TYPE_CPUMAP:
  310. return Php::Object("CpuMapTable", new CpuMapTable(&this->bpf, table_name));
  311. case BPF_MAP_TYPE_XSKMAP:
  312. return Php::Object("XskMapTable", new XskMapTable(&this->bpf, table_name));
  313. case BPF_MAP_TYPE_ARRAY_OF_MAPS:
  314. return Php::Object("MapInMapArrayTable", new MapInMapArrayTable(&this->bpf, table_name));
  315. case BPF_MAP_TYPE_HASH_OF_MAPS:
  316. return Php::Object("MapInMapHashTable", new MapInMapHashTable(&this->bpf, table_name));
  317. case BPF_MAP_TYPE_QUEUE:
  318. case BPF_MAP_TYPE_STACK:
  319. return Php::Object("QueueStackTable", new QueueStackTable(&this->bpf, table_name));
  320. case BPF_MAP_TYPE_RINGBUF:
  321. return Php::Object("RingBufTable", new RingBufTable(&this->bpf, table_name));
  322. default:
  323. if (from_attr) {
  324. return ttype;
  325. }
  326. throw Php::Exception("Unknown table type " + std::to_string(ttype));
  327. }
  328. }
  329. Php::Value php_table(Php::Parameters &params) {
  330. std::string table_name = params[0].stringValue(); // Get event_name from the parameters
  331. int from_fn = 0;
  332. return get_table_cls(table_name.c_str(), from_fn);
  333. // this->_class_perf_event = new PerfEventArrayTable(&this->bpf, table_name);
  334. // return Php::Object("PerfEventArrayTable", this->_class_perf_event);
  335. }
  336. void php_perf_buffer_poll(Php::Parameters &params) {
  337. if (!this->_class_perf_event) {
  338. throw Php::Exception("perf event is null.");
  339. }
  340. int timeout_ms = -1;
  341. int res = this->_class_perf_event->perf_buffer_poll(timeout_ms);
  342. if (res < 0) {
  343. throw Php::Exception("perf buffer poll error.");
  344. }
  345. }
  346. Php::Value php_get_syscall_fnname(Php::Parameters &params) {
  347. std::string name = params[0].stringValue();
  348. return bpf.get_syscall_fnname(name);
  349. }
  350. };
  351. std::string sanitize_str(std::string str, bool (*validator)(char),
  352. char replacement = '_') {
  353. for (size_t i = 0; i < str.length(); i++)
  354. if (!validator(str[i]))
  355. str[i] = replacement;
  356. return str;
  357. }
  358. std::string attach_type_prefix(bpf_probe_attach_type type) {
  359. switch (type) {
  360. case BPF_PROBE_ENTRY:
  361. return "p";
  362. case BPF_PROBE_RETURN:
  363. return "r";
  364. }
  365. return "ERROR";
  366. }
  367. static bool kprobe_event_validator(char c) {
  368. return (c != '+') && (c != '.');
  369. }
  370. std::string get_kprobe_event(const std::string &kernel_func,
  371. bpf_probe_attach_type type) {
  372. std::string res = attach_type_prefix(type) + "_";
  373. res += sanitize_str(kernel_func, &kprobe_event_validator);
  374. return res;
  375. }
  376. extern "C" {
  377. PHPCPP_EXPORT void *get_module() {
  378. static Php::Extension extension("ebpf", "1.0.0");
  379. Php::Class<EbpfExtension> ebpf_class("Ebpf");
  380. ebpf_class.method<&EbpfExtension::php_trace_print>("trace_print");
  381. ebpf_class.method<&EbpfExtension::php_trace_fields>("trace_fields");
  382. ebpf_class.method<&EbpfExtension::__construct>("__construct", {
  383. Php::ByVal("bpf_code", Php::Type::String)
  384. });
  385. ebpf_class.method<&EbpfExtension::php_attach_kprobe>("attach_kprobe", {
  386. Php::ByVal("kernel_func", Php::Type::String),
  387. Php::ByVal("probe_func", Php::Type::String)
  388. });
  389. ebpf_class.method<&EbpfExtension::php_attach_tracepoint>("attach_tracepoint", {
  390. Php::ByVal("tp", Php::Type::String),
  391. Php::ByVal("probe_func", Php::Type::String)
  392. });
  393. ebpf_class.method<&EbpfExtension::php_attach_raw_tracepoint>("attach_raw_tracepoint", {
  394. Php::ByVal("tp", Php::Type::String),
  395. Php::ByVal("probe_func", Php::Type::String)
  396. });
  397. ebpf_class.method<&EbpfExtension::php_attach_kfunc>("attach_kfunc", {
  398. Php::ByVal("kfn", Php::Type::String),
  399. });
  400. ebpf_class.method<&EbpfExtension::php_attach_lsm>("attach_lsm", {
  401. Php::ByVal("lsm", Php::Type::String),
  402. });
  403. ebpf_class.method<&EbpfExtension::php_attach_uprobe>("attach_uprobe", {
  404. Php::ByVal("binary_path", Php::Type::String),
  405. Php::ByVal("symbol", Php::Type::String),
  406. Php::ByVal("probe_func", Php::Type::String),
  407. Php::ByVal("options", Php::Type::Array, false),
  408. });
  409. // ebpf_class.method<&EbpfExtension::php_open_perf_buffer>("open_perf_buffer", {
  410. // Php::ByVal("callback", Php::Type::Callable),
  411. // });
  412. ebpf_class.method<&EbpfExtension::php_perf_event>("perf_event", {
  413. Php::ByVal("ev_name", Php::Type::String),
  414. });
  415. ebpf_class.method<&EbpfExtension::php_table>("table", {
  416. Php::ByVal("tb_name", Php::Type::String),
  417. });
  418. ebpf_class.method<&EbpfExtension::php_perf_buffer_poll>("perf_buffer_poll", {});
  419. ebpf_class.method<&EbpfExtension::php_get_syscall_fnname>("get_syscall_fnname", {
  420. Php::ByVal("name", Php::Type::String),
  421. });
  422. /*detach*/
  423. ebpf_class.method<&EbpfExtension::php_detach_kprobe>("detach_kprobe", {
  424. Php::ByVal("kernel_func", Php::Type::String),
  425. });
  426. ebpf_class.method<&EbpfExtension::php_detach_uprobe>("detach_uprobe", {
  427. Php::ByVal("binary_path", Php::Type::String),
  428. Php::ByVal("symbol", Php::Type::String),
  429. Php::ByVal("options", Php::Type::Array, false),
  430. });
  431. ebpf_class.method<&EbpfExtension::php_test>("test", {});
  432. extension.add(std::move(ebpf_class));
  433. /*HashTable*/
  434. Php::Class<HashTable> ebpf_hashtable_cls("HashTable");
  435. /*ArrayTable*/
  436. Php::Class<ArrayTable> ebpf_array_table_cls("ArrayTable");
  437. ebpf_array_table_cls.method<&ArrayTable::Value>("value", {
  438. Php::ByVal("i", Php::Type::Numeric),
  439. });
  440. /*ProgArrayTable*/
  441. Php::Class<ProgArrayTable> ebpf_prog_array_table_cls("ProgArrayTable");
  442. /*PerfEventArrayTable*/
  443. Php::Class<PerfEventArrayTable> ebpf_perf_event_class("PerfEventArrayTable");
  444. ebpf_perf_event_class.method<&PerfEventArrayTable::php_open_perf_buffer>("open_perf_buffer", {
  445. Php::ByVal("callback", Php::Type::Callable),
  446. });
  447. /*PerCpuHashTable*/
  448. Php::Class<PerCpuHashTable> ebpf_percpuhash_table_cls("PerCpuHashTable");
  449. /*PerCpuArrayTable*/
  450. Php::Class<PerCpuArrayTable> ebpf_percpuarray_table_cls("PerCpuArrayTable");
  451. /*LpmTrieTable*/
  452. Php::Class<LpmTrieTable> ebpf_lpmtrie_table_cls("LpmTrieTable");
  453. /*StackTraceTable*/
  454. Php::Class<StackTraceTable> ebpf_stack_trace_table_cls("StackTraceTable");
  455. /*LruHashTable*/
  456. Php::Class<LruHashTable> ebpf_lruhash_table_cls("LruHashTable");
  457. /*LruPerCpuHashTable*/
  458. Php::Class<LruPerCpuHashTable> ebpf_lruper_cpuhash_table_cls("LruPerCpuHashTable");
  459. /*CgroupArrayTable*/
  460. Php::Class<CgroupArrayTable> ebpf_cgroup_array_table_cls("CgroupArrayTable");
  461. /*DevMapTable*/
  462. Php::Class<DevMapTable> ebpf_devmap_table_cls("DevMapTable");
  463. /*CpuMapTable*/
  464. Php::Class<CpuMapTable> ebpf_cpumap_table_cls("CpuMapTable");
  465. /*XskMapTable*/
  466. Php::Class<XskMapTable> ebpf_xskmap_table_cls("XskMapTable");
  467. /*MapInMapArrayTable*/
  468. Php::Class<MapInMapArrayTable> ebpf_map_in_map_array_table_cls("MapInMapArrayTable");
  469. /*MapInMapHashTable*/
  470. Php::Class<MapInMapHashTable> ebpf_map_in_maphash_table_cls("MapInMapHashTable");
  471. /*QueueStackTable*/
  472. Php::Class<QueueStackTable> ebpf_queue_stack_table_cls("QueueStackTable");
  473. /*RingBufTable*/
  474. Php::Class<RingBufTable> ebpf_ringbuf_table_cls("RingBufTable");
  475. extension.add(std::move(ebpf_hashtable_cls));
  476. extension.add(std::move(ebpf_array_table_cls));
  477. extension.add(std::move(ebpf_prog_array_table_cls));
  478. extension.add(std::move(ebpf_perf_event_class));
  479. extension.add(std::move(ebpf_percpuhash_table_cls));
  480. extension.add(std::move(ebpf_percpuarray_table_cls));
  481. extension.add(std::move(ebpf_lpmtrie_table_cls));
  482. extension.add(std::move(ebpf_stack_trace_table_cls));
  483. extension.add(std::move(ebpf_lruhash_table_cls));
  484. extension.add(std::move(ebpf_lruper_cpuhash_table_cls));
  485. extension.add(std::move(ebpf_cgroup_array_table_cls));
  486. extension.add(std::move(ebpf_devmap_table_cls));
  487. extension.add(std::move(ebpf_cpumap_table_cls));
  488. extension.add(std::move(ebpf_xskmap_table_cls));
  489. extension.add(std::move(ebpf_map_in_map_array_table_cls));
  490. extension.add(std::move(ebpf_map_in_maphash_table_cls));
  491. extension.add(std::move(ebpf_queue_stack_table_cls));
  492. extension.add(std::move(ebpf_ringbuf_table_cls));
  493. return extension;
  494. }
  495. }