Page MenuHomeFreeBSD

Translate 32-bit ifmedia requests into native ones.
ClosedPublic

Authored by brooks on Apr 7 2018, 12:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 16 2024, 5:53 AM
Unknown Object (File)
Dec 26 2023, 6:42 AM
Unknown Object (File)
Dec 20 2023, 12:58 AM
Unknown Object (File)
May 27 2023, 11:31 PM
Unknown Object (File)
Apr 8 2023, 4:03 AM
Unknown Object (File)
Dec 31 2022, 4:51 AM
Unknown Object (File)
Dec 24 2022, 9:35 AM
Unknown Object (File)
Nov 28 2022, 1:33 PM
Subscribers

Details

Summary

We use transformation rather than accessors as virtually ever driver
implements SIOCGIFMEDIA and all would have to be touched.

Keep the code readable by always performing copies and (possiably no-op)
transforms.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

  • Always exit via the same path so we can re-convert ifmediareqs.

This version works with an i386 ifconfig binary and is ready for review.

sys/net/if.c
2958 ↗(On Diff #41298)

Presumably we don't actually need to malloc for the native ones? That is, you could initialize 'ifmr' to NULL before this switch and then remove the non-compat ones from this switch. Down in the out_noref handler you would do:

out_noref:
     if (ifmr != NULL) {
         ifmr_update(ifmr, saved_data);
         free(ifmr, M_TEMP);
     }

This would avoid doing the malloc + free for native binaries but you can still extend this approach for other compat ABIs. You could also remove handling for the default ABI from ifmr_init() and ifmr_update(). In the current patch I would say you could make all the code using ifmr be under COMPAT_FREEBSD32. For other ABIs you would end up with some oprtions that are '#if defined(COMPAT_FREEBSD32) || defined(COMPAT_FOO)'

Why do you need malloc() at all ? The structures seems to be not so large that the stack usage become a problem.

  • Only use extra storage in compat mode and use the stack for the temporary.
  • Fix !COMPAT_FREEBSD32 builds post rebase.

I've retested the revised version of this change and it's working fine.

This revision is now accepted and ready to land.Apr 24 2018, 7:35 PM
This revision was automatically updated to reflect the committed changes.