[chunkd patch 4/6] Print client port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

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

commit 7e2cc1ad8b1de3e33402147841d794e13b4f65f9
Author: Master <zaitcev@xxxxxxxxxxxxxxxxxx>
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");
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux