diff --git a/client/internal/wgproxy/ebpf/bpf_bpfeb.go b/client/internal/wgproxy/ebpf/bpf_bpfeb.go index 4943513ef..c4875c3ae 100644 --- a/client/internal/wgproxy/ebpf/bpf_bpfeb.go +++ b/client/internal/wgproxy/ebpf/bpf_bpfeb.go @@ -54,14 +54,14 @@ type bpfSpecs struct { // // It can be passed ebpf.CollectionSpec.Assign. type bpfProgramSpecs struct { - XdpProgFunc *ebpf.ProgramSpec `ebpf:"xdp_prog_func"` + NbWgProxy *ebpf.ProgramSpec `ebpf:"nb_wg_proxy"` } // bpfMapSpecs contains maps before they are loaded into the kernel. // // It can be passed ebpf.CollectionSpec.Assign. type bpfMapSpecs struct { - XdpPortMap *ebpf.MapSpec `ebpf:"xdp_port_map"` + NbWgProxySettingsMap *ebpf.MapSpec `ebpf:"nb_wg_proxy_settings_map"` } // bpfObjects contains all objects after they have been loaded into the kernel. @@ -83,12 +83,12 @@ func (o *bpfObjects) Close() error { // // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign. type bpfMaps struct { - XdpPortMap *ebpf.Map `ebpf:"xdp_port_map"` + NbWgProxySettingsMap *ebpf.Map `ebpf:"nb_wg_proxy_settings_map"` } func (m *bpfMaps) Close() error { return _BpfClose( - m.XdpPortMap, + m.NbWgProxySettingsMap, ) } @@ -96,12 +96,12 @@ func (m *bpfMaps) Close() error { // // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign. type bpfPrograms struct { - XdpProgFunc *ebpf.Program `ebpf:"xdp_prog_func"` + NbWgProxy *ebpf.Program `ebpf:"nb_wg_proxy"` } func (p *bpfPrograms) Close() error { return _BpfClose( - p.XdpProgFunc, + p.NbWgProxy, ) } diff --git a/client/internal/wgproxy/ebpf/bpf_bpfeb.o b/client/internal/wgproxy/ebpf/bpf_bpfeb.o index c3aa757d6..82d7fc35b 100644 Binary files a/client/internal/wgproxy/ebpf/bpf_bpfeb.o and b/client/internal/wgproxy/ebpf/bpf_bpfeb.o differ diff --git a/client/internal/wgproxy/ebpf/bpf_bpfel.go b/client/internal/wgproxy/ebpf/bpf_bpfel.go index cac39aa01..5a2ce3bb8 100644 --- a/client/internal/wgproxy/ebpf/bpf_bpfel.go +++ b/client/internal/wgproxy/ebpf/bpf_bpfel.go @@ -54,14 +54,14 @@ type bpfSpecs struct { // // It can be passed ebpf.CollectionSpec.Assign. type bpfProgramSpecs struct { - XdpProgFunc *ebpf.ProgramSpec `ebpf:"xdp_prog_func"` + NbWgProxy *ebpf.ProgramSpec `ebpf:"nb_wg_proxy"` } // bpfMapSpecs contains maps before they are loaded into the kernel. // // It can be passed ebpf.CollectionSpec.Assign. type bpfMapSpecs struct { - XdpPortMap *ebpf.MapSpec `ebpf:"xdp_port_map"` + NbWgProxySettingsMap *ebpf.MapSpec `ebpf:"nb_wg_proxy_settings_map"` } // bpfObjects contains all objects after they have been loaded into the kernel. @@ -83,12 +83,12 @@ func (o *bpfObjects) Close() error { // // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign. type bpfMaps struct { - XdpPortMap *ebpf.Map `ebpf:"xdp_port_map"` + NbWgProxySettingsMap *ebpf.Map `ebpf:"nb_wg_proxy_settings_map"` } func (m *bpfMaps) Close() error { return _BpfClose( - m.XdpPortMap, + m.NbWgProxySettingsMap, ) } @@ -96,12 +96,12 @@ func (m *bpfMaps) Close() error { // // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign. type bpfPrograms struct { - XdpProgFunc *ebpf.Program `ebpf:"xdp_prog_func"` + NbWgProxy *ebpf.Program `ebpf:"nb_wg_proxy"` } func (p *bpfPrograms) Close() error { return _BpfClose( - p.XdpProgFunc, + p.NbWgProxy, ) } diff --git a/client/internal/wgproxy/ebpf/bpf_bpfel.o b/client/internal/wgproxy/ebpf/bpf_bpfel.o index d8b24d641..2fc0ff8fc 100644 Binary files a/client/internal/wgproxy/ebpf/bpf_bpfel.o and b/client/internal/wgproxy/ebpf/bpf_bpfel.o differ diff --git a/client/internal/wgproxy/ebpf/loader.go b/client/internal/wgproxy/ebpf/loader.go index 48ac59dc2..e154c0d9e 100644 --- a/client/internal/wgproxy/ebpf/loader.go +++ b/client/internal/wgproxy/ebpf/loader.go @@ -50,22 +50,22 @@ func (l *EBPF) Load(proxyPort, wgPort int) error { _ = objs.Close() }() - err = objs.XdpPortMap.Put(mapKeyProxyPort, uint16(proxyPort)) + err = objs.NbWgProxySettingsMap.Put(mapKeyProxyPort, uint16(proxyPort)) if err != nil { return err } - err = objs.XdpPortMap.Put(mapKeyWgPort, uint16(wgPort)) + err = objs.NbWgProxySettingsMap.Put(mapKeyWgPort, uint16(wgPort)) if err != nil { return err } defer func() { - _ = objs.XdpPortMap.Close() + _ = objs.NbWgProxySettingsMap.Close() }() l.link, err = link.AttachXDP(link.XDPOptions{ - Program: objs.XdpProgFunc, + Program: objs.NbWgProxy, Interface: ifce.Index, }) if err != nil { diff --git a/client/internal/wgproxy/ebpf/src/portreplace.c b/client/internal/wgproxy/ebpf/src/portreplace.c index 25994116b..dc95ee53f 100644 --- a/client/internal/wgproxy/ebpf/src/portreplace.c +++ b/client/internal/wgproxy/ebpf/src/portreplace.c @@ -15,7 +15,7 @@ const __u32 map_key_proxy_port = 0; const __u32 map_key_wg_port = 1; -struct bpf_map_def SEC("maps") xdp_port_map = { +struct bpf_map_def SEC("maps") nb_wg_proxy_settings_map = { .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(__u32), .value_size = sizeof(__u16), @@ -27,14 +27,14 @@ __u16 wg_port = 0; bool read_port_settings() { __u16 *value; - value = bpf_map_lookup_elem(&xdp_port_map, &map_key_proxy_port); + value = bpf_map_lookup_elem(&nb_wg_proxy_settings_map, &map_key_proxy_port); if(!value) { return false; } proxy_port = *value; - value = bpf_map_lookup_elem(&xdp_port_map, &map_key_wg_port); + value = bpf_map_lookup_elem(&nb_wg_proxy_settings_map, &map_key_wg_port); if(!value) { return false; } @@ -44,7 +44,7 @@ bool read_port_settings() { } SEC("xdp") -int xdp_prog_func(struct xdp_md *ctx) { +int nb_wg_proxy(struct xdp_md *ctx) { if(proxy_port == 0 || wg_port == 0) { if(!read_port_settings()){ return XDP_PASS;