Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ $(obj)/ksmbd_spnego_negtokentarg.asn1.o: $(obj)/ksmbd_spnego_negtokentarg.asn1.c

ksmbd-$(CONFIG_SMB_INSECURE_SERVER) += smb1pdu.o smb1ops.o smb1misc.o netmisc.o
ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o
ksmbd-$(CONFIG_PROC_FS) += proc.o
else
# For external module build
EXTRA_FLAGS += -I$(PWD)
Expand Down
55 changes: 55 additions & 0 deletions connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "connection.h"
#include "transport_tcp.h"
#include "transport_rdma.h"
#include "misc.h"

static DEFINE_MUTEX(init_lock);

Expand All @@ -25,6 +26,58 @@ static struct ksmbd_conn_ops default_conn_ops;
DEFINE_HASHTABLE(conn_list, CONN_HASH_BITS);
DECLARE_RWSEM(conn_list_lock);

#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_clients;

static int proc_show_clients(struct seq_file *m, void *v)
{
struct ksmbd_conn *conn;
struct timespec64 now, t;
int i;

seq_puts(m, "#<name> <dialect> <credits> <open files> <requests> <last active>\n");

down_read(&conn_list_lock);
hash_for_each(conn_list, i, conn, hlist) {
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, "%pI4", &conn->inet_addr);
else
seq_printf(m, "%pI6", &conn->inet6_addr);
seq_printf(m, " 0x%03x %u %d %d %ptT\n",
conn->dialect,
conn->total_credits,
atomic_read(&conn->stats.open_files_count),
atomic_read(&conn->req_running),
&t);
}
up_read(&conn_list_lock);
return 0;
}

static int create_proc_clients(void)
{
proc_clients = ksmbd_proc_create("clients",
proc_show_clients, NULL);
if (!proc_clients)
return -ENOMEM;
return 0;
}

static void delete_proc_clients(void)
{
if (proc_clients) {
proc_remove(proc_clients);
proc_clients = NULL;
}
}
#else
static int create_proc_clients(void) { return 0; }
static void delete_proc_clients(void) {}
#endif

/**
* ksmbd_conn_free() - free resources of the connection instance
*
Expand Down Expand Up @@ -523,6 +576,7 @@ int ksmbd_conn_transport_init(void)
}
out:
mutex_unlock(&init_lock);
create_proc_clients();
return ret;
}

Expand Down Expand Up @@ -553,6 +607,7 @@ static void stop_sessions(void)

void ksmbd_conn_transport_destroy(void)
{
delete_proc_clients();
mutex_lock(&init_lock);
ksmbd_tcp_destroy();
ksmbd_rdma_stop_listening();
Expand Down
5 changes: 3 additions & 2 deletions connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define __KSMBD_CONNECTION_H__

#include <linux/list.h>
#include <linux/inet.h>
#include <linux/ip.h>
#include <net/sock.h>
#include <net/tcp.h>
Expand All @@ -31,7 +32,7 @@ enum {
KSMBD_SESS_RELEASING
};

struct ksmbd_stats {
struct ksmbd_conn_stats {
atomic_t open_files_count;
atomic64_t request_served;
};
Expand Down Expand Up @@ -76,7 +77,7 @@ struct ksmbd_conn {
struct list_head requests;
struct list_head async_requests;
int connection_type;
struct ksmbd_stats stats;
struct ksmbd_conn_stats stats;
char ClientGUID[SMB2_CLIENT_GUID_SIZE];
struct ntlmssp_auth ntlmssp;

Expand Down
3 changes: 3 additions & 0 deletions mgmt/tree_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "../transport_ipc.h"
#include "../connection.h"
#include "../stats.h"

#include "tree_connect.h"
#include "user_config.h"
Expand Down Expand Up @@ -85,6 +86,7 @@ ksmbd_tree_conn_connect(struct ksmbd_work *work, const char *share_name)
status.ret = -ENOMEM;
goto out_error;
}
ksmbd_counter_inc(KSMBD_COUNTER_TREE_CONNS);
kvfree(resp);
return status;

Expand Down Expand Up @@ -115,6 +117,7 @@ int ksmbd_tree_conn_disconnect(struct ksmbd_session *sess,
ret = ksmbd_ipc_tree_disconnect_request(sess->id, tree_conn->id);
ksmbd_release_tree_conn_id(sess, tree_conn->id);
ksmbd_share_config_put(tree_conn->share_conf);
ksmbd_counter_dec(KSMBD_COUNTER_TREE_CONNS);
if (atomic_dec_and_test(&tree_conn->refcount))
kfree(tree_conn);
return ret;
Expand Down
6 changes: 2 additions & 4 deletions mgmt/user_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ void ksmbd_free_user(struct ksmbd_user *user)
kfree(user);
}

int ksmbd_anonymous_user(struct ksmbd_user *user)
bool ksmbd_anonymous_user(struct ksmbd_user *user)
{
if (user->name[0] == '\0')
return 1;
return 0;
return user->name[0] == '\0';
}

bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2)
Expand Down
2 changes: 1 addition & 1 deletion mgmt/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ struct ksmbd_user *ksmbd_login_user(const char *account);
struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp,
struct ksmbd_login_response_ext *resp_ext);
void ksmbd_free_user(struct ksmbd_user *user);
int ksmbd_anonymous_user(struct ksmbd_user *user);
bool ksmbd_anonymous_user(struct ksmbd_user *user);
bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2);
#endif /* __USER_CONFIG_MANAGEMENT_H__ */
Loading