From 55df9354fc783ca743285537a6190f4fe4703e77 Mon Sep 17 00:00:00 2001 From: Mahe Tardy Date: Tue, 28 Jan 2025 19:33:27 +0100 Subject: [PATCH] pkg/sensors: TcUnloader do not detach on unpin false Same as previous commit for tc unloader. Signed-off-by: Mahe Tardy --- pkg/sensors/unloader/unloader.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/sensors/unloader/unloader.go b/pkg/sensors/unloader/unloader.go index 1b2dd62f0d2..b1895a2d0dd 100644 --- a/pkg/sensors/unloader/unloader.go +++ b/pkg/sensors/unloader/unloader.go @@ -110,10 +110,15 @@ type TcAttachment struct { IsIngress bool } -func (tu TcUnloader) Unload(_ bool) error { - for _, att := range tu.Attachments { - if err := detachTC(att.LinkName, att.IsIngress); err != nil { - return err +func (tu TcUnloader) Unload(unpin bool) error { + // PROG_ATTACH does not return any link, so there's nothing to unpin, + // but we must skip the detach operation for 'unpin == false' otherwise + // the pinned program will be un-attached + if unpin { + for _, att := range tu.Attachments { + if err := detachTC(att.LinkName, att.IsIngress); err != nil { + return err + } } } return nil