restructure wiki/includes
[obnox/slides/2016-04-vault.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 * '''Currently:''' 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 * '''Currently:''' 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 %%%% * '''Currently:''' 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 %%%% * '''Currently:''' 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.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 epoch 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 : Status ====
231 %%% 
232 %%% <[block]{WIP code}
233 %%% * @git://git.samba.org/obnox/samba/samba-obnox.git@
234 %%% * branch: @master-multi-channel-obnox@
235 %%% [block]>
236
237
238 ==== Multi-Channel $\in$ Samba: TODOs ====
239
240 * Replay lease breaks upon channel failure (server $\rightarrow$ client)
241 * teach socket\_wrapper fd-passing ( ==> selftest...)
242 * clustering integration (CTDB)
243
244 ==== Multi-Channel $\in$ Samba : Clustering/CTDB ====
245
246 +<2->{
247 <[block]{Special considerations}
248 * channels of one session only to one node !
249 * do not bind connections to CTDB public IPs (can move)!
250 * ==> !add static IPs on public interfaces! \\ %
251 use these for interface discovery
252 [block]>
253 }
254
255
256 ==== Multi-Channel $\in$ Samba : Details from @smbXsrv.idl@ ====
257 %%==== @MSG\_SMBXSRV\_CONNECTION\_PASS@ ====
258
259 <[block]{for @MSG\_SMBXSRV\_CONNECTION\_PASS@}
260 <[code]
261 typedef struct {
262     NTTIME                 initial_connect_time;
263     GUID                   client_guid;
264     hyper                  seq_low;
265     DATA_BLOB              negotiate_request;
266 } smbXsrv_connection_pass0;
267 [code]>
268 [block]>
269
270 %%==== Internal Structures (@smbXsrv.idl@) ====
271 ==== Multi-Channel $\in$ Samba : Details from @smbXsrv.idl@ ====
272
273
274 <[block]{layering before}
275 <[code]
276 smbXsrv_session
277   ->smbXsrv_connection
278 [code]>
279 [block]>
280
281 <[block]{layering now}
282 <[code]
283 smbXsrv_session
284   ->smbXsrv_client
285     ->smbXsrv_connections
286 [code]>
287 [block]>
288
289
290 [frame]>
291
292 <[sambabg]
293
294
295 ==== ====[plain]
296
297 <[center]
298 \Large
299 Multi-Channel Demo
300 [center]>
301
302 [frame]>
303 [sambabg]>