| #
607f1105
|
| 08-Dec-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
linux: store Linux Ethernet interface number in struct ifnet
The old approach where we go through the list of interfaces and count them has bugs. One obvious bug with this dynamic translation is th
linux: store Linux Ethernet interface number in struct ifnet
The old approach where we go through the list of interfaces and count them has bugs. One obvious bug with this dynamic translation is that once an Ethernet interface in the middle of the list goes away, all interfaces following it would change their Linux names.
A bigger problem is the ifnet arrival and departure times. For example linsysfs has event handler for ifnet_arrival_event, and of course it wants to resolve the name. This accidentially works, due to a bug in if_attach() where we call if_link_ifnet() before invoking all the event handlers. Once the bug is fixed linsysfs won't be able to resolve the old way. The other side is ifnet_departure_event, where there is no bug, the eventhandlers are called after the if_unlink_ifnet(). This means old translation won't work for departure event handlers. One example is netlink. This change gives the Netlink a chance to emit a proper Linux interface departure message.
However, there is another problem in Netlink, that the ifnet pointer is lost in the Netlink translation layer. Plug this with a cookie in netlink writer structure that can be set by the route layer and used by the Netlink Linux translation layer. This part of the diff seems unrelated, but it is hard to make it a separate change, as the old KPI goes away and to use the new one we need the pointer.
Differential Revision: https://reviews.freebsd.org/D54077
show more ...
|
| #
479e2915
|
| 15-Oct-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
linux: make linux_to_bsd_sockaddr() use memory supplied by caller
No functional change.
Differential Revision: https://reviews.freebsd.org/D52936
|
| #
9d4a08d1
|
| 29-Mar-2024 |
Gleb Smirnoff <glebius@FreeBSD.org> |
linux: use sa_family_t for address family conversions
Express "conversion failed" with maximum possible value. This allows to reduce number of size/signedness conversion in the code that utilizes t
linux: use sa_family_t for address family conversions
Express "conversion failed" with maximum possible value. This allows to reduce number of size/signedness conversion in the code that utilizes the functions.
PR: 274536 Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D44375
show more ...
|
| #
95ee2897
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
| #
5c32488d
|
| 04-Mar-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Add a counterpart to linux_ifflags
For further use in linux_ioctl_socket add bsd_to_linux_ifflags() which accepts FreeBSD interface flags and translate it to Linux if flags.
Reviewed by:
linux(4): Add a counterpart to linux_ifflags
For further use in linux_ioctl_socket add bsd_to_linux_ifflags() which accepts FreeBSD interface flags and translate it to Linux if flags.
Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D38873
show more ...
|
| #
f9b0675b
|
| 04-Mar-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Refactor socket ioctl path to avoid referencing an unstable interfaces
Split the linux_ioctl_socket() function on two counterparts, where the linux_ioctl_socket_ifreq() intended to use in
linux(4): Refactor socket ioctl path to avoid referencing an unstable interfaces
Split the linux_ioctl_socket() function on two counterparts, where the linux_ioctl_socket_ifreq() intended to use in a code path which requires the struct ifreq manipulation, i.e., translating in/out values of the struct, 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_ifreq() 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.
Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D38794
show more ...
|
| #
5d5b633d
|
| 04-Mar-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linsysfs(4): Refactor to avoid referencing an unstable interfaces
Enter the net epoch when traversing a list of interfaces. For that split the ifname_linux_to_bsd() function on two counterparts, whe
linsysfs(4): Refactor to avoid referencing an unstable interfaces
Enter the net epoch when traversing a list of interfaces. For that split the ifname_linux_to_bsd() function on two counterparts, where the ifname_linux_to_ifp() intended to use in epoch, while the ifname_linux_to_bsd() intended to be a self-contained. Until the linux_ioctl_coket() function is refactored, the ifname_linux_to_bsd() temporarily returns interface outside of the net epoch.
Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D38790
show more ...
|
| #
130383f2
|
| 04-Mar-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Make linux_ifflags return a value
To simplify the use of the function in the printf-like statements.
Differential Revision: https://reviews.freebsd.org/D38830
|
| #
3ab3c9c2
|
| 23-Feb-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Consolidate a FreeBSD interface names translation code
We have some amount of interface names translation functions which are differs by bugs implementation. Consolidates it in a one place
linux(4): Consolidate a FreeBSD interface names translation code
We have some amount of interface names translation functions which are differs by bugs implementation. Consolidates it in a one place.
Fixup loopback interface names translation and use ifnet methods and accessors, where possible.
Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D38714 MFC after: 3 days X-MFC with: 32fdc75fe7
show more ...
|
| #
09d60bfa
|
| 31-Mar-2022 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Cleanup empty lines.
MFC after: 2 weeks
|
| #
1ca6b15b
|
| 20-Jul-2021 |
Dmitry Chagin <dchagin@FreeBSD.org> |
Drop "All rights reserved" from my copyright statements.
Add email and fixup years while here.
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D30912 MFC after: 2 weeks
|
| #
26795a03
|
| 22-Jun-2021 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Rework Linux ppoll system call.
For now the Linux emulation layer uses in kernel ppoll(2) without conversion of user supplied fd 'events', and does not convert the kernel supplied fd 'reve
linux(4): Rework Linux ppoll system call.
For now the Linux emulation layer uses in kernel ppoll(2) without conversion of user supplied fd 'events', and does not convert the kernel supplied fd 'revents'.
At least POLLRDHUP is handled by FreeBSD differently than by Linux. Seems that Linux silencly ignores POLLRDHUP on non socket fd's unlike FreeBSD, which does more strictly check and fails.
Rework the Linux ppoll, using kern_poll and converting 'events' and 'revents' values. While here, move poll events defines to the MI part of code as they mostly identical on all arches except arm.
Differential Revision: https://reviews.freebsd.org/D30716 MFC after: 2 weeks
show more ...
|
| #
d5368bf3
|
| 13-May-2019 |
Dmitry Chagin <dchagin@FreeBSD.org> |
Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions alter the userspace sockaddr to convert the format between linux and BSD versions. That's the minimum 3 of copyin/copyout operations
Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions alter the userspace sockaddr to convert the format between linux and BSD versions. That's the minimum 3 of copyin/copyout operations for one syscall.
Also some syscall uses linux_sa_put() and linux_getsockaddr() when load sockaddr to userspace or from userspace accordingly.
To avoid this chaos, especially converting sockaddr in the userspace, rewrite these 4 functions to convert sockaddr only in kernel and leave only 2 of this functions.
Also in order to reduce duplication between MD parts of the Linuxulator put struct sockaddr conversion functions that are MI out into linux_common module.
PR: 232920 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20157
show more ...
|
| #
d151344d
|
| 03-May-2019 |
Dmitry Chagin <dchagin@FreeBSD.org> |
In order to reduce duplication between MD parts of the Linuxulator move bits that are MI out into the headers in compat/linux. For that remove bogus _packed attribute from struct l_sockaddr and use M
In order to reduce duplication between MD parts of the Linuxulator move bits that are MI out into the headers in compat/linux. For that remove bogus _packed attribute from struct l_sockaddr and use MI types for struct members.
And continue to move into the linux_common module a code that is intended for both Linuxulator modules (both instruction set - 32 & 64 bit) or for external modules like linsysfs or linprocfs.
To avoid header pollution introduce new sys/compat/linux_common.h header.
Reviewed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20137
show more ...
|