Re: [PATCH v4 15/21] IB/srpt: Log private data associated with REJ

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

 



On 02/11/2016 02:08 PM, Bart Van Assche wrote:
> To make it possible to determine why an initiator sent a REJ,
> log the private data associated with the received REJ packet.

This particular function is all sorts of broken...I fixed it up as I
took it in.  But, issues were:

1) We always allocate priv even when private_data_len is 0
2) Since we always allocate priv, the test for priv in the pr_info args
isn't really helpful, but the way the test is set up, if priv exists,
then we actually pass NULL, if it doesn't, we pass the static string.
3) In the event we have priv and private data, then there is a nit about
formatting because priv will end with a space right before the null
terminator, which makes the period in the pr_info format hang out in
open space.

My changes:

1) Only alloc priv if private_data_len is not 0
2) Change priv to be space prepended instead of space postpended
3) Change pr_info format to work with space prepended string
4) Fix test in pr_info args

> Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> Cc: Sagi Grimberg <sagig@xxxxxxxxxxxx>
> Cc: Alex Estrin <alex.estrin@xxxxxxxxx>
> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 10bc133..d9bac93 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -2252,8 +2252,17 @@ static void srpt_cm_rej_recv(struct srpt_rdma_ch *ch,
>  			     const u8 *private_data,
>  			     u8 private_data_len)
>  {
> -	pr_info("Received CM REJ for ch %s-%d; reason %d.\n",
> -		ch->sess_name, ch->qp->qp_num, reason);
> +	char *priv = kmalloc(private_data_len * 3 + 1, GFP_KERNEL);
> +	int i;
> +
> +	if (priv) {
> +		priv[0] = '\0';
> +		for (i = 0; i < private_data_len; i++)
> +			sprintf(priv + 3 * i, "%02x ", private_data[i]);
> +	}
> +	pr_info("Received CM REJ for ch %s-%d; reason %d; private data %s.\n",
> +		ch->sess_name, ch->qp->qp_num, reason, priv ? : "(?)");
> +	kfree(priv);
>  	srpt_drain_channel(ch);
>  }
>  
> 


-- 
Doug Ledford <dledford@xxxxxxxxxx>
              GPG KeyID: 0E572FDD


Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux