]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
errno-util: add three more error codes to ERRNO_IS_DISCONNECT()
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Apr 2019 17:38:37 +0000 (19:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Apr 2019 18:03:38 +0000 (20:03 +0200)
This is based on the recommendations in accept4() and the listed error
codes there.

src/basic/errno-util.h

index 615b6a806a8d71a4e50d3a3f5e93bb54ba993550..f2677c7c19caaf6f284865fdf0258e62acef1572 100644 (file)
@@ -32,11 +32,23 @@ static inline int negative_errno(void) {
  *
  * Hint #2: The kernel sends e.g., EHOSTUNREACH or ENONET to userspace in some ICMP error cases.  See the
  *          icmp_err_convert[] in net/ipv4/icmp.c in the kernel sources */
-#define ERRNO_IS_DISCONNECT(r)                                          \
-        IN_SET(abs(r),                                                  \
-               ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, \
-               ENETUNREACH, EHOSTUNREACH, ENOPROTOOPT, EHOSTDOWN,       \
-               ENONET, ESHUTDOWN)
+static inline bool ERRNO_IS_DISCONNECT(int r) {
+        return IN_SET(abs(r),
+                      ECONNABORTED,
+                      ECONNREFUSED,
+                      ECONNRESET,
+                      EHOSTDOWN,
+                      EHOSTUNREACH,
+                      ENETDOWN,
+                      ENETRESET,
+                      ENETUNREACH,
+                      ENONET,
+                      ENOPROTOOPT,
+                      ENOTCONN,
+                      EPIPE,
+                      EPROTO,
+                      ESHUTDOWN);
+}
 
 /* Resource exhaustion, could be our fault or general system trouble */
 #define ERRNO_IS_RESOURCE(r) \