netcat-openbsd/enable-udp-ip_recverr.patch
Peter Simons 568266e188 Accepting request 855992 from home:elvigia:branches:network:utilities
- Build with hidden visibility since no symbols should be exported 

- enable-udp-ip_recverr.patch: Enable IP_RECVERR on UDP sockets
  to match *bsd behaviour and avoid long timeouts if an error
  ocurrs.

OBS-URL: https://build.opensuse.org/request/show/855992
OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=24
2020-12-16 08:36:19 +00:00

36 lines
808 B
Diff

Index: netcat-openbsd-1.203/netcat.c
===================================================================
--- netcat-openbsd-1.203.orig/netcat.c
+++ netcat-openbsd-1.203/netcat.c
@@ -1889,6 +1889,21 @@ udptest(int s)
return 1;
}
+static int
+enable_icmp_errors (int family, int fd)
+{
+ int one = 1;
+ switch (family)
+ {
+ case AF_INET:
+ return setsockopt (fd, SOL_IP, IP_RECVERR, &one, sizeof (one));
+ case AF_INET6:
+ return setsockopt (fd, SOL_IPV6, IPV6_RECVERR, &one, sizeof (one));
+ default:
+ return -1;
+ }
+}
+
void
set_common_sockopts(int s, const struct sockaddr* sa)
{
@@ -1982,6 +1997,8 @@ set_common_sockopts(int s, const struct
errx(1, "can't set IPv6 min hop count (unavailable)");
#endif
}
+ if(uflag)
+ enable_icmp_errors(af,s);
}
int