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

fix sockopt syscalls #309

Open
qianxichen233 opened this issue Jul 17, 2024 · 0 comments
Open

fix sockopt syscalls #309

qianxichen233 opened this issue Jul 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@qianxichen233
Copy link
Contributor

Current implementation of getsockopt and setsockopt has some issues and may need a overhaul:

  1. The design of the option value and the way the option is set might not be appropriate and may lead to issues like overflowing the flag
  2. Some Linux socket options constants are missing. Instead these option constants seem to be from other OS like MacOS.

Linux implementation of sockopt syscalls is using two layer of flags. The first layer of flag is what the user is using (SO_LINGER, SO_OOBINLINE, etc) and is valued based on bit position (0x01, 0x04, 0x08, etc). Upon receiving these options, Linux will use another internal flag to actually set the socket options stored in sk_flags. These internal flags are enum type and are therefore valued in sequence instead. when set, Linux is calling __set_bit to set the corresponding bit refered by internal flag in sk_flags.

@qianxichen233 qianxichen233 added the bug Something isn't working label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant