func (nsp *NetworkSecurityProbe) loadEBPFProgram() error {
	// Recover asset
	buf, err := probe.Asset("probe.o")
	if err != nil {
		return errors.Wrap(err, "couldn't find asset")
	}
	reader := bytes.NewReader(buf)
	// Load elf CollectionSpec
	collectionSpec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return errors.Wrap(err, "couldn't load collection spec")
	}
	// Load eBPF program
	nsp.Collection, err = ebpf.NewCollection(collectionSpec)
	if err != nil {
		return errors.Wrap(err, "couldn't load eBPF program")
	}
	nspLogger.Debug("eBPF program loaded")
	// Map the tail call programs
	requestParser, ok := nsp.Collection.Programs["classifier/dns_request_parser"]
	if !ok {
		return errors.Wrap(err, "dns request parser missing")
	}
	requestFD := requestParser.FD()
	requestKey := kernel.DNSRequestParserKey
	responseParser, ok := nsp.Collection.Programs["classifier/dns_response_parser"]
	if !ok {
		return errors.Wrap(err, "dns response parser missing")
	}
	responseFD := responseParser.FD()
	responseKey := kernel.DNSResponseParserKey
	cidrEntry, ok := nsp.Collection.Programs["classifier/cidr_entry"]
	if !ok {
		return errors.Wrap(err, "cidr entry tailcall missing")
	}
	cidrEntryFD := cidrEntry.FD()
	cidrKey := kernel.CIDREntryProgKey
	dnsProgArray, ok := nsp.Collection.Maps["dns_prog_array"]
	if !ok {
		return errors.Wrap(err, "dns prog array not found")
	}
	if err := dnsProgArray.Put(unsafe.Pointer(&requestKey), unsafe.Pointer(&requestFD)); err != nil {
		return errors.Wrap(err, "couldn't insert dns request parser program")
	}
	if err := dnsProgArray.Put(unsafe.Pointer(&responseKey), unsafe.Pointer(&responseFD)); err != nil {
		return errors.Wrap(err, "couldn't insert dns response parser program")
	}
	if err := dnsProgArray.Put(unsafe.Pointer(&cidrKey), unsafe.Pointer(&cidrEntryFD)); err != nil {
		return errors.Wrap(err, "couldn't insert CIDR entry program")
	}
	return nil
}
// loadEBPFProgram - Loads eBPF program
Loads eBPF program
// loadEBPFProgram - Loads eBPF program
func (nsp *NetworkSecurityProbe) loadEBPFProgram() error {
	buf, err := probe.Asset("probe.o")
	if err != nil {
		return errors.Wrap(err, "couldn't find asset")
	}
	reader := bytes.NewReader(buf)
	collectionSpec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return errors.Wrap(err, "couldn't load collection spec")
	}
	nsp.Collection, err = ebpf.NewCollection(collectionSpec)
	if err != nil {
		return errors.Wrap(err, "couldn't load eBPF program")
	}
	nspLogger.Debug("eBPF program loaded")
	requestParser, ok := nsp.Collection.Programs["classifier/dns_request_parser"]
	if !ok {
		return errors.Wrap(err, "dns request parser missing")
	}
	requestFD := requestParser.FD()
	requestKey := kernel.DNSRequestParserKey
	responseParser, ok := nsp.Collection.Programs["classifier/dns_response_parser"]
	if !ok {
		return errors.Wrap(err, "dns response parser missing")
	}
	responseFD := responseParser.FD()
	responseKey := kernel.DNSResponseParserKey
	cidrEntry, ok := nsp.Collection.Programs["classifier/cidr_entry"]
	if !ok {
		return errors.Wrap(err, "cidr entry tailcall missing")
	}
	cidrEntryFD := cidrEntry.FD()
	cidrKey := kernel.CIDREntryProgKey
	dnsProgArray, ok := nsp.Collection.Maps["dns_prog_array"]
	if !ok {
		return errors.Wrap(err, "dns prog array not found")
	}
	if err := dnsProgArray.Put(unsafe.Pointer(&requestKey), unsafe.Pointer(&requestFD)); err != nil {
		return errors.Wrap(err, "couldn't insert dns request parser program")
	}
	if err := dnsProgArray.Put(unsafe.Pointer(&responseKey), unsafe.Pointer(&responseFD)); err != nil {
		return errors.Wrap(err, "couldn't insert dns response parser program")
	}
	if err := dnsProgArray.Put(unsafe.Pointer(&cidrKey), unsafe.Pointer(&cidrEntryFD)); err != nil {
		return errors.Wrap(err, "couldn't insert CIDR entry program")
	}
	return nil
}
func ( nsp * NetworkSecurityProbe ) loadEBPFProgram ( ) error { buf , err := probe . Asset ( " " ) if err != nil { return errors . Wrap ( err , " " ) } reader := bytes . NewReader ( buf ) collectionSpec , err := ebpf . LoadCollectionSpecFromReader ( reader ) if err != nil { return errors . Wrap ( err , " " ) } nsp . Collection , err = ebpf . NewCollection ( collectionSpec ) if err != nil { return errors . Wrap ( err , " " ) } nspLogger . Debug ( " " ) requestParser , ok := nsp . Collection . Programs [ " " ] if ! ok { return errors . Wrap ( err , " " ) } requestFD := requestParser . FD ( ) requestKey := kernel . DNSRequestParserKey responseParser , ok := nsp . Collection . Programs [ " " ] if ! ok { return errors . Wrap ( err , " " ) } responseFD := responseParser . FD ( ) responseKey := kernel . DNSResponseParserKey cidrEntry , ok := nsp . Collection . Programs [ " " ] if ! ok { return errors . Wrap ( err , " " ) } cidrEntryFD := cidrEntry . FD ( ) cidrKey := kernel . CIDREntryProgKey dnsProgArray , ok := nsp . Collection . Maps [ " " ] if ! ok { return errors . Wrap ( err , " " ) } if err := dnsProgArray . Put ( unsafe . Pointer ( & requestKey ) , unsafe . Pointer ( & requestFD ) ) ; err != nil { return errors . Wrap ( err , " " ) } if err := dnsProgArray . Put ( unsafe . Pointer ( & responseKey ) , unsafe . Pointer ( & responseFD ) ) ; err != nil { return errors . Wrap ( err , " " ) } if err := dnsProgArray . Put ( unsafe . Pointer ( & cidrKey ) , unsafe . Pointer ( & cidrEntryFD ) ) ; err != nil { return errors . Wrap ( err , " " ) } return nil }
Loads eBPF program
Loads eBPF program
// Recover asset // Load elf CollectionSpec // Load eBPF program // Map the tail call programs