public inbox for hail-devel@vger.kernel.org
 help / color / mirror / Atom feed
* [chunkd patch 4/6] Print client port
@ 2010-05-21  4:54 Pete Zaitcev
  2010-05-25 22:23 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2010-05-21  4:54 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

The originating port is interesting when the same client contacts the
chunkserver several times and we, for example, look at that with tcpdump.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

---
 server/chunkd.h |    1 +
 server/server.c |   11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

commit 7e2cc1ad8b1de3e33402147841d794e13b4f65f9
Author: Master <zaitcev@lembas.zaitcev.lan>
Date:   Thu May 20 21:32:43 2010 -0600

    Print port too (to match against tcpdump, for example).

diff --git a/server/chunkd.h b/server/chunkd.h
index e5721cd..47e6f95 100644
--- a/server/chunkd.h
+++ b/server/chunkd.h
@@ -84,6 +84,7 @@ struct client {
 
 	struct sockaddr_in6	addr;		/* inet address */
 	char			addr_host[64];	/* ASCII version of inet addr */
+	char			addr_port[16];	/* ASCII version of port */
 	int			fd;		/* socket */
 
 	char			user[CHD_USER_SZ + 1];
diff --git a/server/server.c b/server/server.c
index de9e6a8..2d2f6c3 100644
--- a/server/server.c
+++ b/server/server.c
@@ -343,7 +343,8 @@ static void cli_write_free_all(struct client *cli)
 
 static void cli_free(struct client *cli)
 {
-	applog(LOG_INFO, "client %s disconnected", cli->addr_host);
+	applog(LOG_INFO, "client host %s port %s disconnected",
+	       cli->addr_host, cli->addr_port);
 
 	cli_write_free_all(cli);
 
@@ -1341,6 +1342,7 @@ static bool tcp_srv_event(int fd, short events, void *userdata)
 	socklen_t addrlen = sizeof(struct sockaddr_in6);
 	struct client *cli;
 	char host[64];
+	char port[16];
 	int on = 1;
 	struct server_poll *sp;
 
@@ -1381,13 +1383,16 @@ static bool tcp_srv_event(int fd, short events, void *userdata)
 
 	/* pretty-print incoming cxn info */
 	memset(host, 0, sizeof(host));
+	memset(port, 0, sizeof(port));
 	getnameinfo((struct sockaddr *) &cli->addr, addrlen,
-		    host, sizeof(host), NULL, 0, NI_NUMERICHOST);
+		    host, sizeof(host), port, sizeof(port), NI_NUMERICHOST);
 	host[sizeof(host) - 1] = 0;
-	applog(LOG_INFO, "client %s connected%s", host,
+	host[sizeof(port) - 1] = 0;
+	applog(LOG_INFO, "client host %s port %s connected%s", host, port,
 		cli->ssl ? " via SSL" : "");
 
 	strcpy(cli->addr_host, host);
+	strcpy(cli->addr_port, port);
 
 	if (!srv_poll_ready(fd))
 		applog(LOG_ERR, "unable to ready srv fd for polling");

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [chunkd patch 4/6] Print client port
  2010-05-21  4:54 [chunkd patch 4/6] Print client port Pete Zaitcev
@ 2010-05-25 22:23 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2010-05-25 22:23 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Project Hail List

On 05/21/2010 12:54 AM, Pete Zaitcev wrote:
> -		    host, sizeof(host), NULL, 0, NI_NUMERICHOST);
> +		    host, sizeof(host), port, sizeof(port), NI_NUMERICHOST);
>   	host[sizeof(host) - 1] = 0;
> -	applog(LOG_INFO, "client %s connected%s", host,
> +	host[sizeof(port) - 1] = 0;


You truncate the wrong variable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-25 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-21  4:54 [chunkd patch 4/6] Print client port Pete Zaitcev
2010-05-25 22:23 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox