[pve-devel] [PATCH http-server 3/3] add debug log for problems during accept

Stoiko Ivanov s.ivanov at proxmox.com
Thu Dec 3 19:43:22 CET 2020


Co-Authored-by: Dominik Csapak <d.csapak at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 PVE/APIServer/AnyEvent.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
index 7038b07..d33f6b0 100644
--- a/PVE/APIServer/AnyEvent.pm
+++ b/PVE/APIServer/AnyEvent.pm
@@ -1520,6 +1520,11 @@ sub check_host_access {
 
     my $cip = Net::IP->new($clientip);
 
+    if (!$cip) {
+	print "$$: check_host_access: clientip not parsable: $@\n" if $self->{debug};
+	return 0;
+    }
+
     my $match_allow = 0;
     my $match_deny = 0;
 
@@ -1527,6 +1532,7 @@ sub check_host_access {
 	foreach my $t (@{$self->{allow_from}}) {
 	    if ($t->overlaps($cip)) {
 		$match_allow = 1;
+		print "$$: check_host_access: clientip allowed: ". $t->prefix() . "\n" if $self->{debug};
 		last;
 	    }
 	}
@@ -1535,6 +1541,7 @@ sub check_host_access {
     if ($self->{deny_from}) {
 	foreach my $t (@{$self->{deny_from}}) {
 	    if ($t->overlaps($cip)) {
+		print "$$: check_host_access: clientip denied: ". $t->prefix() . "\n" if $self->{debug};
 		$match_deny = 1;
 		last;
 	    }
@@ -1571,6 +1578,7 @@ sub accept_connections {
 		my ($pfamily, $pport, $phost) = PVE::Tools::unpack_sockaddr_in46($sin);
 		($reqstate->{peer_port}, $reqstate->{peer_host}) = ($pport,  Socket::inet_ntop($pfamily, $phost));
 	    } else {
+		print "$$: ACCEPT connection: getpeername failed: $!\n" if $self->{debug};
 		shutdown($clientfh, 1);
 		next;
 	    }
@@ -1619,6 +1627,7 @@ sub accept_connections {
 
     if (my $err = $@) {
 	syslog('err', $err);
+	print "$$: ACCEPT connection error: $err\n" if $self->{debug};
 	shutdown($clientfh, 1) if $early_err;
 	$self->{end_loop} = 1;
     }
-- 
2.20.1






More information about the pve-devel mailing list