socket: downgrade log warnings about inability to set socket buffer sizes
authorLennart Poettering <lennart@poettering.net>
Fri, 11 Sep 2020 17:58:54 +0000 (19:58 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 12 Sep 2020 12:15:19 +0000 (14:15 +0200)
In containers we might lack the privs to up the socket buffers. Let's
not complain so loudly about that. Let's hence downgrade this to debug
logging if it's a permission problem.

(This wasn't an issue before b92f350789e33942be0cf85af22a580c1fd483d6
because back then the failures wouldn't be detected at all.)

(cherry picked from commit 35b4e3c1bc7d4001244ff3986c084152c8901d03)

src/core/socket.c

index 33e6013b03e7ce3f1fee29756581da2e878719bb..809cac68a9f6999025994ef1af6b833702f1c350 100644 (file)
@@ -1075,13 +1075,15 @@ static void socket_apply_socket_options(Socket *s, int fd) {
         if (s->receive_buffer > 0) {
                 r = fd_set_rcvbuf(fd, s->receive_buffer, false);
                 if (r < 0)
-                        log_unit_warning_errno(UNIT(s), r, "SO_RCVBUF/SO_RCVBUFFORCE failed: %m");
+                        log_unit_full_errno(UNIT(s), ERRNO_IS_PRIVILEGE(r) ? LOG_DEBUG : LOG_WARNING, r,
+                                            "SO_RCVBUF/SO_RCVBUFFORCE failed: %m");
         }
 
         if (s->send_buffer > 0) {
                 r = fd_set_sndbuf(fd, s->send_buffer, false);
                 if (r < 0)
-                        log_unit_warning_errno(UNIT(s), r, "SO_SNDBUF/SO_SNDBUFFORCE failed: %m");
+                        log_unit_full_errno(UNIT(s), ERRNO_IS_PRIVILEGE(r) ? LOG_DEBUG : LOG_WARNING, r,
+                                            "SO_SNDBUF/SO_SNDBUFFORCE failed: %m");
         }
 
         if (s->mark >= 0) {