gstreamer/subprojects/gst-plugins-good/gst/udp
Jonas K Danielsson 20e3454c26 udpsrc: Disable allocated port reuse for unicast
The `reuse` property end up setting the SO_REUSEADDR socket option for
the UDP socket. This setting have surprising effects.

On Linux systems the man page (`socket(7)`) states:
```
SO_REUSEADDR
    Indicates that the rules used in validating addresses supplied
    in a bind(2) call should allow reuse of local addresses. For
    AF_INET sockets this means that a socket may bind, except when
    there is an active listening socket bound to the address.
```

But since UDP does not listen this ends up meaning that when an
ephemeral port is allocated (setting the `port` to `0`) the kernel is
free to reuse any other UDP port that has `SO_REUSEADDR` set.

Tests checking the likelyhood of port conflict when using multiple
`udpsrc` shows port conflicts starting to occur after ~100-300 udpsrc
with port allocation enabled. See issue #3411 for more details.

Changing the default value of a property is not a small thing we risk
breaking application that rely on the current default value. But since
the effects of having `reuse` default `TRUE` on can also have damaging
and hard-to-debug consequences, it might be worth to consider.

Having `SO_REUSEADDR` enabled for multicast, might have some use cases
but for unicast, with dynamic port allocation, it does not make sense.

When not using an multicast address we will disable port reuse if the
`port` property is set to 0 (=allocate) and warn the user that we did
so.

Closes #3411

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7841>
2024-11-06 10:21:14 +00:00
..
gstdynudpsink.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstdynudpsink.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstmultiudpsink.c multiudpsink: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstmultiudpsink.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstudp.c udpsrc: Add support for IGMPv3 SSM 2023-04-12 16:32:07 +00:00
gstudpelement.c Bump GLib requirement to >= 2.62 2022-06-10 06:01:41 +00:00
gstudpelements.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstudpnetutils.c udpsrc: Add support for IGMPv3 SSM 2023-04-12 16:32:07 +00:00
gstudpnetutils.h udpsrc: Add support for IGMPv3 SSM 2023-04-12 16:32:07 +00:00
gstudpsink.c udpsrc: Add support for IGMPv3 SSM 2023-04-12 16:32:07 +00:00
gstudpsink.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstudpsrc.c udpsrc: Disable allocated port reuse for unicast 2024-11-06 10:21:14 +00:00
gstudpsrc.h udpsrc: Add support for IGMPv3 SSM 2023-04-12 16:32:07 +00:00
meson.build meson: Call pkgconfig.generate in the loop where we declare plugins dependencies 2022-09-01 21:17:35 +00:00
README Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00

* What is UDP src/sink?

It is a set of element to transfer data using UDP, nothing more, nothing less.
Its main purpose is to be used in conjunction with RTP but they are kept as
separate elements because we can.