github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/trace/bind/tracer/bindsnoop_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  type bindsnoopBindEvent struct {
    16  	Addr       [16]uint8
    17  	MountNsId  uint64
    18  	Timestamp  uint64
    19  	TsUs       uint64
    20  	Pid        uint32
    21  	BoundDevIf uint32
    22  	Uid        uint32
    23  	Gid        uint32
    24  	Ret        int32
    25  	Port       uint16
    26  	Proto      uint16
    27  	Opts       uint8
    28  	Ver        uint8
    29  	Task       [16]uint8
    30  	_          [6]byte
    31  }
    32  
    33  // loadBindsnoop returns the embedded CollectionSpec for bindsnoop.
    34  func loadBindsnoop() (*ebpf.CollectionSpec, error) {
    35  	reader := bytes.NewReader(_BindsnoopBytes)
    36  	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
    37  	if err != nil {
    38  		return nil, fmt.Errorf("can't load bindsnoop: %w", err)
    39  	}
    40  
    41  	return spec, err
    42  }
    43  
    44  // loadBindsnoopObjects loads bindsnoop and converts it into a struct.
    45  //
    46  // The following types are suitable as obj argument:
    47  //
    48  //	*bindsnoopObjects
    49  //	*bindsnoopPrograms
    50  //	*bindsnoopMaps
    51  //
    52  // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
    53  func loadBindsnoopObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
    54  	spec, err := loadBindsnoop()
    55  	if err != nil {
    56  		return err
    57  	}
    58  
    59  	return spec.LoadAndAssign(obj, opts)
    60  }
    61  
    62  // bindsnoopSpecs contains maps and programs before they are loaded into the kernel.
    63  //
    64  // It can be passed ebpf.CollectionSpec.Assign.
    65  type bindsnoopSpecs struct {
    66  	bindsnoopProgramSpecs
    67  	bindsnoopMapSpecs
    68  }
    69  
    70  // bindsnoopSpecs contains programs before they are loaded into the kernel.
    71  //
    72  // It can be passed ebpf.CollectionSpec.Assign.
    73  type bindsnoopProgramSpecs struct {
    74  	IgBindIpv4E *ebpf.ProgramSpec `ebpf:"ig_bind_ipv4_e"`
    75  	IgBindIpv4X *ebpf.ProgramSpec `ebpf:"ig_bind_ipv4_x"`
    76  	IgBindIpv6E *ebpf.ProgramSpec `ebpf:"ig_bind_ipv6_e"`
    77  	IgBindIpv6X *ebpf.ProgramSpec `ebpf:"ig_bind_ipv6_x"`
    78  }
    79  
    80  // bindsnoopMapSpecs contains maps before they are loaded into the kernel.
    81  //
    82  // It can be passed ebpf.CollectionSpec.Assign.
    83  type bindsnoopMapSpecs struct {
    84  	Events               *ebpf.MapSpec `ebpf:"events"`
    85  	GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"`
    86  	Ports                *ebpf.MapSpec `ebpf:"ports"`
    87  	Sockets              *ebpf.MapSpec `ebpf:"sockets"`
    88  }
    89  
    90  // bindsnoopObjects contains all objects after they have been loaded into the kernel.
    91  //
    92  // It can be passed to loadBindsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
    93  type bindsnoopObjects struct {
    94  	bindsnoopPrograms
    95  	bindsnoopMaps
    96  }
    97  
    98  func (o *bindsnoopObjects) Close() error {
    99  	return _BindsnoopClose(
   100  		&o.bindsnoopPrograms,
   101  		&o.bindsnoopMaps,
   102  	)
   103  }
   104  
   105  // bindsnoopMaps contains all maps after they have been loaded into the kernel.
   106  //
   107  // It can be passed to loadBindsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
   108  type bindsnoopMaps struct {
   109  	Events               *ebpf.Map `ebpf:"events"`
   110  	GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"`
   111  	Ports                *ebpf.Map `ebpf:"ports"`
   112  	Sockets              *ebpf.Map `ebpf:"sockets"`
   113  }
   114  
   115  func (m *bindsnoopMaps) Close() error {
   116  	return _BindsnoopClose(
   117  		m.Events,
   118  		m.GadgetMntnsFilterMap,
   119  		m.Ports,
   120  		m.Sockets,
   121  	)
   122  }
   123  
   124  // bindsnoopPrograms contains all programs after they have been loaded into the kernel.
   125  //
   126  // It can be passed to loadBindsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
   127  type bindsnoopPrograms struct {
   128  	IgBindIpv4E *ebpf.Program `ebpf:"ig_bind_ipv4_e"`
   129  	IgBindIpv4X *ebpf.Program `ebpf:"ig_bind_ipv4_x"`
   130  	IgBindIpv6E *ebpf.Program `ebpf:"ig_bind_ipv6_e"`
   131  	IgBindIpv6X *ebpf.Program `ebpf:"ig_bind_ipv6_x"`
   132  }
   133  
   134  func (p *bindsnoopPrograms) Close() error {
   135  	return _BindsnoopClose(
   136  		p.IgBindIpv4E,
   137  		p.IgBindIpv4X,
   138  		p.IgBindIpv6E,
   139  		p.IgBindIpv6X,
   140  	)
   141  }
   142  
   143  func _BindsnoopClose(closers ...io.Closer) error {
   144  	for _, closer := range closers {
   145  		if err := closer.Close(); err != nil {
   146  			return err
   147  		}
   148  	}
   149  	return nil
   150  }
   151  
   152  // Do not access this directly.
   153  //
   154  //go:embed bindsnoop_x86_bpfel.o
   155  var _BindsnoopBytes []byte