Skip to content

Commit 91be128

Browse files
bharathsm-mssmfrench
authored andcommitted
smb: client: show negotiated cipher in DebugData
Print the negotiated encryption cipher type in DebugData Signed-off-by: Bharath SM <[email protected]> Acked-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 72595cb commit 91be128

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,22 @@ static __always_inline const char *compression_alg_str(__le16 alg)
347347
}
348348
}
349349

350+
static __always_inline const char *cipher_alg_str(__le16 cipher)
351+
{
352+
switch (cipher) {
353+
case SMB2_ENCRYPTION_AES128_CCM:
354+
return "AES128-CCM";
355+
case SMB2_ENCRYPTION_AES128_GCM:
356+
return "AES128-GCM";
357+
case SMB2_ENCRYPTION_AES256_CCM:
358+
return "AES256-CCM";
359+
case SMB2_ENCRYPTION_AES256_GCM:
360+
return "AES256-GCM";
361+
default:
362+
return "UNKNOWN";
363+
}
364+
}
365+
350366
static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
351367
{
352368
struct mid_q_entry *mid_entry;
@@ -539,6 +555,11 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
539555
else
540556
seq_puts(m, "disabled (not supported by this server)");
541557

558+
/* Show negotiated encryption cipher, even if not required */
559+
seq_puts(m, "\nEncryption: ");
560+
if (server->cipher_type)
561+
seq_printf(m, "Negotiated cipher (%s)", cipher_alg_str(server->cipher_type));
562+
542563
seq_printf(m, "\n\n\tSessions: ");
543564
i = 0;
544565
list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
@@ -576,12 +597,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
576597

577598
/* dump session id helpful for use with network trace */
578599
seq_printf(m, " SessionId: 0x%llx", ses->Suid);
579-
if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) {
600+
if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA)
580601
seq_puts(m, " encrypted");
581-
/* can help in debugging to show encryption type */
582-
if (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)
583-
seq_puts(m, "(gcm256)");
584-
}
585602
if (ses->sign)
586603
seq_puts(m, " signed");
587604

0 commit comments

Comments
 (0)