diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-03-19 13:00:29 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-03-19 15:29:44 +0100 |
commit | c3fecddf0d0b2cebc313989fb11cad53aa03e37a (patch) | |
tree | 6a7913a6316e9a4c34eb8961499b893533714e03 /src/basic/errno-util.h | |
parent | 594da0a3e140b1801b5f85d2be930db834d1e9cc (diff) | |
download | systemd-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.h | 13 |
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) |