@@ -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
0 commit comments