Skip to content

getsockopt

Partial in Antinomie 0.7.0 · Syscall list

long getsockopt(int fd, int level, int optname, char *optval, int *optlen);
Number (x86-64) 55
ABI 64
Kernel entry point sys_getsockopt

This is the raw kernel prototype from the pinned Linux 6.12.94 schema, not the libc wrapper.

Reads an option of a socket or protocol layer, identified by a level and an option name.

Name Type Meaning
fd (arg0) int File descriptor to operate on.
level (arg1) int Protocol level, SOL_SOCKET (1) or a protocol number such as IPPROTO_TCP (6).
optname (arg2) int Option name within the level.
optval (arg3) char * Buffer the kernel fills with the option value.
optlen (arg4) int * Pointer to the buffer size; the kernel writes the real size back.

On success: 0.

In an Antinomie trace the Return column and the ret filter field show the raw kernel return value. On failure that is the negative errno, for example -2 for ENOENT, not the -1 plus errno that the libc wrapper gives. syscall.errno holds the positive errno and syscall.success is false.

Raw return Name Meaning
-9 EBADF A file descriptor is not valid for this operation.
-22 EINVAL An argument is invalid.
-92 ENOPROTOOPT The protocol does not support this option.

getsockopt(2) on man7.org

Coverage mark: Partial. Known (level, option) pairs decode their value. An unknown pair records the raw bytes (up to 128 KiB) together with a “no decoder” gap, and a few nested structures are left raw.

Every call is recorded as an Entry record (the six argument words and the pointees copied at entry) and an Exit record (the return value and the pointees copied at exit).

Argument When How Recorded field key Condition
fd (arg0) Entry raw scalar word args.0, args.fd
level (arg1) Entry raw scalar word args.1, args.level
optname (arg2) Entry raw scalar word args.2, args.optname
optval (arg3) Entry the pointer itself, as a raw word args.3, args.raw[3]
↳ pointee Entry input value for the few options that also read one arg3.optval_in the option has an input layout
↳ pointee Exit the option value; known options use their layout, unknown pairs are raw bytes up to 128 KiB; length is the written length arg3.optval result is 0; “invalid extent” if the written length exceeds the capacity
optlen (arg4) Entry the pointer itself, as a raw word args.4, args.raw[4]
↳ pointee Entry and exit int: the buffer capacity at entry, and the length the kernel wrote at exit arg4.optlen at exit only when result is 0
  • Selector: (level, optname). arg4.optlen is recorded at entry as the capacity, and again at exit with the length the kernel wrote; arg3.optval is recorded at exit on success, bounded by the written length.
  • Result: ret, syscall.errno, syscall.success, syscall.duration_ns.
  • Argument words: args.fd (arg0), args.level (arg1), args.optname (arg2), args.optval (arg3), args.optlen (arg4); args.0 to args.5 by position.
  • Structure tcp_zerocopy_receive behind optval (arg3): args.optval.<member> for address, copybuf_address, copybuf_len, err, flags, inq, length, msg_control, msg_controllen, msg_flags, recv_skip_hint, reserved.
  • Structure wait_status behind optlen (arg4): args.optlen.<member> for value.

See Syscall Trace filter for the full syntax.

  • An unknown (level, optname) pair records sockopt.unknown_option with the “no decoder” status at entry.
  • See the coverage mark above for the code paths that record a gap.

For what the capture statuses mean, see Capture statuses. For what is never recorded, see Known gaps.