-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update eBPF config cache and local l3af-config-store file for a deleted interface #374
Conversation
jaysheth2
commented
Apr 21, 2024
- When an interface is deleted on the fly, and a delete/remove call is received for the that interface, all the programs associated with that interface should be deleted. Hence, in the PR, on receiving a delete call for an unloaded-interface, the local copy of the programs stored in go-interface and the l3af-config-store file is deleted for cleanup
… the l3af-config-store Signed-off-by: Jay Sheth <[email protected]>
kf/nfconfig.go
Outdated
@@ -1312,6 +1323,9 @@ func (c *NFConfigs) DeleteEbpfPrograms(bpfProgs []models.L3afBPFProgramNames) er | |||
if err := c.SaveConfigsToConfigStore(); err != nil { | |||
return fmt.Errorf("SaveConfigsToConfigStore failed to save configs %w", err) | |||
} | |||
//if err := c.SaveConfigsToConfigStore(); err != nil { | |||
// return fmt.Errorf("SaveConfigsToConfigStore failed to save configs %w", err) | |||
//} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
kf/nfconfig.go
Outdated
errOut := fmt.Errorf("%s interface name not found in the host", ifaceName) | ||
errOut := fmt.Errorf("%s interface name not found in the host, and deleting all EBPF programs associated to ", ifaceName) | ||
if c.EgressTCBpfs[ifaceName] != nil { | ||
c.EgressTCBpfs[ifaceName] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sets the lists to nil, are there any additional cleanups that need to happen or is this enough to remove the reference counts and allow the garbage collector to lazily clean up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the interface is deleted, all the programs associated with will automatically be deleted by the kernel.
I have added a separate function for cleanup all the L3AFd related parameters and information related to the deleted interface.
…face Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
kf/bpf.go
Outdated
if err := b.UnloadProgram(ifaceName, direction); err != nil { | ||
return fmt.Errorf("BPFProgram %s unload failed on interface %s with error: %w", b.Program.Name, ifaceName, err) | ||
allInterfaces, _ := getHostInterfaces() | ||
for iface := range allInterfaces { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fetch interface from map and avoid for loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
kf/nfconfig.go
Outdated
for e := bpfList.Front(); e != nil; e = e.Next() { | ||
data := e.Value.(*BPF) | ||
if err := data.Stop(ifaceName, models.XDPIngressType, c.HostConfig.BpfChainingEnabled); err != nil { | ||
log.Error().Err(err).Msgf("failed to remove map file for program %s => %s", ifaceName, data.Program.Name) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for e := bpfList.Front(); e != nil; e = e.Next() { | |
data := e.Value.(*BPF) | |
if err := data.Stop(ifaceName, models.XDPIngressType, c.HostConfig.BpfChainingEnabled); err != nil { | |
log.Error().Err(err).Msgf("failed to remove map file for program %s => %s", ifaceName, data.Program.Name) | |
} | |
} | |
c.StopNRemoveAllBPFPrograms(ifaceName, models.XDPIngressType) |
kf/nfconfig.go
Outdated
for e := bpfList.Front(); e != nil; e = e.Next() { | ||
data := e.Value.(*BPF) | ||
if err := data.Stop(ifaceName, models.IngressType, c.HostConfig.BpfChainingEnabled); err != nil { | ||
log.Error().Err(err).Msgf("failed to remove map file for program %s => %s", ifaceName, data.Program.Name) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for e := bpfList.Front(); e != nil; e = e.Next() { | |
data := e.Value.(*BPF) | |
if err := data.Stop(ifaceName, models.IngressType, c.HostConfig.BpfChainingEnabled); err != nil { | |
log.Error().Err(err).Msgf("failed to remove map file for program %s => %s", ifaceName, data.Program.Name) | |
} | |
} | |
c.StopNRemoveAllBPFPrograms(ifaceName, models.IngressType) |
kf/nfconfig.go
Outdated
for e := bpfList.Front(); e != nil; e = e.Next() { | ||
data := e.Value.(*BPF) | ||
if err := data.Stop(ifaceName, models.EgressType, c.HostConfig.BpfChainingEnabled); err != nil { | ||
log.Error().Err(err).Msgf("failed to remove map file for program %s => %s", ifaceName, data.Program.Name) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for e := bpfList.Front(); e != nil; e = e.Next() { | |
data := e.Value.(*BPF) | |
if err := data.Stop(ifaceName, models.EgressType, c.HostConfig.BpfChainingEnabled); err != nil { | |
log.Error().Err(err).Msgf("failed to remove map file for program %s => %s", ifaceName, data.Program.Name) | |
} | |
} | |
c.StopNRemoveAllBPFPrograms(ifaceName, models.EgressType) |
kf/nfconfig.go
Outdated
if c.IngressXDPBpfs[ifaceName] != nil { | ||
if err := c.StopNRemoveAllBPFPrograms(ifaceName, models.XDPIngressType); err != nil { | ||
log.Warn().Err(err).Msg("failed to Close Ingress XDP BPF Program") | ||
} | ||
} | ||
if c.IngressTCBpfs[ifaceName] != nil { | ||
if err := c.StopNRemoveAllBPFPrograms(ifaceName, models.IngressType); err != nil { | ||
log.Warn().Err(err).Msg("failed to Close Ingress XDP BPF Program") | ||
} | ||
} | ||
if c.EgressTCBpfs[ifaceName] != nil { | ||
if err := c.StopNRemoveAllBPFPrograms(ifaceName, models.EgressType); err != nil { | ||
log.Warn().Err(err).Msg("failed to Close Ingress XDP BPF Program") | ||
} | ||
} | ||
errOut := fmt.Errorf("%s interface name not found in the host, Stop called ", ifaceName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this code block into member function and call both the places.
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good