diff options
author | Cristian RodrÃguez <crodriguez@owncloud.com> | 2020-12-17 11:27:03 -0300 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-12-21 15:24:08 +0100 |
commit | d13179db3e88ddcca087175e35332c2b04b08770 (patch) | |
tree | e4acb4bc09f98d6bd378aa64b3313858539ed68b | |
parent | a7696c73436f643d5d31ce0c3d48d282c79f4b5d (diff) | |
download | curl-d13179db3e88ddcca087175e35332c2b04b08770.tar.gz |
connect: on linux, enable reporting of all ICMP errors on UDP sockets
The linux kernel does not report all ICMP errors back to userspace due
to historical reasons.
IP*_RECVERR sockopt must be turned on to have the correct behaviour
which is to pass all ICMP errors to userspace.
See https://bugzilla.kernel.org/show_bug.cgi?id=202355
Closes #6341
-rw-r--r-- | lib/connect.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/connect.c b/lib/connect.c index 251145ce1..f7aa26019 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -1574,6 +1574,20 @@ CURLcode Curl_socket(struct connectdata *conn, } #endif +#if defined(__linux__) && defined(IP_RECVERR) + if(addr->socktype == SOCK_DGRAM) { + int one = 1; + switch(addr->family) { + case AF_INET: + setsockopt(*sockfd, SOL_IP, IP_RECVERR, &one, sizeof(one)); + break; + case AF_INET6: + setsockopt(*sockfd, SOL_IPV6, IPV6_RECVERR, &one, sizeof(one)); + break; + } + } +#endif + return CURLE_OK; } |