ksmbd: fix non-IPv6 build
Subsystems (2)
PATCH 1/1 ksmbd: fix non-IPv6 build
From: Arnd Bergmann <[email protected]>
The newly added procfs code fails to build when CONFIG_IPv6 is disabled:
fs/smb/server/connection.c: In function 'proc_show_clients':fs/smb/server/connection.c:47:58: error: 'struct ksmbd_conn' has no member named 'inet6_addr'; did you mean 'inet_addr'?
47 | seq_printf(m, "%-20pI6c", &conn->inet6_addr);
| ^~~~~~~~~~
| inet_addr
make[7]: *** [scripts/Makefile.build:279: fs/smb/server/connection.o] Error 1
fs/smb/server/mgmt/user_session.c: In function 'show_proc_sessions':
fs/smb/server/mgmt/user_session.c:215:65: error: 'struct ksmbd_conn' has no member named 'inet6_addr'; did you mean 'inet_addr'?
215 | seq_printf(m, " %-40pI6c", &chan->conn->inet6_addr);
| ^~~~~~~~~~
| inet_addrRearrange the condition to allow adding a simple preprocessor conditional.
---
Alternatively, the corresponding check in the ksmbd_conn could be removed, which would waste a few bytes per connection but avoid the #ifdef.
--- fs/smb/server/connection.c | 8 +++++--- fs/smb/server/mgmt/user_session.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-)
fs/smb/server/connection.c +5 -3
@@ -41,10 +41,12 @@ static int proc_show_clients(struct seq_file *m, void *v)jiffies_to_timespec64 (jiffies - conn->last_active, &t);ktime_get_real_ts64 (&now); t =timespec64_sub (now, t); -if (conn->inet_addr) -seq_printf (m,"%-20pI4" , &conn->inet_addr); -else +#if IS_ENABLED (CONFIG_IPV6 ) +if (!conn->inet_addr)seq_printf (m,"%-20pI6c" , &conn->inet6_addr); + else +#endif +seq_printf (m,"%-20pI4" , &conn->inet_addr); seq_printf(m, " 0x%-10x %-10u %-12d %-10d %ptT\n", conn->dialect, conn->total_credits,
fs/smb/server/mgmt/user_session.c +5 -3
@@ -209,10 +209,12 @@ static int show_proc_sessions(struct seq_file *m, void *v)down_read (&chan->conn->session_lock);ksmbd_user_session_get (session); -if (chan->conn->inet_addr) -seq_printf (m," %-40pI4" , &chan->conn->inet_addr); -else +#if IS_ENABLED (CONFIG_IPV6 ) +if (!chan->conn->inet_addr)seq_printf (m," %-40pI6c" , &chan->conn->inet6_addr); + else +#endif +seq_printf (m," %-40pI4" , &chan->conn->inet_addr); seq_printf(m, " %-15s %-10llu %-10s\n", session_user_name(session), session->id,
Signature · 1 line
2.39.5
Quoted 17 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The newly added procfs code fails to build when
CONFIG_IPv6is disabled:
fs/smb/server/connection.c: In function 'proc_show_clients':fs/smb/server/connection.c:47:58: error: 'structksmbd_conn' has no member named 'inet6_addr'; did you mean 'inet_addr'?47 | seq_printf(m, "%-20pI6c", &conn->inet6_addr); | ^~~~~~~~~~ | inet_addr make[7]: *** [scripts/Makefile.build:279: fs/smb/server/connection.o] Error 1 fs/smb/server/mgmt/user_session.c: In function 'show_proc_sessions': fs/smb/server/mgmt/user_session.c:215:65: error: 'struct ksmbd_conn' has no member named 'inet6_addr'; did you mean 'inet_addr'? 215 | seq_printf(m, " %-40pI6c", &chan->conn->inet6_addr); | ^~~~~~~~~~ | inet_addr
Quoted 4 lines
Rearrange the condition to allow adding a simple preprocessor conditional.
Fixes b38f99c1217a ("ksmbd: add procfs interface for runtime monitoring and statistics")Signed-off-by Arnd Bergmann <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks!