mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-07-04 00:06:43 -04:00
module-rtp-source: Detect and drop packets that are larger than the MTU
This commit is contained in:
parent
20f17c73de
commit
2f94a49962
1 changed files with 20 additions and 1 deletions
|
|
@ -311,9 +311,22 @@ on_rtp_io(void *data, int fd, uint32_t mask)
|
|||
current_time = get_time_ns(impl);
|
||||
|
||||
if (mask & SPA_IO_IN) {
|
||||
if ((len = recvfrom(fd, impl->buffer, impl->buffer_size, 0, (struct sockaddr *)(&recvaddr), &recvaddr_len)) < 0)
|
||||
if ((len = recvfrom(fd, impl->buffer, impl->buffer_size,
|
||||
#ifdef __linux__
|
||||
/* Use this Linux specific feature to get the actual size of the
|
||||
* packet, even if it was truncated due to it being larger than
|
||||
* the buffer size. The code below uses this to detect packets
|
||||
* that exceed the MTU size. */
|
||||
MSG_TRUNC,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
(struct sockaddr *)(&recvaddr), &recvaddr_len)) < 0)
|
||||
goto receive_error;
|
||||
|
||||
if (SPA_UNLIKELY((size_t)len > impl->buffer_size))
|
||||
goto packet_larger_than_mtu;
|
||||
|
||||
/* Filter the packets to exclude those with source addresses
|
||||
* that do not match the expected one. Only used with unicast.
|
||||
* (The bind() call in make_socket takes care of only
|
||||
|
|
@ -373,6 +386,12 @@ short_packet:
|
|||
pw_log_warn("(%d suppressed) short packet of len %zd received",
|
||||
suppressed, len);
|
||||
return;
|
||||
packet_larger_than_mtu:
|
||||
if ((suppressed = spa_ratelimit_test(&impl->rate_limit, current_time)) >= 0)
|
||||
pw_log_warn("(%d suppressed) packet received that is larger than "
|
||||
"the configured MTU (%zu bytes)",
|
||||
suppressed, impl->buffer_size);
|
||||
return;
|
||||
}
|
||||
|
||||
static int rejoin_igmp_group(struct spa_loop *loop, bool async, uint32_t seq,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue