github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/advise/seccomp/tracer/seccomp_x86_bpfel.go (about)

     1  // Code generated by bpf2go; DO NOT EDIT.
     2  //go:build 386 || amd64
     3  
     4  package tracer
     5  
     6  import (
     7  	"bytes"
     8  	_ "embed"
     9  	"fmt"
    10  	"io"
    11  
    12  	"github.com/cilium/ebpf"
    13  )
    14  
    15  // loadSeccomp returns the embedded CollectionSpec for seccomp.
    16  func loadSeccomp() (*ebpf.CollectionSpec, error) {
    17  	reader := bytes.NewReader(_SeccompBytes)
    18  	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
    19  	if err != nil {
    20  		return nil, fmt.Errorf("can't load seccomp: %w", err)
    21  	}
    22  
    23  	return spec, err
    24  }
    25  
    26  // loadSeccompObjects loads seccomp and converts it into a struct.
    27  //
    28  // The following types are suitable as obj argument:
    29  //
    30  //	*seccompObjects
    31  //	*seccompPrograms
    32  //	*seccompMaps
    33  //
    34  // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
    35  func loadSeccompObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
    36  	spec, err := loadSeccomp()
    37  	if err != nil {
    38  		return err
    39  	}
    40  
    41  	return spec.LoadAndAssign(obj, opts)
    42  }
    43  
    44  // seccompSpecs contains maps and programs before they are loaded into the kernel.
    45  //
    46  // It can be passed ebpf.CollectionSpec.Assign.
    47  type seccompSpecs struct {
    48  	seccompProgramSpecs
    49  	seccompMapSpecs
    50  }
    51  
    52  // seccompSpecs contains programs before they are loaded into the kernel.
    53  //
    54  // It can be passed ebpf.CollectionSpec.Assign.
    55  type seccompProgramSpecs struct {
    56  	IgSeccompE *ebpf.ProgramSpec `ebpf:"ig_seccomp_e"`
    57  }
    58  
    59  // seccompMapSpecs contains maps before they are loaded into the kernel.
    60  //
    61  // It can be passed ebpf.CollectionSpec.Assign.
    62  type seccompMapSpecs struct {
    63  	SyscallsPerMntns *ebpf.MapSpec `ebpf:"syscalls_per_mntns"`
    64  }
    65  
    66  // seccompObjects contains all objects after they have been loaded into the kernel.
    67  //
    68  // It can be passed to loadSeccompObjects or ebpf.CollectionSpec.LoadAndAssign.
    69  type seccompObjects struct {
    70  	seccompPrograms
    71  	seccompMaps
    72  }
    73  
    74  func (o *seccompObjects) Close() error {
    75  	return _SeccompClose(
    76  		&o.seccompPrograms,
    77  		&o.seccompMaps,
    78  	)
    79  }
    80  
    81  // seccompMaps contains all maps after they have been loaded into the kernel.
    82  //
    83  // It can be passed to loadSeccompObjects or ebpf.CollectionSpec.LoadAndAssign.
    84  type seccompMaps struct {
    85  	SyscallsPerMntns *ebpf.Map `ebpf:"syscalls_per_mntns"`
    86  }
    87  
    88  func (m *seccompMaps) Close() error {
    89  	return _SeccompClose(
    90  		m.SyscallsPerMntns,
    91  	)
    92  }
    93  
    94  // seccompPrograms contains all programs after they have been loaded into the kernel.
    95  //
    96  // It can be passed to loadSeccompObjects or ebpf.CollectionSpec.LoadAndAssign.
    97  type seccompPrograms struct {
    98  	IgSeccompE *ebpf.Program `ebpf:"ig_seccomp_e"`
    99  }
   100  
   101  func (p *seccompPrograms) Close() error {
   102  	return _SeccompClose(
   103  		p.IgSeccompE,
   104  	)
   105  }
   106  
   107  func _SeccompClose(closers ...io.Closer) error {
   108  	for _, closer := range closers {
   109  		if err := closer.Close(); err != nil {
   110  			return err
   111  		}
   112  	}
   113  	return nil
   114  }
   115  
   116  // Do not access this directly.
   117  //
   118  //go:embed seccomp_x86_bpfel.o
   119  var _SeccompBytes []byte