github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/features/version.go (about)

     1  package features
     2  
     3  import "github.com/cilium/ebpf/internal"
     4  
     5  // LinuxVersionCode returns the version of the currently running kernel
     6  // as defined in the LINUX_VERSION_CODE compile-time macro. It is represented
     7  // in the format described by the KERNEL_VERSION macro from linux/version.h.
     8  //
     9  // Do not use the version to make assumptions about the presence of certain
    10  // kernel features, always prefer feature probes in this package. Some
    11  // distributions backport or disable eBPF features.
    12  func LinuxVersionCode() (uint32, error) {
    13  	v, err := internal.KernelVersion()
    14  	if err != nil {
    15  		return 0, err
    16  	}
    17  	return v.Kernel(), nil
    18  }