From 1fc7fdace0103105caad1ece34ae7712de5274b1 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Mon, 27 Oct 2014 22:41:55 +0000 Subject: [PATCH] krping: In verbose mode print only first 128 bytes of krping data. Submitted by: Hariprasad at Chelsio dot com. Sponsored by: Chelsio Communications --- sys/contrib/rdma/krping/krping.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c index 228063605728..a770423cfde8 100644 --- a/sys/contrib/rdma/krping/krping.c +++ b/sys/contrib/rdma/krping/krping.c @@ -1011,9 +1011,17 @@ static void krping_test_server(struct krping_cb *cb) DEBUG_LOG(cb, "server received read complete\n"); /* Display data in recv buf */ - if (cb->verbose) - PRINTF(cb, "server ping data: %s\n", - cb->rdma_buf); + if (cb->verbose) { + if (strlen(cb->rdma_buf) > 128) { + char msgbuf[128]; + + strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf)); + PRINTF(cb, "server ping data stripped: %s\n", + msgbuf); + } else + PRINTF(cb, "server ping data: %s\n", + cb->rdma_buf); + } /* Tell client to continue */ if (cb->server && cb->server_invalidate) { @@ -1713,8 +1721,16 @@ static void krping_test_client(struct krping_cb *cb) break; } - if (cb->verbose) - PRINTF(cb, "ping data: %s\n", cb->rdma_buf); + if (cb->verbose) { + if (strlen(cb->rdma_buf) > 128) { + char msgbuf[128]; + + strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf)); + PRINTF(cb, "ping data stripped: %s\n", + msgbuf); + } else + PRINTF(cb, "ping data: %s\n", cb->rdma_buf); + } #ifdef SLOW_KRPING wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ); #endif