1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00
wireguard-go/conn
Jordan Whited 334b605e72 conn: fix StdNetEndpoint data race by dynamically allocating endpoints
In 9e2f386 ("conn, device, tun: implement vectorized I/O on Linux"), the
Linux-specific Bind implementation was collapsed into StdNetBind. This
introduced a race on StdNetEndpoint from getSrcFromControl() and
setSrcControl().

Remove the sync.Pool involved in the race, and simplify StdNetBind's
receive path to allocate StdNetEndpoint on the heap instead, with the
intent for it to be cleaned up by the GC, later. This essentially
reverts ef5c587 ("conn: remove the final alloc per packet receive"),
adding back that allocation, unfortunately.

This does slightly increase resident memory usage in higher throughput
scenarios. StdNetBind is the only Bind implementation that was using
this Endpoint recycling technique prior to this commit.

This is considered a stop-gap solution, and there are plans to replace
the allocation with a better mechanism.

Reported-by: lsc <lsc@lv6.tw>
Link: https://lore.kernel.org/wireguard/ac87f86f-6837-4e0e-ec34-1df35f52540e@lv6.tw/
Fixes: 9e2f386 ("conn, device, tun: implement vectorized I/O on Linux")
Cc: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: James Tucker <james@tailscale.com>
Signed-off-by: Jordan Whited <jordan@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-24 14:37:13 +01:00
..
bindtest global: buff -> buf 2023-03-13 17:55:53 +01:00
winrio global: bump copyright year 2023-02-07 20:39:29 -03:00
bind_std_test.go global: buff -> buf 2023-03-13 17:55:53 +01:00
bind_std.go conn: fix StdNetEndpoint data race by dynamically allocating endpoints 2023-03-24 14:37:13 +01:00
bind_windows.go global: buff -> buf 2023-03-13 17:55:53 +01:00
boundif_android.go conn, device, tun: implement vectorized I/O on Linux 2023-03-10 14:52:17 +01:00
conn_test.go global: buff -> buf 2023-03-13 17:55:53 +01:00
conn.go global: buff -> buf 2023-03-13 17:55:53 +01:00
controlfns_linux.go conn: disable sticky sockets on Android 2023-03-23 18:39:00 +01:00
controlfns_unix.go conn: set SO_{SND,RCV}BUF to 7MB on the Bind UDP socket 2023-03-10 14:52:20 +01:00
controlfns_windows.go conn: set SO_{SND,RCV}BUF to 7MB on the Bind UDP socket 2023-03-10 14:52:20 +01:00
controlfns.go conn: set SO_{SND,RCV}BUF to 7MB on the Bind UDP socket 2023-03-10 14:52:20 +01:00
default.go conn, device, tun: implement vectorized I/O on Linux 2023-03-10 14:52:17 +01:00
mark_default.go conn, device, tun: implement vectorized I/O on Linux 2023-03-10 14:52:17 +01:00
mark_unix.go conn, device, tun: implement vectorized I/O on Linux 2023-03-10 14:52:17 +01:00
sticky_default.go conn: disable sticky sockets on Android 2023-03-23 18:39:00 +01:00
sticky_linux_test.go conn: disable sticky sockets on Android 2023-03-23 18:39:00 +01:00
sticky_linux.go conn: disable sticky sockets on Android 2023-03-23 18:39:00 +01:00