bpf_bpfeb.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Code generated by bpf2go; DO NOT EDIT.
  2. //go:build mips || mips64 || ppc64 || s390x
  3. package main
  4. import (
  5. "bytes"
  6. _ "embed"
  7. "fmt"
  8. "io"
  9. "github.com/cilium/ebpf"
  10. )
  11. // loadBpf returns the embedded CollectionSpec for bpf.
  12. func loadBpf() (*ebpf.CollectionSpec, error) {
  13. reader := bytes.NewReader(_BpfBytes)
  14. spec, err := ebpf.LoadCollectionSpecFromReader(reader)
  15. if err != nil {
  16. return nil, fmt.Errorf("can't load bpf: %w", err)
  17. }
  18. return spec, err
  19. }
  20. // loadBpfObjects loads bpf and converts it into a struct.
  21. //
  22. // The following types are suitable as obj argument:
  23. //
  24. // *bpfObjects
  25. // *bpfPrograms
  26. // *bpfMaps
  27. //
  28. // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
  29. func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
  30. spec, err := loadBpf()
  31. if err != nil {
  32. return err
  33. }
  34. return spec.LoadAndAssign(obj, opts)
  35. }
  36. // bpfSpecs contains maps and programs before they are loaded into the kernel.
  37. //
  38. // It can be passed ebpf.CollectionSpec.Assign.
  39. type bpfSpecs struct {
  40. bpfProgramSpecs
  41. bpfMapSpecs
  42. }
  43. // bpfSpecs contains programs before they are loaded into the kernel.
  44. //
  45. // It can be passed ebpf.CollectionSpec.Assign.
  46. type bpfProgramSpecs struct {
  47. KprobeExecve *ebpf.ProgramSpec `ebpf:"kprobe_execve"`
  48. }
  49. // bpfMapSpecs contains maps before they are loaded into the kernel.
  50. //
  51. // It can be passed ebpf.CollectionSpec.Assign.
  52. type bpfMapSpecs struct {
  53. KprobeMap *ebpf.MapSpec `ebpf:"kprobe_map"`
  54. }
  55. // bpfObjects contains all objects after they have been loaded into the kernel.
  56. //
  57. // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
  58. type bpfObjects struct {
  59. bpfPrograms
  60. bpfMaps
  61. }
  62. func (o *bpfObjects) Close() error {
  63. return _BpfClose(
  64. &o.bpfPrograms,
  65. &o.bpfMaps,
  66. )
  67. }
  68. // bpfMaps contains all maps after they have been loaded into the kernel.
  69. //
  70. // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
  71. type bpfMaps struct {
  72. KprobeMap *ebpf.Map `ebpf:"kprobe_map"`
  73. }
  74. func (m *bpfMaps) Close() error {
  75. return _BpfClose(
  76. m.KprobeMap,
  77. )
  78. }
  79. // bpfPrograms contains all programs after they have been loaded into the kernel.
  80. //
  81. // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
  82. type bpfPrograms struct {
  83. KprobeExecve *ebpf.Program `ebpf:"kprobe_execve"`
  84. }
  85. func (p *bpfPrograms) Close() error {
  86. return _BpfClose(
  87. p.KprobeExecve,
  88. )
  89. }
  90. func _BpfClose(closers ...io.Closer) error {
  91. for _, closer := range closers {
  92. if err := closer.Close(); err != nil {
  93. return err
  94. }
  95. }
  96. return nil
  97. }
  98. // Do not access this directly.
  99. //
  100. //go:embed bpf_bpfeb.o
  101. var _BpfBytes []byte