Skip to content

Commit

Permalink
pkg/endpoint: do not rely on bpf_host.o to detect host endpoint
Browse files Browse the repository at this point in the history
The code to restore endpoint state checks for the presence of
bpf_host.o to determine whether the host endpoint ID needs to
be restored. Use ep.IsHost instead to decouple the restore process
from what the loader is doing under the covers.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
  • Loading branch information
lmb committed May 15, 2024
1 parent ded9520 commit 8c97a21
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions pkg/endpoint/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ var (
initialGlobalIdentitiesControllerGroup = controller.NewGroup("initial-global-identities")
)

// hostObjFileName is the name of the host object file.
const hostObjFileName = "bpf_host.o"

func hasHostObjectFile(epDir string) bool {
hostObjFilepath := filepath.Join(epDir, hostObjFileName)
_, err := os.Stat(hostObjFilepath)
return err == nil
}

// ReadEPsFromDirNames returns a mapping of endpoint ID to endpoint of endpoints
// from a list of directory names that can possible contain an endpoint.
func ReadEPsFromDirNames(ctx context.Context, owner regeneration.Owner, policyGetter policyRepoGetter,
Expand All @@ -75,7 +66,6 @@ func ReadEPsFromDirNames(ctx context.Context, owner regeneration.Owner, policyGe
possibleEPs := map[uint16]*Endpoint{}
for _, epDirName := range completeEPDirNames {
epDir := filepath.Join(basePath, epDirName)
isHost := hasHostObjectFile(epDir)

scopedLog := log.WithFields(logrus.Fields{
logfields.EndpointID: epDirName,
Expand Down Expand Up @@ -105,7 +95,7 @@ func ReadEPsFromDirNames(ctx context.Context, owner regeneration.Owner, policyGe

// We need to save the host endpoint ID as we'll need it to regenerate
// other endpoints.
if isHost {
if ep.IsHost() {
node.SetEndpointID(ep.GetID())
}
}
Expand Down

0 comments on commit 8c97a21

Please sign in to comment.