Skip to content

Improve SO_BROADCAST stubs#3471

Merged
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:so-broadcast
Dec 28, 2024
Merged

Improve SO_BROADCAST stubs#3471
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:so-broadcast

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

@stevenengler stevenengler commented Dec 22, 2024

Previously, we had stubs for setsockopt with SO_BROADCAST for tcp and udp:

(libc::SOL_SOCKET, libc::SO_BROADCAST) => {
    // TODO: implement this, pkg.go.dev/net uses it
    log::trace!("setsockopt SO_BROADCAST not yet implemented");
}

The old behaviour for tcp/udp was:

  • getsockopt:
    • return ENOPROTOOPT
  • setsockopt:
    • show trace (for tcp) or "warn_once_then_debug" (for udp) log and return 0

The new behaviour for tcp/udp is:

  • getsockopt:
    • always returns 0 since we don't support broadcast sockets
  • setsockopt:
    • if value is 0, do nothing and return 0
    • if value is not 0, show "warn_once_then_debug" log and return 0

Our tests aren't set up to test get/setsockopt for unix sockets, so I didn't implement the option for unix sockets. I would expect it to return an error.

Closes #3439.

@stevenengler stevenengler self-assigned this Dec 22, 2024
@github-actions github-actions bot added Component: Testing Unit and integration tests and frameworks Component: Main Composing the core Shadow executable labels Dec 22, 2024
@github-actions github-actions bot added the Component: Documentation In-repository documentation, under docs/ label Dec 22, 2024
We don't yet support broadcast sockets, so we return 0 for getsockopt
and don't warn if given 0 for setsockopt.
@stevenengler stevenengler merged commit 6e55617 into shadow:main Dec 28, 2024
@stevenengler stevenengler deleted the so-broadcast branch December 28, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Documentation In-repository documentation, under docs/ Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support SO_BROADCAST udp socket option with getsockopt

2 participants