socket.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. package tracer
  2. import (
  3. "fmt"
  4. "net"
  5. "os"
  6. "runtime"
  7. "strings"
  8. "syscall"
  9. "time"
  10. "github.com/cilium/ebpf"
  11. "github.com/cilium/ebpf/btf"
  12. "github.com/coroot/coroot-node-agent/flags"
  13. "github.com/coroot/coroot-node-agent/utils"
  14. . "github.com/coroot/coroot-node-agent/utils/modelse"
  15. klog "github.com/sirupsen/logrus"
  16. )
  17. func init() {
  18. enable_ebpf_protocol(PROTO_HTTP1)
  19. enable_ebpf_protocol(PROTO_HTTP2)
  20. enable_ebpf_protocol(PROTO_TLS_HTTP1)
  21. enable_ebpf_protocol(PROTO_TLS_HTTP2)
  22. enable_ebpf_protocol(PROTO_DUBBO)
  23. enable_ebpf_protocol(PROTO_SOFARPC)
  24. enable_ebpf_protocol(PROTO_MYSQL)
  25. enable_ebpf_protocol(PROTO_POSTGRESQL)
  26. enable_ebpf_protocol(PROTO_REDIS)
  27. enable_ebpf_protocol(PROTO_KAFKA)
  28. enable_ebpf_protocol(PROTO_MQTT)
  29. enable_ebpf_protocol(PROTO_DNS)
  30. }
  31. func MapInit(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) {
  32. set_offset_map(collectionSpec, opts)
  33. set_conf_map_default(collectionSpec, opts)
  34. //offsetData := make([]any, runtime.NumCPU())
  35. //for i := range offsetData {
  36. // offsetData[i] = testStruct{
  37. // test_id: 99999,
  38. // }
  39. //}
  40. //if bpf_table_set_value(collectionSpec, opts, "test_heap", offsetData) != ETR_OK {}
  41. //insert_output_prog_to_map(collectionSpec, opts)
  42. }
  43. func MapInsert(collection *ebpf.Collection) {
  44. insert_output_prog_to_map(collection)
  45. insert_adapt_kern_uid_to_map(collection)
  46. // Update go offsets to eBPF "proc_info_map"
  47. //update_proc_info_to_map(collection)
  48. // Update protocol filter array
  49. update_protocol_filter_array(collection)
  50. // 从flags配置获取CodeType配置,默认支持Python和Node
  51. update_skmsg_header_allowed_to_map(collection)
  52. }
  53. func insert_output_prog_to_map(collection *ebpf.Collection) {
  54. // jmp for tracepoints
  55. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_TP_NAME, PROG_DATA_SUBMIT_NAME_FOR_TP, PROG_DATA_SUBMIT_TP_IDX)
  56. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_TP_NAME, PROG_OUTPUT_DATA_NAME_FOR_TP, PROG_OUTPUT_DATA_TP_IDX)
  57. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_TP_NAME, PROG_IO_EVENT_NAME_FOR_TP, PROG_IO_EVENT_TP_IDX)
  58. // jmp for kprobe/uprobe
  59. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_KP_NAME, PROG_DATA_SUBMIT_NAME_FOR_KP, PROG_DATA_SUBMIT_KP_IDX)
  60. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_KP_NAME, PROG_OUTPUT_DATA_NAME_FOR_KP, PROG_OUTPUT_DATA_KP_IDX)
  61. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_UP_NAME, PROG_SAVE_SC_DATA_FOR_UP, PROG_DATA_SAVE_UP_IDX)
  62. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_UP_NAME, PROG_JAVA_UPDATE_HEADER_FOR_UP, PROG_DATA_JAVA_UPDATE_HEADER_UP_IDX)
  63. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_UP_NAME, PROG_JAVA_FIND_HOST_FOR_UP, PROG_DATA_JAVA_FIND_HOST_UP_IDX)
  64. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_UP_NAME, PROG_JAVA_BUILD_HEADER_FOR_UP, PROG_DATA_JAVA_BUILD_HEADER_UP_IDX)
  65. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_UP_NAME, PROG_GO_UPDATE_HEADER_FOR_UP, PROG_DATA_GO_UPDATE_HEADER_UP_IDX)
  66. //add for l7.c -> is_http_request(payload) -> bpf_tail_call
  67. __insert_output_prog_to_map(collection, MAP_PROGS_JMP_TP_NAME, PROG_L7_HTTP_TRACE_ID_FOR_TP, PROG_DATA_L7_HTTP_TRACE_ID_TP_IDX)
  68. }
  69. func __insert_output_prog_to_map(collection *ebpf.Collection, mapName string, progName string, key uint32) {
  70. // find in programs
  71. prog, ok := collection.Programs[progName]
  72. //fmt.Println(prog, ok)
  73. if ok {
  74. progFd := prog.FD()
  75. code, err := bpf_table_set_value(collection, mapName, key, uint32(progFd))
  76. if err != nil {
  77. klog.Error(err, code)
  78. }
  79. }
  80. }
  81. func update_protocol_filter_array(collection *ebpf.Collection) {
  82. for i := 0; i < PROTO_NUM; i++ {
  83. code, err := bpf_table_set_value(collection, MAP_PROTO_FILTER_NAME, uint32(i), EbpfConfigProtocolFilter[i])
  84. if err != nil || code != ETR_OK {
  85. klog.Error(err, code)
  86. }
  87. }
  88. }
  89. //func update_allow_port_bitmap(collection *ebpf.Collection) {
  90. // for i := 0; i < PROTO_NUM; i++ {
  91. // if bpf_table_set_value(collection, MAP_ALLOW_PORT_BITMAP_NAME, 0, &allow_port_bitmap) != ETR_OK {
  92. // fmt.Println("no")
  93. // } else {
  94. // fmt.Println("ok")
  95. // }
  96. // }
  97. //}
  98. func insert_adapt_kern_uid_to_map(collection *ebpf.Collection) {
  99. pid := os.Getpid()
  100. tid := syscall.Gettid()
  101. adaptKernUID := uint64(pid)<<32 | uint64(tid)
  102. code, err := bpf_table_set_value(collection, MAP_ADAPT_KERN_UID_NAME, uint32(0), adaptKernUID)
  103. if err != nil || code != ETR_OK {
  104. klog.Error(err, code)
  105. }
  106. }
  107. func enable_ebpf_protocol(protocol int) {
  108. if protocol < PROTO_NUM {
  109. EbpfConfigProtocolFilter[protocol] = 1
  110. }
  111. }
  112. func Offset() {
  113. listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", offsetInferServerAddr, offsetInferServerPort))
  114. if err != nil {
  115. fmt.Errorf("failed to create server listener: %v", err)
  116. return
  117. }
  118. if err := kernelOffsetInferServer(listener); err != nil {
  119. fmt.Printf("Error in kernel_offset_infer_server: %v\n", err)
  120. }
  121. if err := kernelOffsetInferClient(); err != nil {
  122. fmt.Printf("Error in kernel_offset_infer_client: %v\n", err)
  123. }
  124. defer listener.Close()
  125. }
  126. func set_offset_map(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) {
  127. // 解析BTF数据
  128. if update_offset_map_from_btf_vmlinux(collectionSpec, opts) != ETR_OK {
  129. klog.Infof("[eBPF Kernel Adapt] Set offsets map from btf_vmlinux, not support.")
  130. if update_offset_map_default(collectionSpec, opts) != ETR_OK {
  131. klog.Infof("[eBPF Kernel Adapt] Set offsets error, failed to update default offse.t")
  132. } else {
  133. klog.Infof("[eBPF Kernel Adapt] Set offsets map use default.")
  134. }
  135. } else {
  136. klog.Infof("[eBPF Kernel Adapt] Set offsets map from btf_vmlinux, success.")
  137. }
  138. }
  139. // __u64 socket_id; // 会话标识
  140. // __u64 coroutine_trace_id; // 同一协程的数据转发关联
  141. // __u64 thread_trace_id; // 同一进程/线程的数据转发关联,用于多事务流转场景
  142. // __u64 data_limit_max; // Maximum number of data transfers
  143. // __u64 go_tracing_timeout;
  144. // __u64 io_event_collect_mode;
  145. // __u64 io_event_minimal_duration;
  146. func set_conf_map_default(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) {
  147. //charHostID := utils.GetHostIDBPFString()
  148. //_, charAppID := utils.GetAppID()
  149. uidBase := uint64(time.Now().UnixNano()/int64(time.Millisecond)) & 0xffffffffffffff
  150. numCPU := runtime.NumCPU()
  151. nCPU, _ := utils.GetCPUCount()
  152. tConf := make([]any, numCPU)
  153. for i := range tConf {
  154. socketID := uint64(i)<<56 | uint64(uidBase)
  155. tracerConf := EbpfTraceConf{
  156. SocketID: socketID,
  157. CoroutineTraceID: socketID,
  158. ThreadTraceID: socketID,
  159. DataLimitMax: 4096,
  160. GoTracingTimeout: 120,
  161. IOEventCollectMode: 1,
  162. IOEventMinimalDuartion: 1000000,
  163. //HostID: utils.GetHostIDBPFString(),
  164. //APPID: charAppID,
  165. TotalCpus: uint64(nCPU),
  166. }
  167. tConf[i] = tracerConf
  168. }
  169. if bpf_table_pre_set_value(collectionSpec, opts, MAP_TRACE_CONF_NAME, tConf) != ETR_OK {
  170. klog.Infof("[eBPF Kernel Adapt] Set config map from btf_vmlinux, not support.")
  171. } else {
  172. klog.Infof("[eBPF Kernel Adapt] Set config map from btf_vmlinux, success.")
  173. }
  174. }
  175. // 解析BTF数据
  176. func update_offset_map_from_btf_vmlinux(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) int {
  177. btfSpec, err := btf.LoadKernelSpec()
  178. if err != nil || btfSpec == nil {
  179. klog.WithError(err).Warning("[eBPF Kernel Adapt] Failed to get btf.LoadKernelSpec")
  180. return ETR_NOTSUPP
  181. }
  182. copied_seq_offs := kernel_struct_field_offset(btfSpec, "tcp_sock", "copied_seq")
  183. write_seq_offs := kernel_struct_field_offset(btfSpec, "tcp_sock", "write_seq")
  184. files_offs := kernel_struct_field_offset(btfSpec, "task_struct", "files")
  185. sk_flags_offs := kernel_struct_field_offset(btfSpec, "sock", "__sk_flags_offset")
  186. if sk_flags_offs == ETR_NOTEXIST {
  187. sk_flags_offs = kernel_struct_field_offset(btfSpec, "sock", "sk_pacing_shift")
  188. if sk_flags_offs > 0 {
  189. sk_flags_offs -= 1
  190. }
  191. }
  192. struct_files_struct_fdt_offset := kernel_struct_field_offset(btfSpec, "files_struct", "fdt")
  193. struct_files_private_data_offset := kernel_struct_field_offset(btfSpec, "file", "private_data")
  194. struct_file_f_inode_offset := kernel_struct_field_offset(btfSpec, "file", "f_inode")
  195. struct_inode_i_mode_offset := kernel_struct_field_offset(btfSpec, "inode", "i_mode")
  196. struct_file_dentry_offset_1 := kernel_struct_field_offset(btfSpec, "file", "f_path")
  197. struct_file_dentry_offset_2 := kernel_struct_field_offset(btfSpec, "path", "dentry")
  198. if struct_file_dentry_offset_1 < 0 ||
  199. struct_file_dentry_offset_2 < 0 {
  200. return ETR_NOTSUPP
  201. }
  202. struct_file_dentry_offset := struct_file_dentry_offset_1 + struct_file_dentry_offset_2
  203. struct_dentry_name_offset_1 := kernel_struct_field_offset(btfSpec, "dentry", "d_name")
  204. struct_dentry_name_offset_2 := kernel_struct_field_offset(btfSpec, "qstr", "name")
  205. if struct_dentry_name_offset_1 < 0 ||
  206. struct_dentry_name_offset_2 < 0 {
  207. return ETR_NOTSUPP
  208. }
  209. struct_dentry_name_offset := struct_dentry_name_offset_1 + struct_dentry_name_offset_2
  210. struct_sock_family_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_family")
  211. struct_sock_saddr_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_rcv_saddr")
  212. struct_sock_daddr_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_daddr")
  213. struct_sock_ip6saddr_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_v6_rcv_saddr")
  214. struct_sock_ip6daddr_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_v6_daddr")
  215. struct_sock_dport_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_dport")
  216. struct_sock_sport_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_num")
  217. struct_sock_skc_state_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_state")
  218. struct_sock_common_ipv6only_offset := kernel_struct_field_offset(btfSpec, "sock_common", "skc_flags")
  219. klog.Infof("Offsets from BTF vmlinux:")
  220. klog.Infof(" copied_seq_offs: 0x%x", copied_seq_offs)
  221. klog.Infof(" write_seq_offs: 0x%x", write_seq_offs)
  222. klog.Infof(" files_offs: 0x%x", files_offs)
  223. klog.Infof(" sk_flags_offs: 0x%x", sk_flags_offs)
  224. klog.Infof(" struct_files_struct_fdt_offset: 0x%x", struct_files_struct_fdt_offset)
  225. klog.Infof(" struct_files_private_data_offset: 0x%x", struct_files_private_data_offset)
  226. klog.Infof(" struct_file_f_inode_offset: 0x%x", struct_file_f_inode_offset)
  227. klog.Infof(" struct_inode_i_mode_offset: 0x%x", struct_inode_i_mode_offset)
  228. klog.Infof(" struct_file_dentry_offset: 0x%x", struct_file_dentry_offset)
  229. klog.Infof(" struct_dentry_name_offset: 0x%x", struct_dentry_name_offset)
  230. klog.Infof(" struct_sock_family_offset: 0x%x", struct_sock_family_offset)
  231. klog.Infof(" struct_sock_saddr_offset: 0x%x", struct_sock_saddr_offset)
  232. klog.Infof(" struct_sock_daddr_offset: 0x%x", struct_sock_daddr_offset)
  233. klog.Infof(" struct_sock_ip6saddr_offset: 0x%x", struct_sock_ip6saddr_offset)
  234. klog.Infof(" struct_sock_ip6daddr_offset: 0x%x", struct_sock_ip6daddr_offset)
  235. klog.Infof(" struct_sock_dport_offset: 0x%x", struct_sock_dport_offset)
  236. klog.Infof(" struct_sock_sport_offset: 0x%x", struct_sock_sport_offset)
  237. klog.Infof(" struct_sock_skc_state_offset: 0x%x", struct_sock_skc_state_offset)
  238. klog.Infof(" struct_sock_common_ipv6only_offset: 0x%x", struct_sock_common_ipv6only_offset)
  239. if copied_seq_offs < 0 || write_seq_offs < 0 || files_offs < 0 ||
  240. sk_flags_offs < 0 || struct_files_struct_fdt_offset < 0 ||
  241. struct_files_private_data_offset < 0 ||
  242. struct_file_f_inode_offset < 0 || struct_inode_i_mode_offset < 0 ||
  243. struct_inode_i_mode_offset < 0 || struct_file_dentry_offset < 0 ||
  244. struct_dentry_name_offset < 0 || struct_sock_family_offset < 0 ||
  245. struct_sock_saddr_offset < 0 || struct_sock_daddr_offset < 0 ||
  246. struct_sock_ip6saddr_offset < 0 ||
  247. struct_sock_ip6daddr_offset < 0 || struct_sock_dport_offset < 0 ||
  248. struct_sock_sport_offset < 0 || struct_sock_skc_state_offset < 0 ||
  249. struct_sock_common_ipv6only_offset < 0 {
  250. return ETR_NOTSUPP
  251. }
  252. offset := BpfOffsetParam{}
  253. offset.Ready = 1
  254. offset.TaskFilesOffset = uint32(files_offs)
  255. offset.SockFlagsOffset = uint32(sk_flags_offs)
  256. offset.TcpSockCopiedSeqOffset = uint32(copied_seq_offs)
  257. offset.TcpSockWriteSeqOffset = uint32(write_seq_offs)
  258. offset.StructFilesStructFdtOffset = uint32(struct_files_struct_fdt_offset)
  259. offset.StructFilesPrivateDataOffset = uint32(struct_files_private_data_offset)
  260. offset.StructFileFInodeOffset = uint32(struct_file_f_inode_offset)
  261. offset.StructInodeIModeOffset = uint32(struct_inode_i_mode_offset)
  262. offset.StructFileDentryOffset = uint32(struct_file_dentry_offset)
  263. offset.StructDentryNameOffset = uint32(struct_dentry_name_offset)
  264. offset.StructSockFamilyOffset = uint32(struct_sock_family_offset)
  265. offset.StructSockSaddrOffset = uint32(struct_sock_saddr_offset)
  266. offset.StructSockDaddrOffset = uint32(struct_sock_daddr_offset)
  267. offset.StructSockIp6saddrOffset = uint32(struct_sock_ip6saddr_offset)
  268. offset.StructSockIp6daddrOffset = uint32(struct_sock_ip6daddr_offset)
  269. offset.StructSockDportOffset = uint32(struct_sock_dport_offset)
  270. offset.StructSockSportOffset = uint32(struct_sock_sport_offset)
  271. offset.StructSockSkcStateOffset = uint32(struct_sock_skc_state_offset)
  272. offset.StructSockCommonIpv6onlyOffset = uint32(struct_sock_common_ipv6only_offset)
  273. if update_offsets_table(collectionSpec, opts, offset) != ETR_OK {
  274. return ETR_UPDATE_MAP_FAILD
  275. }
  276. return ETR_OK
  277. }
  278. func update_offset_map_default(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) int {
  279. offset := BpfOffsetParam{}
  280. offset.StructFilesStructFdtOffset = 0x20
  281. offset.StructFilesPrivateDataOffset = 0xc8
  282. offset.StructFileFInodeOffset = 0x20
  283. offset.StructInodeIModeOffset = 0x00
  284. offset.StructFileDentryOffset = 0x18
  285. offset.StructDentryNameOffset = 0x28
  286. offset.StructSockFamilyOffset = 0x10
  287. offset.StructSockSaddrOffset = 0x4
  288. offset.StructSockDaddrOffset = 0x0
  289. offset.StructSockIp6saddrOffset = 0x48
  290. offset.StructSockIp6daddrOffset = 0x38
  291. offset.StructSockDportOffset = 0xc
  292. offset.StructSockSportOffset = 0xe
  293. offset.StructSockSkcStateOffset = 0x12
  294. offset.StructSockCommonIpv6onlyOffset = 0x13
  295. if update_offsets_table(collectionSpec, opts, offset) != ETR_OK {
  296. return ETR_UPDATE_MAP_FAILD
  297. }
  298. return ETR_OK
  299. }
  300. func update_offsets_table(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions, offset BpfOffsetParam) int {
  301. numCPU := runtime.NumCPU()
  302. offsetData := make([]any, numCPU)
  303. for i := range offsetData {
  304. offsetData[i] = offset
  305. }
  306. if bpf_table_pre_set_value(collectionSpec, opts, MAP_MEMBERS_OFFSET_NAME, offsetData) != ETR_OK {
  307. return ETR_UPDATE_MAP_FAILD
  308. }
  309. return ETR_OK
  310. }
  311. func SetConstants(collectionSpec *ebpf.CollectionSpec) {
  312. // nCPU, err := utils.GetCPUCount()
  313. // consts := map[string]interface{}{
  314. // TODO go Process
  315. // "buckets_ptr_pos": int64(16),
  316. // "ctx_ptr_pos": int64(232),
  317. // "headers_ptr_pos": int64(56),
  318. // "request_host_pos": int64(128),
  319. // "is_registers_abi": true,
  320. // "method_ptr_pos": int64(0),
  321. // "path_ptr_pos": int64(56),
  322. // "status_code_pos": int64(120),
  323. // "url_ptr_pos": int64(16),
  324. // TODO 全局 ***
  325. // "total_cpus": int64(nCPU),
  326. //"apm_app_id": int64(0),
  327. //"apm_host_id": int64(0),
  328. // }
  329. // err = collectionSpec.RewriteConstants(consts)
  330. // if err != nil {
  331. // fmt.Println("err", err, consts)
  332. // }
  333. }
  334. // parseCodeTypesFromFlags 从flags配置解析CodeType数组
  335. // 配置格式: "python,nodejs" 或 "python,node" 等
  336. // 支持的语言标识: python, node, nodejs, java, go, php, dotnet, netcore, c, lua, ruby
  337. func parseCodeTypesFromFlags() []CodeType {
  338. var codeTypes []CodeType
  339. configValue := *flags.L4HeaderCodeTypes
  340. if configValue == "" {
  341. return codeTypes
  342. }
  343. parts := strings.Split(configValue, ",")
  344. for _, part := range parts {
  345. part = strings.TrimSpace(strings.ToLower(part))
  346. switch part {
  347. case "python":
  348. codeTypes = append(codeTypes, CodeTypePython)
  349. case "node", "nodejs":
  350. codeTypes = append(codeTypes, CodeTypeNode)
  351. case "java":
  352. codeTypes = append(codeTypes, CodeTypeJava)
  353. case "go":
  354. codeTypes = append(codeTypes, CodeTypeGo)
  355. case "php":
  356. codeTypes = append(codeTypes, CodeTypePHP)
  357. case "dotnet":
  358. codeTypes = append(codeTypes, CodeTypeDotNet)
  359. case "netcore":
  360. codeTypes = append(codeTypes, CodeTypeNetCore)
  361. case "c":
  362. codeTypes = append(codeTypes, CodeTypeC)
  363. case "lua":
  364. codeTypes = append(codeTypes, CodeTypeLua)
  365. case "ruby":
  366. codeTypes = append(codeTypes, CodeTypeRuby)
  367. case "nginx":
  368. codeTypes = append(codeTypes, CodeTypeNginx)
  369. default:
  370. klog.Warnf("Unknown code type in L4_HEADER_CODE_TYPES: %s", part)
  371. }
  372. }
  373. return codeTypes
  374. }
  375. func update_skmsg_header_allowed_to_map(collection *ebpf.Collection) {
  376. codeTypes := parseCodeTypesFromFlags()
  377. klog.Infof("[kernel] set l4 header allowed_to_map %s", codeTypes)
  378. for _, codeType := range codeTypes {
  379. _, err := bpf_table_set_any_value(collection, MAP_L4_HEADER_CODE_TYPES_NAME, uint16(codeType), uint8(1))
  380. if err != nil {
  381. klog.Errorf("[kernel] update_skmsg_header_allowed_to_map err: %v]")
  382. }
  383. }
  384. }