@@ -32,6 +32,15 @@ module ControllerProcess = struct
32
32
module Log = Async_OpenFlow_Log
33
33
let tags = [(" openflow" , " openflow0x01" )]
34
34
35
+ let output_log = ref None
36
+
37
+ let initialize_output () =
38
+ Writer. open_file " /home/mark/updates-experiments/scripts/controller.remote"
39
+ >> | fun log -> output_log := Some log
40
+
41
+ let get_output () = match ! output_log with
42
+ | Some log -> log
43
+
35
44
module ChunkController = Async_OpenFlowChunk. Controller
36
45
module Client_id = struct
37
46
module T = struct
@@ -246,24 +255,34 @@ module ControllerProcess = struct
246
255
}
247
256
248
257
let create_from_chunk_hub t h =
249
- let ctl = create_from_chunk t in
258
+ let ctl = create_from_chunk t in
259
+ initialize_output ()
260
+ >> = fun () ->
250
261
Pipe. iter (Hub. listen_simple h) ~f: (fun (id , msg ) -> match msg with
251
262
| `Send (sw_id , msg ) -> begin
252
- Log. debug ~tags " send (remote)" ;
263
+ Print. fprintf (get_output () ) " [remote] send\n " ;
264
+ Writer. fsync (get_output () )
265
+ >> = fun () ->
253
266
send ctl sw_id msg
254
267
>> | fun resp -> Hub. send h id (`Send_resp resp)
255
268
end
256
269
| `Send_to_all msg ->
257
- Log. debug ~tags " send_to_all (remote)" ;
270
+ Print. fprintf (get_output () ) " [remote] send_to_all\n " ;
271
+ Writer. fsync (get_output () )
272
+ >> = fun () ->
258
273
return (send_to_all ctl msg)
259
274
| `Send_ignore_errors (sw_id , msg ) ->
260
275
return (send_ignore_errors ctl sw_id msg)
261
276
| `Listen -> begin
262
- Intf. hub ()
263
- >> =
264
- Hub. open_channel
265
- >> | fun chan -> Deferred. don't_wait_for (Pipe. iter_without_pushback (listen ctl) ~f: (fun elm -> Channel. write chan elm));
266
- Hub. send h id (`Listen_resp chan)
277
+ Intf. hub ~buffer_age_limit: `Unlimited ()
278
+ >> = fun new_h ->
279
+ Deferred. don't_wait_for (Pipe. read (Hub. listen_simple new_h)
280
+ >> = function
281
+ | `Ok (id , msg ) ->
282
+ (Pipe. iter_without_pushback (listen ctl)
283
+ ~f: (Hub. send new_h id)));
284
+ Hub. open_channel new_h
285
+ >> | fun chan -> Hub. send h id (`Listen_resp chan)
267
286
end
268
287
| `Individual_stats (pattern , sw_id ) -> (individual_stats ctl ~pattern sw_id)
269
288
>> | fun resp -> Hub. send h id (`Individual_stats_resp resp)
@@ -280,7 +299,10 @@ module ControllerProcess = struct
280
299
| `Set_idle_wait interval -> return (set_idle_wait ctl interval)
281
300
| `Set_kill_wait interval -> return (set_kill_wait ctl interval)
282
301
| `Get_switches ->
302
+ Print. fprintf (get_output () ) " [remote] get_switches\n " ;
283
303
Log. debug ~tags " get_switches (remote)" ;
304
+ Writer. fsync (get_output () )
305
+ >> = fun () ->
284
306
return (Hub. send h id (`Get_switches_resp (get_switches ctl)))
285
307
| `Clear_flows (pattern , sw_id ) -> clear_flows ~pattern ctl sw_id
286
308
>> | fun resp -> Hub. send h id (`Clear_flows_resp resp)
@@ -343,16 +365,12 @@ module Controller = struct
343
365
| `Individual_stats_resp of
344
366
(OpenFlow0x01_Stats .individualStats list , exn ) Result .t
345
367
| `Listen_resp of
346
- ([ `Connect of
347
- OpenFlow0x01 .switchId * OpenFlow0x01.SwitchFeatures .t
348
- | `Disconnect of SDN_Types .switchId * Core.Std.Sexp .t
349
- | `Message of
350
- SDN_Types .switchId * Message .t ],
368
+ ([ `Ready ],
351
369
[ `Connect of
352
370
OpenFlow0x01 .switchId * OpenFlow0x01.SwitchFeatures .t
353
371
| `Disconnect of SDN_Types .switchId * Core.Std.Sexp .t
354
372
| `Message of
355
- SDN_Types .switchId * Message .t ]) Channel .t
373
+ SDN_Types .switchId * Message .t ]) Channel .t
356
374
| `Send_resp of [ `Drop of exn | `Sent of Time .t ]
357
375
| `Has_client_id_resp of bool
358
376
| `Client_addr_port_resp of (Unix.Inet_addr .t * int ) option
@@ -472,10 +490,11 @@ module Controller = struct
472
490
Channel. write t `Listen ;
473
491
let reader,writer = Pipe. create () in
474
492
don't_wait_for (
475
- Channel. read t >> = function
476
- | `Listen_resp resp -> Log. debug ~tags " Listen channel returned (local)" ;
477
- Log. flushed () >> |
478
- fun () -> channel_transfer resp writer);
493
+ Log. debug ~tags " About to listen for listen_resp" ;
494
+ Channel. read t >> | function
495
+ | `Listen_resp chan -> Log. debug ~tags " Listen channel returned (local)" ;
496
+ Channel. write chan `Ready ;
497
+ channel_transfer chan writer);
479
498
reader
480
499
481
500
let barrier (t : t ) sw_id =
0 commit comments