MCPcopy Create free account
hub / github.com/SeeFlowerX/stackplz / start

Method start

user/module/syscall.go:133–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131}
132
133func (this *MSyscall) start() error {
134 // 初始化相关设置
135 err := this.setupManager()
136 if err != nil {
137 return err
138 }
139 this.setupManagerOptions()
140
141 // 从assets中获取eBPF程序的二进制数据
142 var bpfFileName = filepath.Join("user/assets", this.hookBpfFile)
143 byteBuf, err := assets.Asset(bpfFileName)
144
145 if err != nil {
146 return fmt.Errorf("%s\tcouldn't find asset %v .", this.Name(), err)
147 }
148
149 // 初始化 bpfManager 循环次数越多这一步耗时越长
150 if err = this.bpfManager.InitWithOptions(bytes.NewReader(byteBuf), this.bpfManagerOptions); err != nil {
151 return fmt.Errorf("couldn't init manager %v", err)
152 }
153
154 // 启动 bpfManager
155 if err = this.bpfManager.Start(); err != nil {
156 return fmt.Errorf("couldn't start bootstrap manager %v .", err)
157 }
158
159 // 通过更新 BPF_MAP_TYPE_HASH 类型的 map 实现过滤设定的同步
160 err = this.updateFilter()
161 if err != nil {
162 return err
163 }
164
165 // 加载map信息,设置eventFuncMaps,给不同的事件指定处理事件数据的函数
166 err = this.initDecodeFun()
167 if err != nil {
168 return err
169 }
170
171 return nil
172}
173
174func (this *MSyscall) update_map(map_name string, filter_key uint32, filter_value interface{}) {
175 bpf_map, err := this.FindMap(map_name)

Callers 1

StartMethod · 0.95

Calls 6

setupManagerMethod · 0.95
setupManagerOptionsMethod · 0.95
updateFilterMethod · 0.95
initDecodeFunMethod · 0.95
NameMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected