Page MenuHomeFreeBSD

linux(4): Refactor socket ioctl path to avoid referencing an unstable interfaces
ClosedPublic

Authored by dchagin on Feb 26 2023, 11:06 AM.
Referenced Files
Unknown Object (File)
Mon, Jun 24, 8:13 PM
Unknown Object (File)
May 28 2024, 8:13 AM
Unknown Object (File)
May 28 2024, 8:13 AM
Unknown Object (File)
May 28 2024, 8:13 AM
Unknown Object (File)
May 28 2024, 8:13 AM
Unknown Object (File)
May 28 2024, 8:01 AM
Unknown Object (File)
Mar 21 2024, 11:56 PM
Unknown Object (File)
Jan 1 2024, 12:01 PM
Subscribers

Details

Summary

Enter the net epoch when traversing a list of interfaces. For that
split the linux_ioctl_socket() function on two counterparts, where
the linux_ioctl_socket_ifp() intended to use in the net epoch as it
need a reference to the interface, while the linux_ioctl_socket()
function is left as is, it calls sys_ioctl() without touching in/out
values.
Due to structures ifreq, sockaddr difference between FreeBSd and Linux
the linux_ioctl_socket_ifp() calls kern_ioctl() directly, converting
in and out values to FreeBSD and to Linux accordingly.

Finally, modify the ifname_linux_to_bsd() to return error code, not
an unstable reference to the interface.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 50114
Build 47006: arc lint + arc unit

Event Timeline

It'd be nice to add something to the TESTING section to check that ioctls are still working as expected.

sys/compat/linux/linux_ioctl.c
2246–2247

Nit: what is 0xFFFF? I'd suggest having some self-describing define for that.

done, and adjust to D38873 (factor out ifname_linux_to_ifp() as it neede only for linux_ifflags

It'd be nice to add something to the TESTING section to check that ioctls are still working as expected.

sure, however we need a full build infrastructure to build linux binaries for testing

melifaro added inline comments.
sys/compat/linux/linux_ioctl.c
2470

Nit: maybe put CURVNET_SET / CURVNET_RESTORE here?
It'll simplify both linux_ioctl_socket_ifp() and reduce the need to set CURVNET in LINUX_SIOCGIFNAME / LINUX_SIOCGIFCONF / LINUX_SIOCADDMULTI /LINUX_SIOCADELMULTI hnadling.

This revision is now accepted and ready to land.Mar 3 2023, 10:36 AM

done, looks good to me now.

This revision now requires review to proceed.Mar 3 2023, 10:15 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mar 4 2023, 9:14 AM
This revision was automatically updated to reflect the committed changes.