public inbox for hail-devel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [chunkd patch 4/6] Print client port
Date: Thu, 20 May 2010 22:54:31 -0600	[thread overview]
Message-ID: <20100520225431.4cf7a05a@redhat.com> (raw)

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");

             reply	other threads:[~2010-05-21  4:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-21  4:54 Pete Zaitcev [this message]
2010-05-25 22:23 ` [chunkd patch 4/6] Print client port Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100520225431.4cf7a05a@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox