Skip to content

Commit 0f68fc4

Browse files
aiborlmb
authored andcommitted
prog: speed up opening pinned Programs
With commit df9ebe8 the opening of programs by fd was improved. The LoadPinnedProgram still uses to full ProgramInfo instead of the sufficient minimal one. This commit improves the load of pinned Programs as well by using the central helper for creating programs from a fd. This also makes it more consistent with the LoadPinnedMap function as well. Signed-off-by: Tobias Böhm <[email protected]>
1 parent 29f1245 commit 0f68fc4

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

prog.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -978,20 +978,16 @@ func LoadPinnedProgram(fileName string, opts *LoadPinOptions) (*Program, error)
978978
return nil, fmt.Errorf("%s is not a Program", fileName)
979979
}
980980

981-
info, err := newProgramInfoFromFd(fd)
982-
if err != nil {
983-
_ = fd.Close()
984-
return nil, fmt.Errorf("info for %s: %w", fileName, err)
985-
}
981+
p, err := newProgramFromFD(fd)
982+
if err == nil {
983+
p.pinnedPath = fileName
986984

987-
var progName string
988-
if haveObjName() == nil {
989-
progName = info.Name
990-
} else {
991-
progName = filepath.Base(fileName)
985+
if haveObjName() != nil {
986+
p.name = filepath.Base(fileName)
987+
}
992988
}
993989

994-
return &Program{"", fd, progName, fileName, info.Type}, nil
990+
return p, err
995991
}
996992

997993
// ProgramGetNextID returns the ID of the next eBPF program.

0 commit comments

Comments
 (0)