Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys/unix: allow setting tcp repair options #46984

Closed
dandare100 opened this issue Jun 30, 2021 · 2 comments
Closed

x/sys/unix: allow setting tcp repair options #46984

dandare100 opened this issue Jun 30, 2021 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dandare100
Copy link

go version go1.16.5 linux/amd64

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

I would like to add a function (in syscall_unix.go) to set the socket repair options.
There are a few "typed" functions that exist already (unix.SetsockoptInt,SetsockoptInet4Addr,SetsockoptLinger) and I see this new function sitting alongside them.

The reason I would like to add it is because I cannot currently see a way to pass in the repair options in the way they need to be passed in.

An example of doing this call in C is

setsockopt(sk, SOL_TCP, TCP_REPAIR_OPTIONS,
opts, 4 * sizeof(struct tcp_repair_opt)

where opts is

struct tcp_repair_opt opts[4]

and tcp_repair_opts from tcp.h is

/* For socket repair options. */
struct tcp_repair_opt
{
u_int32_t opt_code;
u_int32_t opt_val;
};

There is no way (that I can see, please help if I am incorrect) to do this syscall in that manner, given the protection the go api has with the typed/named functions.

The work would be :

  1. Add the tcp_repair_opt struct as TcpRepairOpt struct alongside the other structs in x/sys/unix/linux/types.go that are auto generated to x/sys/unix/ztypes_linux_amd64.go at build time. This tcp_repair_opt linux struct is currently found in the netinet/tcp.h linux header file

  2. Add a function SetsockoptRepairOpt(fd, level, opt int, o []TcpRepairOpt) (err error) {

Would this be worth adding ?

@seankhliao seankhliao changed the title /x/sys/unix Allow for setting tcp repair options proposal: x/sys/unix: allow setting tcp repair options Jun 30, 2021
@gopherbot gopherbot added this to the Proposal milestone Jun 30, 2021
@ianlancetaylor
Copy link
Contributor

We don't usually use the proposal process for x/sys changes, which mostly just involve adding ways to access system-specific functionality.

This idea seems fine at first glance. Thanks.

@ianlancetaylor ianlancetaylor changed the title proposal: x/sys/unix: allow setting tcp repair options x/sys/unix: allow setting tcp repair options Jun 30, 2021
@ianlancetaylor ianlancetaylor added NeedsFix The path to resolution is known, but the work has not been done. and removed Proposal labels Jun 30, 2021
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Unreleased Jun 30, 2021
@gopherbot
Copy link

Change https://golang.org/cl/332709 mentions this issue: unix: add SetsockoptTcpRepairOpt on Linux

@golang golang locked and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants