Skip to content

[main][linux] set IP(6)_RECVERR on connected datagram sockets. #8635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,20 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&val, sizeof(val));
}
}
#endif
#ifdef __linux__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really Linux specific, or should we check if IP_RECVERR and IPV6_RECVERR are defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The misbehaviour? Yes. o..in other OSs if exists just enables icmp error reporting, which PHP does not currently consume at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other oses do not have anything close to this, it s really a Linux extension. The FreeBSD's Linux compat layer send an unsupported op warning in this case.

if (socktype == SOCK_DGRAM) {
int val = 1;
switch (sa->sa_family)
{
case AF_INET:
setsockopt(sock, SOL_IP, IP_RECVERR, &val, sizeof (val));
break;
case AF_INET6:
setsockopt(sock, SOL_IPV6, IPV6_RECVERR, &val, sizeof (val));
break;
}
}
#endif
n = php_network_connect_socket(sock, sa, socklen, asynchronous,
timeout ? &working_timeout : NULL,
Expand Down