Skip to content

fix sockopt syscalls #309

Open
Open
@qianxichen233

Description

@qianxichen233

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions