Skip to content

Commit 2ac0ec5

Browse files
authored
fix: load config before attaching redirect ebpf program to hook (#312)
* fix: load config before attaching redirect ebpf program to hook Signed-off-by: Matheus Pimenta <[email protected]> * chore: release 0.13.1 Signed-off-by: Matheus Pimenta <[email protected]> --------- Signed-off-by: Matheus Pimenta <[email protected]>
1 parent 8dee2ea commit 2ac0ec5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

internal/redirect/redirect.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ func LoadAndAttachBPF(emulatorIP netip.Addr, emulatorPort int, debug bool) (*BPF
4646
return nil, fmt.Errorf("error loading redirect eBPF redirect objects: %w", err)
4747
}
4848

49-
var err error
50-
b.link, err = link.AttachCgroup(link.CgroupOptions{
51-
Path: "/sys/fs/cgroup",
52-
Attach: ebpf.AttachCGroupInet4Connect,
53-
Program: b.objs.RedirectConnect4,
54-
})
55-
if err != nil {
56-
return nil, fmt.Errorf("error attaching redirect eBPF program to cgroup: %w", err)
57-
}
58-
5949
emulatorIPv4 := emulatorIP.As4()
6050
config := redirectConfig{
6151
EmulatorIp: binary.BigEndian.Uint32(emulatorIPv4[:]),
@@ -69,6 +59,16 @@ func LoadAndAttachBPF(emulatorIP netip.Addr, emulatorPort int, debug bool) (*BPF
6959
return nil, fmt.Errorf("error updating redirect eBPF config map: %w", err)
7060
}
7161

62+
var err error
63+
b.link, err = link.AttachCgroup(link.CgroupOptions{
64+
Path: "/sys/fs/cgroup",
65+
Attach: ebpf.AttachCGroupInet4Connect,
66+
Program: b.objs.RedirectConnect4,
67+
})
68+
if err != nil {
69+
return nil, fmt.Errorf("error attaching redirect eBPF program to cgroup: %w", err)
70+
}
71+
7272
return &b, nil
7373
}
7474

versions.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
helm: 0.13.0
24-
timoni: 0.13.0
25-
container: 0.13.0
23+
helm: 0.13.1
24+
timoni: 0.13.1
25+
container: 0.13.1

0 commit comments

Comments
 (0)