Skip to content

net: ListenMulticastUDP doesn't limit data to packets from the declared group port on Linux #73484

Open
@mrinny

Description

@mrinny

What version of Go are you using (go version)?

$ go version
go version go1.23.7 linux/amd64

Does this issue reproduce with the latest release?

yes, also tested on 1.24.2 linux/amd64
tested on
debian trixie - kernel 6.12.22-amd64
ubuntu 24.04 - kernel 6.8.0-51-generic

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/vclaes/.cache/go-build'
GOENV='/home/vclaes/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/vclaes/go/pkg/mod'
GONOPROXY='git.pulsar-lab.be/*'
GONOSUMDB='git.pulsar-lab.be/*'
GOOS='linux'
GOPATH='/home/vclaes/go'
GOPRIVATE='git.pulsar-lab.be/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/vclaes/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/vclaes/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.7'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/vclaes/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/vclaes/Documents/git/pulsarlab/playground/tadaa/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1225361755=/tmp/go-build -gno-record-gcc-switches'
uname -sr: Linux 6.12.22-amd64
Distributor ID:	Debian
Description:	Debian GNU/Linux trixie/sid
Release:	n/a
Codename:	trixie
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.41-7) stable release version 2.41.
gdb --version: GNU gdb (Debian 16.2-8) 16.2

What did you do?

join a multicast group using net.ListenMulticastUDP.

example / repoduction scenario

A sender process sends multicast packets every second on group A (239.0.10.10).
A proxy process listens for multicast packets on group A if a packet is received it sends a packet with different content on group B (239.0.10.11)
A receiver process listens for multicast packets on group B

mc_sender process: https://gist.github.com/mrinny/3c948eb86fc9cfa151cdf4b089980cbc
mc_proxy process: https://gist.github.com/mrinny/bbe1884dea72a4d08ad4101301f9b258
mc_receiver process: https://gist.github.com/mrinny/2e38dede9d32ebea222b28176537b55f

What did you expect to see?

reading from the connection should only return data send to multicast group which was decared as the remote address (group address and port).

the proxy process prints out "hello world" every second
the receiver process prints out "hello proxy" every second

What did you see instead?

Data from any linux kernel joined group is being returned by calling ReadFromUDP.

The proxy process prints out "hello world" followed by lots of "hello proxy"
the proxy process prints out "hello proxy"

Further Information

On OSX the behavior seems to be as expected.

The example reproduction uses three go programs to demonstrate the issue. Though it can also be observed with other programs.
For example:

  1. run the go proxy process
  2. start ffmpeg as a dummy multicast source "ffmpeg -re -f lavfi -i testsrc=size=960x540:rate=1 -r 1 -c:v libx264 -preset fast -tune zerolatency -crf 28 -g 10 -f rtp rtp://239.0.2.1:3000?pkt_size=1280"
  3. start iperf to make the linux ip stack join the multicast group. "iperf -u -s -B 239.0.2.1"
    The moment the linux ip stack joins the multicast group. I start seeing the proxy process printout the binary video data. While the poxy process never actually joined the group being used for the rtp multicast.

Instead of the call ListenMulticastUDP I've also tried the net.ListenPacket => ipv4.PacketConn => JoinGroup approach. Though this gives the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions