91bcfeb8ec077613bddabe96e7bfb3c1fdad5874
[obnox/slides/2016-05-sambaxp.git] / multichannel.wiki
1 <[sambabg]
2
3 ==== ====[plain]
4
5 <[center]
6 \Large
7 '''Multi-Channel'''
8 [center]>
9
10 [frame]>
11 [sambabg]>
12
13
14 ==== Multi-Channel - General ====
15
16 <[block]{multiple transport connections in one SMB(3) session}
17 * '''channel''': transport connection bound to a session
18 * client decides which connections to bind and to use
19 * session is valid as long as at least one channel is intact
20 [block]>
21
22 <[block]{two purposes}
23 # increase throughput:
24 #* use multiple connections of same type
25 # improve fault tolerance:
26 #* channel failure: replay/retry detection
27 %%#* session is valid as long as one channel is still intact
28 [block]>
29
30 ==== Multi-Channel - General ====
31
32 <[block]{use case: channels of different type/quality}
33 * use only the channels of best quality
34 * fall back to inferior channels if superior ones fail
35 * e.g.: laptop switching between WiFi and LAN (?)
36 [block]>
37
38 ==== Multi-Channel - Windows/Protocol ====
39
40 # establish initial session on TCP connection
41 # find interfaces with interface discovery: \\ %
42 @FSCTL\_QUERY\_NETWORK\_INTERFACE\_INFO@
43 # bind additional TCP (or later RDMA) connection (channel) to established SMB3 session (''session bind'')
44 # Windows: uses connections of same (and best) quality
45 # Windows: binds only to a single node
46 # replay / retry mechanisms, epoch numbers
47
48 ==== Multi-Channel $\in$ Samba ====
49
50 <[block]{samba/smbd: multi-process}
51 * '''Originally:''' process $\Leftrightarrow$ TCP connection
52 *<0> '''Idea:''' transfer new TCP connection to existing smbd
53 *<0> '''How?''' ==> use fd-passing (sendmsg/recvmsg)
54 *<0> '''When?'''
55 ** ''Natural choice'': at SessionSetup (Bind)
56 ** !Idea!: as early as possible, based on ClientGUID \\ %
57 ==> per ClientGUID single process model
58 %%*<0> !But!: This may not work! \frownie
59 [block]>
60
61 ==== Multi-Channel $\in$ Samba ====
62
63 <[center]
64 <<<smb3-mc-daemons-n1.png,width=.9\textwidth>>>
65 [center]>
66
67 ==== Multi-Channel $\in$ Samba ====
68
69 <[block]{samba/smbd: multi-process}
70 * '''Originally:''' process $\Leftrightarrow$ TCP connection
71 * '''Idea:''' transfer new TCP connection to existing smbd
72 *<0> '''How?''' ==> use fd-passing (sendmsg/recvmsg)
73 *<0> '''When?'''
74 ** ''Natural choice'': at SessionSetup (Bind)
75 ** !Idea!: as early as possible, based on ClientGUID \\ %
76 ==> per ClientGUID single process model
77 %%*<0> !But!: There may be problems! ... \frownie
78 [block]>
79
80
81 ==== Multi-Channel $\in$ Samba ====
82
83 -<1>{
84 <[center]
85 <<<smb3-mc-daemons-n1a.png,width=.9\textwidth>>>
86 [center]>
87 }
88
89 -<2>{
90 <[center]
91 <<<smb3-mc-daemons-n2.png,width=.9\textwidth>>>
92 [center]>
93 }
94
95 -<3>{
96 <[center]
97 <<<smb3-mc-daemons-n3.png,width=.9\textwidth>>>
98 [center]>
99 }
100
101
102 ==== Multi-Channel $\in$ Samba ====
103
104 <[block]{samba/smbd: multi-process}
105 * '''Originally:''' process $\Leftrightarrow$ TCP connection
106 * '''Idea:''' transfer new TCP connection to existing smbd
107 * '''How?''' ==> use fd-passing (sendmsg/recvmsg)
108 *<2-> '''When?'''
109 ** ''Natural choice'': at SessionSetup (Bind)
110 ** !Idea!: as early as possible, based on ClientGUID \\ %
111 ==> per ClientGUID single process model
112 %%*<0> !But!: There may be problems! ... \frownie
113 [block]>
114
115
116 ==== Multi-Channel $\in$ Samba : pass by ClientGUID ====
117
118 <[center]
119 %%<<<smb3-mc-samba_exp.png,height=.9\textheight>>>
120 <<<smb3-mc-samba.png,height=.9\textheight>>>
121 [center]>
122
123
124 ==== Multi-Channel $\in$ Samba : pass by ClientGUID ====
125
126 <[block]{Wait a minute - what about performance?}
127 * Single process...
128 * But we use short-lived worker-pthreads for I/O ops!
129 * Benchmarks and tunings still to be done.
130 [block]>
131
132 %%%% ==== Multi-Channel $\in$ Samba ====
133 %%%% 
134 %%%% <[block]{samba/smbd: multi-process}
135 %%%% * '''Orignally:''' process $\Leftrightarrow$ TCP connection
136 %%%% * '''Idea:''' transfer new TCP connection to existing smbd
137 %%%% * '''How?''' ==> use fd-passing (sendmsg/recvmsg)
138 %%%% * '''When?'''
139 %%%% ** ''Natural choice'': at SessionSetup (Bind)
140 %%%% ** ''Idea'': as early as possible, based on ClientGUID \\ %
141 %%%% ==> per ClientGUID single process model
142 %%%% * !But!: There may be problems! ... \frownie
143 %%%% [block]>
144 %%%% 
145 %%%% 
146 %%%% ==== The Relevance of the ClientGUID ====
147 %%%% 
148 %%%% +<1->{
149 %%%% <[block]{Assumption was:}
150 %%%% * All channels in a session have the same ClientGUID
151 %%%% * The server enforces this
152 %%%% [block]>
153 %%%% }
154 %%%% 
155 %%%% +<2->{
156 %%%% <[block]{Evidence from [MS-SMB2]:}
157 %%%% * 3.3.5.9 Receiving an SMB2 CREATE Request:
158 %%%% ** sets Open.ClientGuid to Connection.ClientGuid
159 %%%% ** replay detection checks \\ %
160 %%%% Open.ClientGuid == Connection.ClientGuid
161 %%%% * 3.3.5.9.7/12 Durable (v2) Reconnect Create Context:
162 %%%% ** check Open.ClientGuid == Connection.ClientGuid
163 %%%% [block]>
164 %%%% }
165 %%%% 
166 %%%% +<3->{
167 %%%% <[block]{The truth is...}
168 %%%% The Windows server does not enforce it!
169 %%%% [block]>
170 %%%% }
171 %%%% 
172 %%%% 
173 %%%% ==== The Relevance of the ClientGUID ====
174 %%%% 
175 %%%% <[block]{Windows behaviour according to MS}
176 %%%% * The server does NOT enforce same ClientGUID in a session.
177 %%%% * But clients can be expected to do it.
178 %%%% * But it is not explicitly documented like this.
179 %%%% [block]>
180 %%%% 
181 %%%% +<2->{
182 %%%% <[block]{The good news:}
183 %%%% There will be documentation notes:
184 %%%% * Things will not work as expected when clients behave differently.
185 %%%% * It is OK for a server to enforce equality of ClientGUID within session.
186 %%%% [block]>
187 %%%% }
188 %%%% 
189 %%%% ==== More digression on ClientGUID : Leases ====
190 %%%% 
191 %%%% <[block]{According to [MS-SMB2]}
192 %%%% * Server Global data Structures:
193 %%%% ** GlobalLeaseTableList indexed by ClientGuid (3.3.1.5)
194 %%%% *** LeaseTable indexed by LeaseKey (3.3.1.11)
195 %%%% * Requesting a lease (3.3.1.4):
196 %%%% ** Object store takes an abstract ClientLeaseId
197 %%%% *** Win7: combination of ClientGuid and LeaseKey
198 %%%% *** Win8+: LeaseKey
199 %%%% * Object store indicates a lease break (3.3.4.7):
200 %%%% ** smb server uses ClientGuid and LeaseKey given by ObjectStore
201 %%%% 
202 %%%%  ==> !Inconsistent\! -- What to do?!
203 %%%% [block]>
204 %%%% 
205 %%%% 
206 %%%% ==== Multi-Channel $\in$ Samba : pass by SessionID (plan B) ====
207 %%%% 
208 %%%% <[center]
209 %%%% <<<smb3-mc-samba-v2.png,height=.9\textheight>>>
210 %%%% [center]>
211
212
213 ==== Multi-Channel $\in$ Samba : Status ====
214
215 +<2->{
216 # messaging rewrite using unix dgm sockets with sendmsg [DONE,4.2]
217 # add fd-passing to messaging [DONE,4.2]
218 # preparations in internal structures [DONE,4.2--4.4]
219 # prepare code to cope with multiple channels [DONE,4.4]
220 # implement smbd message to pass a tcp socket [DONE,4.4]
221 # transfer connection in Negotiate (by ClientGUID) [DONE,4.4]
222 # implement session bind [DONE,4.4]
223 # implement channel sequence numbers [DONE,4.4]
224 # implement interface discovery [DONE(linux/conf),4.4]
225 # implement test cases [WIP(isn't it always?... $\smiley$)]
226 # implement fd-passing in socket-wrapper [WIP]
227 # implement lease break replay [TODO]
228 }
229
230 ==== Multi-Channel $\in$ Samba : How we got there ====
231
232 * Based on preparations in 4.2 and earlier (200+ patches)
233 * Since Summer 2015:
234 ** Polishing of large parts of massively WIP branch
235 ** Added new code (create replay, interface detection)
236 ** Result merged in units. Overall some ~130 patches.
237 ** Patches by:
238 *** Michael Adam
239 *** Stefan Metzmacher
240 *** Günther Deschner
241 *** Anoop C S
242 *** Anubhav Rakshit
243 * Just made it as experimental feature into Samba 4.4
244
245
246 ==== Multi-Channel $\in$ Samba : How to enable it ====
247
248 <[block]{smb.conf}
249 <[code]
250 \[global\]
251 ...
252 server multi channel support = yes
253 ...
254 [code]>
255 [block]>
256
257 %%==== Multi-Channel $\in$ Samba : Details from @smbXsrv.idl@ ====
258 %%%%==== @MSG\_SMBXSRV\_CONNECTION\_PASS@ ====
259 %%
260 %%<[block]{for @MSG\_SMBXSRV\_CONNECTION\_PASS@}
261 %%<[code]
262 %%typedef struct {
263 %%    NTTIME                 initial_connect_time;
264 %%    GUID                   client_guid;
265 %%    hyper                  seq_low;
266 %%    DATA_BLOB              negotiate_request;
267 %%} smbXsrv_connection_pass0;
268 %%[code]>
269 %%[block]>
270 %%
271 %%%%==== Internal Structures (@smbXsrv.idl@) ====
272 %%==== Multi-Channel $\in$ Samba : Details from @smbXsrv.idl@ ====
273 %%
274 %%
275 %%<[block]{layering before}
276 %%<[code]
277 %%smbXsrv_session
278 %%  ->smbXsrv_connection
279 %%[code]>
280 %%[block]>
281 %%
282 %%<[block]{layering now}
283 %%<[code]
284 %%smbXsrv_session
285 %%  ->smbXsrv_client
286 %%    ->smbXsrv_connections
287 %%[code]>
288 %%[block]>
289
290
291 %%% ==== Multi-Channel $\in$ Samba : Status ====
292 %%% 
293 %%% <[block]{WIP code}
294 %%% * @git://git.samba.org/obnox/samba/samba-obnox.git@
295 %%% * branch: @master-multi-channel-obnox@
296 %%% [block]>
297
298
299 ==== Multi-Channel $\in$ Samba: TODOs ====
300
301 *<2-> teach socket\_wrapper fd-passing ( ==> selftest...)
302 *<3-> Replay lease breaks upon channel failure (server $\rightarrow$ client) \\ %
303 _red_DANGER!_
304 *<4-> clustering integration (CTDB) \\ %
305 _red_DANGER!_
306
307 ==== Multi-Channel $\in$ Samba : Clustering/CTDB ====
308
309 +<2->{
310 <[block]{Special considerations}
311 * channels of one session only to one node !
312 * do not bind connections to CTDB public IPs (can move)!
313 * problem: CTDB clustering transparent to SMB clients...
314 * ==> !add static IPs on public interfaces! \\ %
315 use these for interface discovery
316 [block]>
317 }
318
319 ==== Multi-Channel $\in$ Samba : Clustering/CTDB ====
320
321 +<2->{
322 <[block]{Plan for integration}
323 * establish blacklist of addresses (e.g. CTDB public IPs)
324 * optionally establish whitelist (interfaces ...)
325 * ==> list of allowed addresses
326 * only publish allowed addresses in interfaces info ioctl
327 * only give more than one address in interface info when asked via an allowed address
328 * deny session bind on non-allowed address
329 [block]>
330 }
331
332 [frame]>
333
334 <[sambabg]
335
336
337 ==== ====[plain]
338
339 <[center]
340 \Large
341 Multi-Channel Demo
342 [center]>
343
344 [frame]>
345 [sambabg]>