net: use %px to print skb address in trace_netif_receive_skb
Subsystems (3)
PATCH 1/1 net: use %px to print skb address in trace_netif_receive_skb
From: Qitao Xu <[email protected]>
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.
--- include/trace/events/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/net.h +1 -1
@@ -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) )
Signature · 1 line
2.27.0
PATCH 1/1 net_sched: use %px to print skb address in trace_qdisc_dequeue()
From: Qitao Xu <[email protected]>
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.
--- include/trace/events/qdisc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/qdisc.h +1 -1
@@ -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 ) );
Signature · 1 line
2.27.0
PATCH 1/1 net_sched: introduce tracepoint trace_qdisc_enqueue()
In reply to Cong WangFrom: Qitao Xu <[email protected]>
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().
--- include/trace/events/qdisc.h | 26 ++++++++++++++++++++++++++ net/core/dev.c | 9 +++++++++ 2 files changed, 35 insertions(+)
include/trace/events/qdisc.h +26 -0
@@ -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),
net/core/dev.c +9 -0
@@ -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);
Signature · 1 line
2.27.0
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Thu, 8 Jul 2021 22:17:08 -0700
Quoted 8 lines
From: Qitao Xu <[email protected]>
The print format of skb adress in tracepoint class
net_dev_templateis changed to %px from %p, because we want to use skb address as a quick way to identify a packet.Reviewed-by Cong Wang <[email protected]>Signed-off-by Qitao Xu <[email protected]>
Aren't we not supposed to leak kernel addresses to userspace?
Quoted 6 lines · David Miller
From: Cong Wang <[email protected]>
Date: Thu, 8 Jul 2021 22:17:08 -0700Quoted 2 lines
From: Qitao Xu <[email protected]>
Quoted 8 lines
Quoted 6 lines
The print format of skb adress in tracepoint class
net_dev_templateis changed to %px from %p, because we want to use skb address as a quick way to identify a packet.Reviewed-by Cong Wang <[email protected]>Signed-off-by Qitao Xu <[email protected]>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.
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Fri, 9 Jul 2021 11:59:43 -0700
Quoted 11 lines · David Miller
Quoted 10 lines
From: Cong Wang <[email protected]>
Date: Thu, 8 Jul 2021 22:17:08 -0700Quoted 6 lines
From: Qitao Xu <[email protected]>
The print format of skb adress in tracepoint class
net_dev_templateis changed to %px from %p, because we want to use skb address as a quick way to identify a packet.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Reviewed-by Cong Wang <[email protected]>Signed-off-by Qitao Xu <[email protected]>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.