func checkAndUpdateBPFBinaries()

in pkg/ebpf/bpf_client.go [333:377]


func checkAndUpdateBPFBinaries(bpfTCClient tc.BpfTc, bpfBinaries []string, hostBinaryPath string) (bool, bool, bool, error) {
	log := ctrl.Log.WithName("ebpf-client-init") //TODO - reuse the logger
	updateIngressProbe, updateEgressProbe, updateEventsProbe := false, false, false
	var existingProbePath string

	for _, bpfProbe := range bpfBinaries {
		if bpfProbe == EKS_CLI_BINARY || bpfProbe == EKS_V6_CLI_BINARY {
			continue
		}

		log.Info("Validating ", "Probe: ", bpfProbe)
		currentProbe, err := ioutil.ReadFile(bpfProbe)
		if err != nil {
			log.Info("error opening  ", "Probe: ", bpfProbe, "error", err)
		}

		existingProbePath = hostBinaryPath + bpfProbe
		existingProbe, err := ioutil.ReadFile(existingProbePath)
		if err != nil {
			log.Info("error opening  ", "Probe: ", existingProbePath, "error", err)
		}

		log.Info("comparing new and existing probes ...")
		isEqual := cmp.Equal(currentProbe, existingProbe)
		if !isEqual {
			if bpfProbe == EVENTS_BINARY || bpfProbe == EVENTS_V6_BINARY {
				// Ingress and Egress probes refer to Conntrack and Policy Events maps defined in
				// events binary. So, if the events binary changes, we will need to update all the existing
				// probes in the local node
				updateEventsProbe, updateIngressProbe, updateEgressProbe = true, true, true
				log.Info("change detected in event probe binaries..")
				break
			}
			if bpfProbe == TC_INGRESS_BINARY || bpfProbe == TC_V6_INGRESS_BINARY {
				log.Info("change detected in ingress probe binaries.. ")
				updateIngressProbe = true
			}
			if bpfProbe == TC_EGRESS_BINARY || bpfProbe == TC_V6_EGRESS_BINARY {
				log.Info("change detected in egress probe binaries..")
				updateEgressProbe = true
			}
		}
	}
	return updateIngressProbe, updateEgressProbe, updateEventsProbe, nil
}