All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb
@ 2021-07-09  5:17 Cong Wang
  2021-07-09  5:17 ` [Patch net-next] net_sched: use %px to print skb address in trace_qdisc_dequeue() Cong Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Cong Wang @ 2021-07-09  5:17 UTC (permalink / raw)
  To: netdev; +Cc: Qitao Xu, Cong Wang

From: Qitao Xu <qitao.xu@bytedance.com>

The print format of skb adress in tracepoint class net_dev_template
is changed to %px from %p, because we want to use skb address
as a quick way to identify a packet.

Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
---
 include/trace/events/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/trace/events/net.h b/include/trace/events/net.h
index 2399073c3afc..78c448c6ab4c 100644
--- a/include/trace/events/net.h
+++ b/include/trace/events/net.h
@@ -136,7 +136,7 @@ DECLARE_EVENT_CLASS(net_dev_template,
 		__assign_str(name, skb->dev->name);
 	),
 
-	TP_printk("dev=%s skbaddr=%p len=%u",
+	TP_printk("dev=%s skbaddr=%px len=%u",
 		__get_str(name), __entry->skbaddr, __entry->len)
 )
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Patch net-next] net_sched: use %px to print skb address in trace_qdisc_dequeue()
  2021-07-09  5:17 [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb Cong Wang
@ 2021-07-09  5:17 ` Cong Wang
  2021-07-09  5:17 ` [Patch net-next] net_sched: introduce tracepoint trace_qdisc_enqueue() Cong Wang
  2021-07-09  8:16 ` [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Cong Wang @ 2021-07-09  5:17 UTC (permalink / raw)
  To: netdev; +Cc: Qitao Xu, Cong Wang

From: Qitao Xu <qitao.xu@bytedance.com>

Print format of skbaddr is changed to %px from %p, because we want
to use skb address as a quick way to identify a packet.

Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
---
 include/trace/events/qdisc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/trace/events/qdisc.h b/include/trace/events/qdisc.h
index 330d32d84485..58209557cb3a 100644
--- a/include/trace/events/qdisc.h
+++ b/include/trace/events/qdisc.h
@@ -41,7 +41,7 @@ TRACE_EVENT(qdisc_dequeue,
 		__entry->txq_state	= txq->state;
 	),
 
-	TP_printk("dequeue ifindex=%d qdisc handle=0x%X parent=0x%X txq_state=0x%lX packets=%d skbaddr=%p",
+	TP_printk("dequeue ifindex=%d qdisc handle=0x%X parent=0x%X txq_state=0x%lX packets=%d skbaddr=%px",
 		  __entry->ifindex, __entry->handle, __entry->parent,
 		  __entry->txq_state, __entry->packets, __entry->skbaddr )
 );
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Patch net-next] net_sched: introduce tracepoint trace_qdisc_enqueue()
  2021-07-09  5:17 [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb Cong Wang
  2021-07-09  5:17 ` [Patch net-next] net_sched: use %px to print skb address in trace_qdisc_dequeue() Cong Wang
@ 2021-07-09  5:17 ` Cong Wang
  2021-07-09  8:16 ` [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Cong Wang @ 2021-07-09  5:17 UTC (permalink / raw)
  To: netdev; +Cc: Qitao Xu, Cong Wang

From: Qitao Xu <qitao.xu@bytedance.com>

Tracepoint trace_qdisc_enqueue() is introduced to trace skb at
the entrance of TC layer on TX side. This is similar to
trace_qdisc_dequeue().

Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
---
 include/trace/events/qdisc.h | 26 ++++++++++++++++++++++++++
 net/core/dev.c               |  9 +++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/trace/events/qdisc.h b/include/trace/events/qdisc.h
index 58209557cb3a..c3006c6b4a87 100644
--- a/include/trace/events/qdisc.h
+++ b/include/trace/events/qdisc.h
@@ -46,6 +46,32 @@ TRACE_EVENT(qdisc_dequeue,
 		  __entry->txq_state, __entry->packets, __entry->skbaddr )
 );
 
+TRACE_EVENT(qdisc_enqueue,
+
+	TP_PROTO(struct Qdisc *qdisc, const struct netdev_queue *txq, struct sk_buff *skb),
+
+	TP_ARGS(qdisc, txq, skb),
+
+	TP_STRUCT__entry(
+		__field(struct Qdisc *, qdisc)
+		__field(void *,	skbaddr)
+		__field(int, ifindex)
+		__field(u32, handle)
+		__field(u32, parent)
+	),
+
+	TP_fast_assign(
+		__entry->qdisc = qdisc;
+		__entry->skbaddr = skb;
+		__entry->ifindex = txq->dev ? txq->dev->ifindex : 0;
+		__entry->handle	 = qdisc->handle;
+		__entry->parent	 = qdisc->parent;
+	),
+
+	TP_printk("enqueue ifindex=%d qdisc handle=0x%X parent=0x%X skbaddr=%px",
+		  __entry->ifindex, __entry->handle, __entry->parent, __entry->skbaddr)
+);
+
 TRACE_EVENT(qdisc_reset,
 
 	TP_PROTO(struct Qdisc *q),
diff --git a/net/core/dev.c b/net/core/dev.c
index c253c2aafe97..20b9376de301 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -131,6 +131,7 @@
 #include <trace/events/napi.h>
 #include <trace/events/net.h>
 #include <trace/events/skb.h>
+#include <trace/events/qdisc.h>
 #include <linux/inetdevice.h>
 #include <linux/cpu_rmap.h>
 #include <linux/static_key.h>
@@ -3864,6 +3865,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 			if (unlikely(!nolock_qdisc_is_empty(q))) {
 				rc = q->enqueue(skb, q, &to_free) &
 					NET_XMIT_MASK;
+				if (rc == NET_XMIT_SUCCESS)
+					trace_qdisc_enqueue(q, txq, skb);
 				__qdisc_run(q);
 				qdisc_run_end(q);
 
@@ -3880,6 +3883,9 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 		}
 
 		rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK;
+		if (rc == NET_XMIT_SUCCESS)
+			trace_qdisc_enqueue(q, txq, skb);
+
 		qdisc_run(q);
 
 no_lock_out:
@@ -3924,6 +3930,9 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 		rc = NET_XMIT_SUCCESS;
 	} else {
 		rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK;
+		if (rc == NET_XMIT_SUCCESS)
+			trace_qdisc_enqueue(q, txq, skb);
+
 		if (qdisc_run_begin(q)) {
 			if (unlikely(contended)) {
 				spin_unlock(&q->busylock);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb
  2021-07-09  5:17 [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb Cong Wang
  2021-07-09  5:17 ` [Patch net-next] net_sched: use %px to print skb address in trace_qdisc_dequeue() Cong Wang
  2021-07-09  5:17 ` [Patch net-next] net_sched: introduce tracepoint trace_qdisc_enqueue() Cong Wang
@ 2021-07-09  8:16 ` David Miller
  2021-07-09 18:59   ` Cong Wang
  2 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2021-07-09  8:16 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, qitao.xu, cong.wang

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu,  8 Jul 2021 22:17:08 -0700

> From: Qitao Xu <qitao.xu@bytedance.com>
> 
> The print format of skb adress in tracepoint class net_dev_template
> is changed to %px from %p, because we want to use skb address
> as a quick way to identify a packet.
> 
> Reviewed-by: Cong Wang <cong.wang@bytedance.com>
> Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>

Aren't we not supposed to leak kernel addresses to userspace?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb
  2021-07-09  8:16 ` [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb David Miller
@ 2021-07-09 18:59   ` Cong Wang
  2021-07-09 19:18     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Cong Wang @ 2021-07-09 18:59 UTC (permalink / raw)
  To: David Miller; +Cc: Linux Kernel Network Developers, Qitao Xu, Cong Wang .

On Fri, Jul 9, 2021 at 1:16 AM David Miller <davem@davemloft.net> wrote:
>
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Thu,  8 Jul 2021 22:17:08 -0700
>
> > From: Qitao Xu <qitao.xu@bytedance.com>
> >
> > The print format of skb adress in tracepoint class net_dev_template
> > is changed to %px from %p, because we want to use skb address
> > as a quick way to identify a packet.
> >
> > Reviewed-by: Cong Wang <cong.wang@bytedance.com>
> > Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
>
> Aren't we not supposed to leak kernel addresses to userspace?

Right, but trace ring buffer is only accessible to privileged users,
so leaking it to root is not a problem.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb
  2021-07-09 18:59   ` Cong Wang
@ 2021-07-09 19:18     ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2021-07-09 19:18 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, qitao.xu, cong.wang

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri, 9 Jul 2021 11:59:43 -0700

> On Fri, Jul 9, 2021 at 1:16 AM David Miller <davem@davemloft.net> wrote:
>>
>> From: Cong Wang <xiyou.wangcong@gmail.com>
>> Date: Thu,  8 Jul 2021 22:17:08 -0700
>>
>> > From: Qitao Xu <qitao.xu@bytedance.com>
>> >
>> > The print format of skb adress in tracepoint class net_dev_template
>> > is changed to %px from %p, because we want to use skb address
>> > as a quick way to identify a packet.
>> >
>> > Reviewed-by: Cong Wang <cong.wang@bytedance.com>
>> > Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
>>
>> Aren't we not supposed to leak kernel addresses to userspace?
> 
> Right, but trace ring buffer is only accessible to privileged users,
> so leaking it to root is not a problem.

Please explain this in your commit msgs and resubmit.

Thank you.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-09 19:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09  5:17 [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb Cong Wang
2021-07-09  5:17 ` [Patch net-next] net_sched: use %px to print skb address in trace_qdisc_dequeue() Cong Wang
2021-07-09  5:17 ` [Patch net-next] net_sched: introduce tracepoint trace_qdisc_enqueue() Cong Wang
2021-07-09  8:16 ` [Patch net-next] net: use %px to print skb address in trace_netif_receive_skb David Miller
2021-07-09 18:59   ` Cong Wang
2021-07-09 19:18     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.