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

proposal: x/sys/unix: make withData public #65903

Open
leongross opened this issue Feb 23, 2024 · 3 comments
Open

proposal: x/sys/unix: make withData public #65903

leongross opened this issue Feb 23, 2024 · 3 comments
Labels
Milestone

Comments

@leongross
Copy link

Proposal Details

The ifreq functionality through the Ifreq interface and its IoctlIfreq interface currently do not offer the flexibility it could have.
A simple example would be to issue some ioctl where ifr should be a pointer.
There are of course workarounds for that (e.g. issuing raw ioctls via the syscall API and providing a byte slice) but adding a more robust interface like already supposed would be a good idea.
I currently don't see any reason why not to expose this already existing functionality, but maybe I miss a bigger structural point here.

If you do not have enough resources for implementing this change I'd be happy to help you out on that.

The code suggests that @mdlayher once thought about exporting access to IfreqData, but postponed it due accessibility through IoctlGetEthtoolDrvinfo. This although is read only.

@gopherbot gopherbot added this to the Proposal milestone Feb 23, 2024
@seankhliao seankhliao changed the title proposal: golang.org/x/sys/unix/: make withData public proposal: x/sys/unix: make withData public Feb 23, 2024
@mdlayher
Copy link
Member

To clarify: what are you trying to do? IIRC my intent was to avoid exposing an unsafe.Pointer in the API, in favor of exposing type-safe wrappers for each type we need.

@leongross
Copy link
Author

I want to issue an ioctl call that passes as an argument an Ifreq struct that holds custom ifr data that is a uintptr. The API calls for Ifreq although only expose methods to SetInet4Addr, SetUint16, SetUint32, none of which is suitable to set a pointer value (64bit) for https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if.h#L253.

Alternatively, one could add an interface to set 64bit values or even arbitrary byte slices to ifr.raw.Ifru.

@mdlayher
Copy link
Member

A pointer to what struct exactly? Is there a concrete C struct we can generate to give you a type safe API for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

3 participants