Skip to content

Commit e9b2b2e

Browse files
committed
added debug printing
1 parent 74bed71 commit e9b2b2e

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

async/Async_OpenFlow0x01.ml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,12 @@ module ControllerProcess = struct
249249
let ctl = create_from_chunk t in
250250
Pipe.iter (Hub.listen_simple h) ~f:(fun (id, msg) -> match msg with
251251
| `Send (sw_id, msg) -> begin
252+
Log.debug ~tags "send (remote)";
252253
send ctl sw_id msg
253254
>>| fun resp -> Hub.send h id (`Send_resp resp)
254255
end
255256
| `Send_to_all msg ->
257+
Log.debug ~tags "send_to_all (remote)";
256258
return (send_to_all ctl msg)
257259
| `Send_ignore_errors (sw_id, msg) ->
258260
return (send_ignore_errors ctl sw_id msg)
@@ -278,6 +280,7 @@ module ControllerProcess = struct
278280
| `Set_idle_wait interval -> return (set_idle_wait ctl interval)
279281
| `Set_kill_wait interval -> return (set_kill_wait ctl interval)
280282
| `Get_switches ->
283+
Log.debug ~tags "get_switches (remote)";
281284
return (Hub.send h id (`Get_switches_resp (get_switches ctl)))
282285
| `Clear_flows (pattern, sw_id) -> clear_flows ~pattern ctl sw_id
283286
>>| fun resp -> Hub.send h id (`Clear_flows_resp resp)
@@ -306,6 +309,9 @@ module Controller = struct
306309
open Async.Std
307310
open Async_parallel
308311

312+
module Log = Async_OpenFlow_Log
313+
let tags = [("openflow", "openflow0x01")]
314+
309315
module Client_id = ControllerProcess.Client_id
310316
type t = ([ `Barrier of SwitchMap.key
311317
| `Individual_stats of
@@ -359,68 +365,83 @@ module Controller = struct
359365
]) Channel.t
360366

361367
let aggregate_stats ?(pattern=C.match_all) (t : t) sw_id =
368+
Log.debug ~tags "aggregate_stats (local)";
362369
Channel.write t (`Aggregate_stats (pattern, sw_id));
363370
Channel.read t >>| function
364371
| `Aggregate_stats_resp resp -> resp
365372

366373
let send_pkt_out (t : t) (sw_id:Client_id.t) pkt_out =
374+
Log.debug ~tags "send_pkt_out (local)";
367375
Channel.write t (`Send_pkt_out (sw_id, pkt_out));
368376
Channel.read t >>| function
369377
| `Send_pkt_out_resp resp -> resp
370378

371379
let send_flow_mods ?(clear=true) (t : t) (sw_id:Client_id.t) flow_mods =
380+
Log.debug ~tags "send_flow_mods (local)";
372381
Channel.write t (`Send_flow_mods (clear, sw_id, flow_mods));
373382
Channel.read t >>| function
374383
| `Send_flow_mods_resp resp -> resp
375384

376385
let clear_flows ?(pattern=C.match_all) (t : t) (sw_id:Client_id.t) =
386+
Log.debug ~tags "clear_flows (local)";
377387
Channel.write t (`Clear_flows (pattern, sw_id));
378388
Channel.read t >>| function
379389
| `Clear_flows_resp resp -> resp
380390

381391
let get_switches (t : t) =
392+
Log.debug ~tags "get_switches (local)";
382393
Channel.write t `Get_switches;
383394
Channel.read t >>| function
384395
| `Get_switches_resp resp -> resp
385396

386397
let set_kill_wait t (s:Time.Span.t) =
398+
Log.debug ~tags "set_kill_wait (local)";
387399
Channel.write t (`Set_kill_wait s)
388400

389401
let set_monitor_interval t (s:Time.Span.t) =
402+
Log.debug ~tags "set_monitor_interval (local)";
390403
Channel.write t (`Set_monitor_interval s)
391404

392405
let set_idle_wait t (s:Time.Span.t) : unit =
406+
Log.debug ~tags "set_idle_wait (local)";
393407
Channel.write t (`Set_idle_wait s)
394408

395409
let listening_port (t : t) =
410+
Log.debug ~tags "set_listening_port (local)";
396411
Channel.write t `Listening_port;
397412
Channel.read t >>| function
398413
| `Listening_port_resp resp -> resp
399414

400415
let client_addr_port (t : t) sw_id =
416+
Log.debug ~tags "client_addr_port (local)";
401417
Channel.write t (`Client_addr_port sw_id);
402418
Channel.read t >>| function
403419
| `Client_addr_port_resp resp -> resp
404420

405421
let send_to_all (t : t) msg =
422+
Log.debug ~tags "send_to_all (local)";
406423
Channel.write t (`Send_to_all msg)
407424

408425
let send_ignore_errors (t : t) sw_id msg =
426+
Log.debug ~tags "send_ignore_errors (local)";
409427
Channel.write t (`Send_ignore_errors (sw_id, msg))
410428

411429
let has_client_id (t : t) sw_id =
430+
Log.debug ~tags "has_client_id (local)";
412431
Channel.write t (`Has_client_id sw_id);
413432
Channel.read t >>| function
414433
| `Has_client_id_resp resp -> resp
415434

416435
let close (t : t) sw_id =
436+
Log.debug ~tags "close (local)";
417437
Channel.write t (`Close sw_id)
418438

419439
type e = ControllerProcess.e
420440
type m = ControllerProcess.m
421441
type c = ControllerProcess.c
422442

423443
let create_from_chunk chunk =
444+
Log.debug ~tags "create_from_chunk (local)";
424445
Intf.spawn (create_from_chunk_hub chunk) >>| fun (c,_) ->
425446
c
426447

@@ -429,6 +450,7 @@ module Controller = struct
429450
?log_disconnects
430451
?buffer_age_limit
431452
?monitor_connections ~port () : t Deferred.t =
453+
Log.debug ~tags "create (local)";
432454
Intf.spawn (create ?max_pending_connections
433455
?verbose
434456
?log_disconnects
@@ -437,6 +459,7 @@ module Controller = struct
437459
c
438460

439461
let send (t : t) sw_id msg =
462+
Log.debug ~tags "send (local)";
440463
Channel.write t (`Send (sw_id, msg));
441464
Channel.read t >>| function
442465
| `Send_resp resp -> resp
@@ -445,19 +468,24 @@ module Controller = struct
445468
Deferred.forever () (fun _ -> Channel.read chan >>=
446469
Pipe.write writer)
447470
let listen (t : t) =
471+
Log.debug ~tags "listen (local)";
448472
Channel.write t `Listen;
449473
let reader,writer = Pipe.create () in
450474
don't_wait_for (
451-
Channel.read t >>| function
452-
| `Listen_resp resp -> channel_transfer resp writer);
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);
453479
reader
454480

455481
let barrier (t : t) sw_id =
482+
Log.debug ~tags "barrier (local)";
456483
Channel.write t (`Barrier sw_id);
457484
Channel.read t >>| function
458485
| `Barrier_resp resp -> resp
459486

460487
let individual_stats ?(pattern=C.match_all) (t : t) sw_id =
488+
Log.debug ~tags "individual_stats (local)";
461489
Channel.write t (`Individual_stats (pattern, sw_id));
462490
Channel.read t >>| function
463491
| `Individual_stats_resp resp -> resp

0 commit comments

Comments
 (0)