Skip to content

Commit

Permalink
Daemon: ensure we know about all managed interfaces
Browse files Browse the repository at this point in the history
If the daemon is restarted, we start not knowing about any
of the managed interfaces. If we perform activities like
reseting everything due to IngressNodeFirewallNodeState
deletion for example, we will not cleanup all XDP programs.
IngNodeFwController knows all pinned interfaces and ensure
we know about them in ebpfSingleton.

Future work is needed to refactor this to not have two
seperate sources of information about the same thing.

Signed-off-by: Martin Kennelly <mkennell@redhat.com>
  • Loading branch information
martinkennelly committed Oct 30, 2022
1 parent 02a6999 commit 957b7a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/ebpf/ingress_node_firewall_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,15 @@ func (infc *IngNodeFwController) loadPinnedLinks() error {
return nil
}

func (infc *IngNodeFwController) GetPinnedLinkNames() []string {
linkNames := make([]string, 0, len(infc.links))

for linkName, _ := range infc.links {
linkNames = append(linkNames, linkName)
}
return linkNames
}

// cleanup will delete an interface's eBPF objects.
func (infc *IngNodeFwController) cleanup(ifName string) error {
l, ok := infc.links[ifName]
Expand Down
6 changes: 6 additions & 0 deletions pkg/ebpfsyncer/ebpfsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func (e *ebpfSingleton) SyncInterfaceIngressRules(
return err
}

// Ensure IngNodeFwController's pinned links and our managed interfaces align
// TODO: refactor to not have managed interfaces names from two sources
for _, linkName := range e.c.GetPinnedLinkNames() {
e.managedInterfaces[linkName] = struct{}{}
}

// For delete operations, detach all interfaces and run a cleanup, set managed interfaces and the
// manager to empty / nil values, then return.
if isDelete {
Expand Down

0 comments on commit 957b7a9

Please sign in to comment.