~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/smb/server/connection.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
  4  */
  5 
  6 #ifndef __KSMBD_CONNECTION_H__
  7 #define __KSMBD_CONNECTION_H__
  8 
  9 #include <linux/list.h>
 10 #include <linux/ip.h>
 11 #include <net/sock.h>
 12 #include <net/tcp.h>
 13 #include <net/inet_connection_sock.h>
 14 #include <net/request_sock.h>
 15 #include <linux/kthread.h>
 16 #include <linux/nls.h>
 17 #include <linux/unicode.h>
 18 
 19 #include "smb_common.h"
 20 #include "ksmbd_work.h"
 21 
 22 #define KSMBD_SOCKET_BACKLOG            16
 23 
 24 enum {
 25         KSMBD_SESS_NEW = 0,
 26         KSMBD_SESS_GOOD,
 27         KSMBD_SESS_EXITING,
 28         KSMBD_SESS_NEED_RECONNECT,
 29         KSMBD_SESS_NEED_NEGOTIATE,
 30         KSMBD_SESS_RELEASING
 31 };
 32 
 33 struct ksmbd_stats {
 34         atomic_t                        open_files_count;
 35         atomic64_t                      request_served;
 36 };
 37 
 38 struct ksmbd_transport;
 39 
 40 struct ksmbd_conn {
 41         struct smb_version_values       *vals;
 42         struct smb_version_ops          *ops;
 43         struct smb_version_cmds         *cmds;
 44         unsigned int                    max_cmds;
 45         struct mutex                    srv_mutex;
 46         int                             status;
 47         unsigned int                    cli_cap;
 48         char                            *request_buf;
 49         struct ksmbd_transport          *transport;
 50         struct nls_table                *local_nls;
 51         struct unicode_map              *um;
 52         struct list_head                conns_list;
 53         struct rw_semaphore             session_lock;
 54         /* smb session 1 per user */
 55         struct xarray                   sessions;
 56         unsigned long                   last_active;
 57         /* How many request are running currently */
 58         atomic_t                        req_running;
 59         /* References which are made for this Server object*/
 60         atomic_t                        r_count;
 61         unsigned int                    total_credits;
 62         unsigned int                    outstanding_credits;
 63         spinlock_t                      credits_lock;
 64         wait_queue_head_t               req_running_q;
 65         wait_queue_head_t               r_count_q;
 66         /* Lock to protect requests list*/
 67         spinlock_t                      request_lock;
 68         struct list_head                requests;
 69         struct list_head                async_requests;
 70         int                             connection_type;
 71         struct ksmbd_stats              stats;
 72         char                            ClientGUID[SMB2_CLIENT_GUID_SIZE];
 73         struct ntlmssp_auth             ntlmssp;
 74 
 75         spinlock_t                      llist_lock;
 76         struct list_head                lock_list;
 77 
 78         struct preauth_integrity_info   *preauth_info;
 79 
 80         bool                            need_neg;
 81         unsigned int                    auth_mechs;
 82         unsigned int                    preferred_auth_mech;
 83         bool                            sign;
 84         bool                            use_spnego:1;
 85         __u16                           cli_sec_mode;
 86         __u16                           srv_sec_mode;
 87         /* dialect index that server chose */
 88         __u16                           dialect;
 89 
 90         char                            *mechToken;
 91         unsigned int                    mechTokenLen;
 92 
 93         struct ksmbd_conn_ops   *conn_ops;
 94 
 95         /* Preauth Session Table */
 96         struct list_head                preauth_sess_table;
 97 
 98         struct sockaddr_storage         peer_addr;
 99 
100         /* Identifier for async message */
101         struct ida                      async_ida;
102 
103         __le16                          cipher_type;
104         __le16                          compress_algorithm;
105         bool                            posix_ext_supported;
106         bool                            signing_negotiated;
107         __le16                          signing_algorithm;
108         bool                            binding;
109         atomic_t                        refcnt;
110 };
111 
112 struct ksmbd_conn_ops {
113         int     (*process_fn)(struct ksmbd_conn *conn);
114         int     (*terminate_fn)(struct ksmbd_conn *conn);
115 };
116 
117 struct ksmbd_transport_ops {
118         int (*prepare)(struct ksmbd_transport *t);
119         void (*disconnect)(struct ksmbd_transport *t);
120         void (*shutdown)(struct ksmbd_transport *t);
121         int (*read)(struct ksmbd_transport *t, char *buf,
122                     unsigned int size, int max_retries);
123         int (*writev)(struct ksmbd_transport *t, struct kvec *iovs, int niov,
124                       int size, bool need_invalidate_rkey,
125                       unsigned int remote_key);
126         int (*rdma_read)(struct ksmbd_transport *t,
127                          void *buf, unsigned int len,
128                          struct smb2_buffer_desc_v1 *desc,
129                          unsigned int desc_len);
130         int (*rdma_write)(struct ksmbd_transport *t,
131                           void *buf, unsigned int len,
132                           struct smb2_buffer_desc_v1 *desc,
133                           unsigned int desc_len);
134 };
135 
136 struct ksmbd_transport {
137         struct ksmbd_conn                       *conn;
138         const struct ksmbd_transport_ops        *ops;
139 };
140 
141 #define KSMBD_TCP_RECV_TIMEOUT  (7 * HZ)
142 #define KSMBD_TCP_SEND_TIMEOUT  (5 * HZ)
143 #define KSMBD_TCP_PEER_SOCKADDR(c)      ((struct sockaddr *)&((c)->peer_addr))
144 
145 extern struct list_head conn_list;
146 extern struct rw_semaphore conn_list_lock;
147 
148 bool ksmbd_conn_alive(struct ksmbd_conn *conn);
149 void ksmbd_conn_wait_idle(struct ksmbd_conn *conn);
150 int ksmbd_conn_wait_idle_sess_id(struct ksmbd_conn *curr_conn, u64 sess_id);
151 struct ksmbd_conn *ksmbd_conn_alloc(void);
152 void ksmbd_conn_free(struct ksmbd_conn *conn);
153 bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c);
154 int ksmbd_conn_write(struct ksmbd_work *work);
155 int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
156                          void *buf, unsigned int buflen,
157                          struct smb2_buffer_desc_v1 *desc,
158                          unsigned int desc_len);
159 int ksmbd_conn_rdma_write(struct ksmbd_conn *conn,
160                           void *buf, unsigned int buflen,
161                           struct smb2_buffer_desc_v1 *desc,
162                           unsigned int desc_len);
163 void ksmbd_conn_enqueue_request(struct ksmbd_work *work);
164 void ksmbd_conn_try_dequeue_request(struct ksmbd_work *work);
165 void ksmbd_conn_init_server_callbacks(struct ksmbd_conn_ops *ops);
166 int ksmbd_conn_handler_loop(void *p);
167 int ksmbd_conn_transport_init(void);
168 void ksmbd_conn_transport_destroy(void);
169 void ksmbd_conn_lock(struct ksmbd_conn *conn);
170 void ksmbd_conn_unlock(struct ksmbd_conn *conn);
171 
172 /*
173  * WARNING
174  *
175  * This is a hack. We will move status to a proper place once we land
176  * a multi-sessions support.
177  */
178 static inline bool ksmbd_conn_good(struct ksmbd_conn *conn)
179 {
180         return READ_ONCE(conn->status) == KSMBD_SESS_GOOD;
181 }
182 
183 static inline bool ksmbd_conn_need_negotiate(struct ksmbd_conn *conn)
184 {
185         return READ_ONCE(conn->status) == KSMBD_SESS_NEED_NEGOTIATE;
186 }
187 
188 static inline bool ksmbd_conn_need_reconnect(struct ksmbd_conn *conn)
189 {
190         return READ_ONCE(conn->status) == KSMBD_SESS_NEED_RECONNECT;
191 }
192 
193 static inline bool ksmbd_conn_exiting(struct ksmbd_conn *conn)
194 {
195         return READ_ONCE(conn->status) == KSMBD_SESS_EXITING;
196 }
197 
198 static inline bool ksmbd_conn_releasing(struct ksmbd_conn *conn)
199 {
200         return READ_ONCE(conn->status) == KSMBD_SESS_RELEASING;
201 }
202 
203 static inline void ksmbd_conn_set_new(struct ksmbd_conn *conn)
204 {
205         WRITE_ONCE(conn->status, KSMBD_SESS_NEW);
206 }
207 
208 static inline void ksmbd_conn_set_good(struct ksmbd_conn *conn)
209 {
210         WRITE_ONCE(conn->status, KSMBD_SESS_GOOD);
211 }
212 
213 static inline void ksmbd_conn_set_need_negotiate(struct ksmbd_conn *conn)
214 {
215         WRITE_ONCE(conn->status, KSMBD_SESS_NEED_NEGOTIATE);
216 }
217 
218 static inline void ksmbd_conn_set_need_reconnect(struct ksmbd_conn *conn)
219 {
220         WRITE_ONCE(conn->status, KSMBD_SESS_NEED_RECONNECT);
221 }
222 
223 static inline void ksmbd_conn_set_exiting(struct ksmbd_conn *conn)
224 {
225         WRITE_ONCE(conn->status, KSMBD_SESS_EXITING);
226 }
227 
228 static inline void ksmbd_conn_set_releasing(struct ksmbd_conn *conn)
229 {
230         WRITE_ONCE(conn->status, KSMBD_SESS_RELEASING);
231 }
232 
233 void ksmbd_all_conn_set_status(u64 sess_id, u32 status);
234 #endif /* __CONNECTION_H__ */
235 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php