core/socket: include remote address in the message when dropping connection
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Aug 2016 03:51:47 +0000 (23:51 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Aug 2016 12:16:31 +0000 (08:16 -0400)
Without the address the message is not very useful.

Aug 04 23:52:21 rawhide systemd[1]: testlimit.socket: Too many incoming connections (4) from source ::1, dropping connection.

src/core/socket.c

index 0d77694..b8a2f7f 100644 (file)
@@ -2187,7 +2187,7 @@ static void socket_enter_running(Socket *s, int cfd) {
                 Service *service;
 
                 if (s->n_connections >= s->max_connections) {
-                        log_unit_warning(UNIT(s), "Too many incoming connections (%u), refusing connection attempt.",
+                        log_unit_warning(UNIT(s), "Too many incoming connections (%u), dropping connection.",
                                          s->n_connections);
                         safe_close(cfd);
                         return;
@@ -2199,9 +2199,13 @@ static void socket_enter_running(Socket *s, int cfd) {
                                 safe_close(cfd);
                                 return;
                         } else if (r > 0 && p->n_ref > s->max_connections_per_source) {
+                                _cleanup_free_ char *t = NULL;
+
+                                sockaddr_pretty(&p->peer.sa, FAMILY_ADDRESS_SIZE(p->peer.sa.sa_family), true, false, &t);
+
                                 log_unit_warning(UNIT(s),
-                                                 "Too many incoming connections (%u) from source, refusing connection attempt.",
-                                                 p->n_ref);
+                                                 "Too many incoming connections (%u) from source %s, dropping connection.",
+                                                 p->n_ref, strnull(t));
                                 safe_close(cfd);
                                 return;
                         }