maintainer-feedback requested: [Bug 281409] audio/pulseaudio: 16.1_4 IP_TOS failed when socket is PF_INET6

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 10 Sep 2024 07:06:27 UTC
Bugzilla Automation <bugzilla@FreeBSD.org> has asked freebsd-desktop (Team)
<desktop@FreeBSD.org> for maintainer-feedback:
Bug 281409: audio/pulseaudio: 16.1_4 IP_TOS failed when socket is PF_INET6
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281409



--- Description ---
pulseaudio-16.1_4 outputs a log similar to the following

(   0.212|   0.000) [tunnel-sink][../src/pulsecore/socket-util.c:172
pa_make_tcp_socket_low_delay()] IP_TOS failed: Invalid argument

This seems to occur when the socket is for IPv6.
I don't know if this is something that happens only with FreeBSD, or if it is
something that upstream should take care of for all operating systems.
pulseaudio-17.0 still has the same code.

The following is a program in which only the relevant part is extracted and the
difference between PF_INET and PF_INET6 is introduced.

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int
main()
{
	int i, fd;
	int tos;

#if 1
	fd = socket(PF_INET6, SOCK_STREAM, 0);
#else
	fd = socket(PF_INET, SOCK_STREAM, 0);
#endif

	tos = IPTOS_LOWDELAY;

	i = setsockopt(fd, IPPROTO_IP, IP_TOS, (const void *)&tos, sizeof tos);
	if (i == -1) {
		printf("IP_TOS failed: %s\n", strerror(errno));
	}

	close(fd);

	return 0;
}