summaryrefslogtreecommitdiff
path: root/src/basic/errno-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-19 13:00:29 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-19 15:29:44 +0100
commitc3fecddf0d0b2cebc313989fb11cad53aa03e37a (patch)
tree6a7913a6316e9a4c34eb8961499b893533714e03 /src/basic/errno-util.h
parent594da0a3e140b1801b5f85d2be930db834d1e9cc (diff)
downloadsystemd-c3fecddf0d0b2cebc313989fb11cad53aa03e37a.tar.gz
util: move ERRNO_IS_xyz macros to errno-util.h
It's where they fit much better.
Diffstat (limited to 'src/basic/errno-util.h')
-rw-r--r--src/basic/errno-util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h
index 2d72b8ce9e..067b4fa303 100644
--- a/src/basic/errno-util.h
+++ b/src/basic/errno-util.h
@@ -27,3 +27,16 @@ static inline int negative_errno(void) {
assert_return(errno > 0, -EINVAL);
return -errno;
}
+
+/* Hint #1: ENETUNREACH happens if we try to connect to "non-existing" special IP addresses, such as ::5.
+ *
+ * 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)
+
+/* Resource exhaustion, could be our fault or general system trouble */
+#define ERRNO_IS_RESOURCE(r) \
+ IN_SET(abs(r), ENOMEM, EMFILE, ENFILE)