Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1212709 > unrolled thread

[PATCH 2/2] net: sunrpc: fix trace print of &xprt->xpt_remote

Started byPratyush Anand <panand@redhat.com>
First post2015-08-25 08:10 +0200
Last post2015-08-26 22:40 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] net: sunrpc: fix trace print of &xprt->xpt_remote Pratyush Anand <panand@redhat.com> - 2015-08-25 08:10 +0200
    Re: [PATCH 2/2] net: sunrpc: fix trace print of &xprt->xpt_remote Jeff Layton <jlayton@poochiereds.net> - 2015-08-26 12:40 +0200
      Re: [PATCH 2/2] net: sunrpc: fix trace print of &xprt->xpt_remote Steven Rostedt <rostedt@goodmis.org> - 2015-08-26 22:40 +0200

#1212709 — [PATCH 2/2] net: sunrpc: fix trace print of &xprt->xpt_remote

FromPratyush Anand <panand@redhat.com>
Date2015-08-25 08:10 +0200
Subject[PATCH 2/2] net: sunrpc: fix trace print of &xprt->xpt_remote
Message-ID<q1fAJ-6pU-5@gated-at.bofh.it>
TP_printk() for svc_xprt_dequeue intends to print address of
xprt->xpt_remote, however it prints address of another structure where
xprt->xpt_remote has been copied.

This patch fixes the above behaviour.

Signed-off-by: Pratyush Anand <panand@redhat.com>
---
 include/trace/events/sunrpc.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
index 937e482d80e9..37b6af1a911a 100644
--- a/include/trace/events/sunrpc.h
+++ b/include/trace/events/sunrpc.h
@@ -556,19 +556,19 @@ TRACE_EVENT(svc_xprt_dequeue,
 
 	TP_STRUCT__entry(
 		__field(struct svc_xprt *, xprt)
-		__field_struct(struct sockaddr_storage, ss)
+		__field(struct sockaddr *, addr)
 		__field(unsigned long, flags)
 	),
 
 	TP_fast_assign(
-		__entry->xprt = xprt,
-		xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss));
+		__entry->xprt = xprt;
+		__entry->addr =
+			xprt ? (struct sockaddr *)&xprt->xpt_remote : NULL;
 		__entry->flags = xprt ? xprt->xpt_flags : 0;
 	),
 
 	TP_printk("xprt=0x%p addr=%pIScp flags=%s", __entry->xprt,
-		(struct sockaddr *)&__entry->ss,
-		show_svc_xprt_flags(__entry->flags))
+		__entry->addr, show_svc_xprt_flags(__entry->flags))
 );
 
 TRACE_EVENT(svc_wake_up,
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1213726

FromJeff Layton <jlayton@poochiereds.net>
Date2015-08-26 12:40 +0200
Message-ID<q1GhA-38h-29@gated-at.bofh.it>
In reply to#1212709
On Tue, 25 Aug 2015 11:34:20 +0530
Pratyush Anand <panand@redhat.com> wrote:

> TP_printk() for svc_xprt_dequeue intends to print address of
> xprt->xpt_remote, however it prints address of another structure where
> xprt->xpt_remote has been copied.
> 
> This patch fixes the above behaviour.
> 
> Signed-off-by: Pratyush Anand <panand@redhat.com>
> ---
>  include/trace/events/sunrpc.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
> index 937e482d80e9..37b6af1a911a 100644
> --- a/include/trace/events/sunrpc.h
> +++ b/include/trace/events/sunrpc.h
> @@ -556,19 +556,19 @@ TRACE_EVENT(svc_xprt_dequeue,
>  
>  	TP_STRUCT__entry(
>  		__field(struct svc_xprt *, xprt)
> -		__field_struct(struct sockaddr_storage, ss)
> +		__field(struct sockaddr *, addr)
>  		__field(unsigned long, flags)
>  	),
>  
>  	TP_fast_assign(
> -		__entry->xprt = xprt,
> -		xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss));
> +		__entry->xprt = xprt;
> +		__entry->addr =
> +			xprt ? (struct sockaddr *)&xprt->xpt_remote : NULL;

NAK, this is wrong. %pIScp will dereference that address so you don't
want to pass a NULL pointer to it. We do want to save a copy of the
sockaddr.

>  		__entry->flags = xprt ? xprt->xpt_flags : 0;
>  	),
>  
>  	TP_printk("xprt=0x%p addr=%pIScp flags=%s", __entry->xprt,
> -		(struct sockaddr *)&__entry->ss,
> -		show_svc_xprt_flags(__entry->flags))
> +		__entry->addr, show_svc_xprt_flags(__entry->flags))
>  );
>  
>  TRACE_EVENT(svc_wake_up,


-- 
Jeff Layton <jlayton@poochiereds.net>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1214177

FromSteven Rostedt <rostedt@goodmis.org>
Date2015-08-26 22:40 +0200
Message-ID<q1PEe-89i-17@gated-at.bofh.it>
In reply to#1213726
On Wed, 26 Aug 2015 06:32:55 -0400
Jeff Layton <jlayton@poochiereds.net> wrote:

 
> >  	TP_fast_assign(
> > -		__entry->xprt = xprt,
> > -		xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss));
> > +		__entry->xprt = xprt;
> > +		__entry->addr =
> > +			xprt ? (struct sockaddr *)&xprt->xpt_remote : NULL;
> 
> NAK, this is wrong. %pIScp will dereference that address so you don't

Ug, I hate that printk option. It can be dangerous.

> want to pass a NULL pointer to it. We do want to save a copy of the
> sockaddr.

Save just enough for what you need to print out. Don't waste any space
on the ring buffer that isn't necessary.

-- Steve

> 
> >  		__entry->flags = xprt ? xprt->xpt_flags : 0;
> >  	),
> >  
> >  	TP_printk("xprt=0x%p addr=%pIScp flags=%s", __entry->xprt,
> > -		(struct sockaddr *)&__entry->ss,
> > -		show_svc_xprt_flags(__entry->flags))
> > +		__entry->addr, show_svc_xprt_flags(__entry->flags))
> >  );
> >  
> >  TRACE_EVENT(svc_wake_up,
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web