-
Notifications
You must be signed in to change notification settings - Fork 136
kernel-native mode support restart #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6bb0b03
6193ad2
753953c
5a1aee9
af523f6
9e9f682
9e311fc
976cdd2
5446dd1
1cd03bf
9d2f19b
a7ec219
ec6c35d
ed61953
b0a5cad
a7b9bb8
8be1dfe
8d9808c
1de44ab
e3e1066
64f0092
8f43e65
55c04f8
5a0e629
f316c05
43f8129
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,17 @@ | |
| package ads | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "syscall" | ||
|
|
||
| "github.com/cilium/ebpf" | ||
| "github.com/cilium/ebpf/link" | ||
|
|
||
| bpf2go "kmesh.net/kmesh/bpf/kmesh/bpf2go/kernelnative/enhanced" | ||
| "kmesh.net/kmesh/daemon/options" | ||
| "kmesh.net/kmesh/pkg/bpf/restart" | ||
| "kmesh.net/kmesh/pkg/constants" | ||
| helper "kmesh.net/kmesh/pkg/utils" | ||
| ) | ||
|
|
||
|
|
@@ -34,10 +40,24 @@ type BpfTracePoint struct { | |
| bpf2go.KmeshTracePointObjects | ||
| } | ||
|
|
||
| func (sc *BpfTracePoint) NewBpf(cfg *options.BpfConfig) { | ||
| sc.Info.MapPath = cfg.BpfFsPath | ||
| sc.Info.BpfFsPath = cfg.BpfFsPath | ||
| func (sc *BpfTracePoint) NewBpf(cfg *options.BpfConfig) error { | ||
| sc.Info.MapPath = cfg.BpfFsPath + "/bpf_kmesh/map/" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you list the dirs/files in /sys/fs/bpf? I think these directory structures need to be reviewed to avoid unreasonable directory division.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /sys/fs/bpf |
||
| sc.Info.BpfFsPath = cfg.BpfFsPath + "/bpf_kmesh/tracepoint/" | ||
| sc.Info.Cgroup2Path = cfg.Cgroup2Path | ||
|
|
||
| if err := os.MkdirAll(sc.Info.MapPath, | ||
| syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR| | ||
| syscall.S_IRGRP|syscall.S_IXGRP); err != nil && !os.IsExist(err) { | ||
| return err | ||
| } | ||
|
|
||
| if err := os.MkdirAll(sc.Info.BpfFsPath, | ||
| syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR| | ||
| syscall.S_IRGRP|syscall.S_IXGRP); err != nil && !os.IsExist(err) { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func (sc *BpfTracePoint) loadKmeshTracePointObjects() (*ebpf.CollectionSpec, error) { | ||
|
|
@@ -76,17 +96,29 @@ func (sc *BpfTracePoint) Load() error { | |
| } | ||
|
|
||
| func (sc *BpfTracePoint) Attach() error { | ||
| var err error | ||
| tpopt := link.RawTracepointOptions{ | ||
| Name: "connect_ret", | ||
| Program: sc.KmeshTracePointObjects.ConnectRet, | ||
| } | ||
|
|
||
| lk, err := link.AttachRawTracepoint(tpopt) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| sc.Link = lk | ||
| pinPath := filepath.Join(sc.Info.BpfFsPath, constants.Prog_link) | ||
| if restart.GetStartType() == restart.Restart { | ||
| sc.Link, err = link.LoadPinnedLink(pinPath, &ebpf.LoadPinOptions{}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } else { | ||
| sc.Link, err = link.AttachRawTracepoint(tpopt) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if err := sc.Link.Pin(pinPath); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,14 +156,12 @@ func StopMda() error { | |
|
|
||
| func (l *BpfLoader) Stop() { | ||
| var err error | ||
| if restart.GetExitType() == restart.Restart && l.config.DualEngineEnabled() { | ||
| C.deserial_uninit() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove C.deserial_uninit()
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The deserial logic is updated, and now the default C.deserial_uninit(). |
||
| log.Infof("kmesh restart, not clean bpf map and prog") | ||
| C.deserial_uninit() | ||
| if restart.GetExitType() == restart.Restart { | ||
| return | ||
| } | ||
|
|
||
| closeMap(l.versionMap) | ||
|
|
||
| if l.config.KernelNativeEnabled() { | ||
| if err = l.obj.Stop(); err != nil { | ||
| CleanupBpfMap() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.