Skip to content

Commit 9ec1c6a

Browse files
Jakub Kicinskidavem330
authored andcommitted
net/tls: add device decrypted trace point
Add a tracepoint to the TLS offload's fast path. This tracepoint can be used to track the decrypted and encrypted status of received records. Records decrypted by the device should have decrypted set to 1, records which have neither decrypted nor decrypted set are partially decrypted, require re-encryption and therefore are most expensive to deal with. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8538d29 commit 9ec1c6a

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎net/tls/tls_device.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ int tls_device_decrypted(struct sock *sk, struct sk_buff *skb)
850850
{
851851
struct tls_context *tls_ctx = tls_get_ctx(sk);
852852
struct tls_offload_context_rx *ctx = tls_offload_ctx_rx(tls_ctx);
853+
struct strp_msg *rxm = strp_msg(skb);
853854
int is_decrypted = skb->decrypted;
854855
int is_encrypted = !is_decrypted;
855856
struct sk_buff *skb_iter;
@@ -860,6 +861,10 @@ int tls_device_decrypted(struct sock *sk, struct sk_buff *skb)
860861
is_encrypted &= !skb_iter->decrypted;
861862
}
862863

864+
trace_tls_device_decrypted(sk, tcp_sk(sk)->copied_seq - rxm->full_len,
865+
tls_ctx->rx.rec_seq, rxm->full_len,
866+
is_encrypted, is_decrypted);
867+
863868
ctx->sw.decrypted |= is_decrypted;
864869

865870
/* Return immediately if the record is either entirely plaintext or

‎net/tls/trace.h‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,39 @@ TRACE_EVENT(tls_device_offload_set,
4141
)
4242
);
4343

44+
TRACE_EVENT(tls_device_decrypted,
45+
46+
TP_PROTO(struct sock *sk, u32 tcp_seq, u8 *rec_no, u32 rec_len,
47+
bool encrypted, bool decrypted),
48+
49+
TP_ARGS(sk, tcp_seq, rec_no, rec_len, encrypted, decrypted),
50+
51+
TP_STRUCT__entry(
52+
__field( struct sock *, sk )
53+
__field( u64, rec_no )
54+
__field( u32, tcp_seq )
55+
__field( u32, rec_len )
56+
__field( bool, encrypted )
57+
__field( bool, decrypted )
58+
),
59+
60+
TP_fast_assign(
61+
__entry->sk = sk;
62+
__entry->rec_no = get_unaligned_be64(rec_no);
63+
__entry->tcp_seq = tcp_seq;
64+
__entry->rec_len = rec_len;
65+
__entry->encrypted = encrypted;
66+
__entry->decrypted = decrypted;
67+
),
68+
69+
TP_printk(
70+
"sk=%p tcp_seq=%u rec_no=%llu len=%u encrypted=%d decrypted=%d",
71+
__entry->sk, __entry->tcp_seq,
72+
__entry->rec_no, __entry->rec_len,
73+
__entry->encrypted, __entry->decrypted
74+
)
75+
);
76+
4477
TRACE_EVENT(tls_device_rx_resync_send,
4578

4679
TP_PROTO(struct sock *sk, u32 tcp_seq, u8 *rec_no, int sync_type),

0 commit comments

Comments
 (0)