Skip to content

Commit 96d45aa

Browse files
committed
Bugfix
Basically, this code was completely fucked.
1 parent 3e31cce commit 96d45aa

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

async/Async_OpenFlow.mli

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ module Chunk : sig
156156
val client_version : t -> Client_id.t -> int
157157
val client_next_xid : t -> Client_id.t -> int32
158158

159-
val send_txn
160-
: t
161-
-> Client_id.t
162-
-> m
163-
-> [ `Sent of Message.t Deferred.t | `Drop of exn ] Deferred.t
164-
165159
val handshake : int -> (t, e, h) Stage.t
166160
end
167161

async/Async_OpenFlow0x01.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ module Controller = struct
222222

223223
let barrier t sw_id =
224224
send_txn_with t sw_id M.BarrierRequest (function
225-
| M.BarrierReply -> Result.Ok ()
225+
| `Result (hdr, _) -> Result.Ok () (* assume it is a barrier reply *)
226226
| _ -> assert false)
227227

228228
let aggregate_stats ?(pattern=C.match_all) (t:t) sw_id =
@@ -233,7 +233,10 @@ module Controller = struct
233233
; sr_out_port = None }
234234
in
235235
send_txn_with t sw_id (M.StatsRequestMsg msg) (function
236-
| M.StatsReplyMsg (AggregateFlowRep r) -> Result.Ok r
236+
| `Result (hdr, body) ->
237+
(match M.parse hdr (Cstruct.to_string body) with
238+
| (_, M.StatsReplyMsg (AggregateFlowRep r)) -> Result.Ok r
239+
| _ -> assert false)
237240
| _ -> assert false)
238241

239242
let individual_stats ?(pattern=C.match_all) (t:t) sw_id =
@@ -244,6 +247,9 @@ module Controller = struct
244247
; sr_out_port = None }
245248
in
246249
send_txn_with t sw_id (M.StatsRequestMsg msg) (function
247-
| M.StatsReplyMsg (IndividualFlowRep r) -> Result.Ok r
248-
| _ -> assert false)
250+
| `Result (hdr, body) ->
251+
(match M.parse hdr (Cstruct.to_string body) with
252+
| (_, M.StatsReplyMsg (IndividualFlowRep r)) -> Result.Ok r
253+
| _ -> assert false)
254+
| _ -> assert false)
249255
end

async/Async_OpenFlow0x04.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ module Controller = struct
255255

256256
let barrier t sw_id =
257257
send_txn_with t sw_id M.BarrierRequest (function
258-
| M.BarrierReply -> Result.Ok ()
258+
| `Result (hdr, body) ->
259+
(match M.parse hdr (Cstruct.to_string body) with
260+
| (_, M.BarrierReply) -> Result.Ok ()
261+
| _ -> assert false)
259262
| _ -> assert false)
260263

261264
end

async/Async_OpenFlowChunk.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ open Core.Std
33
module Platform = Async_OpenFlow_Platform
44
module Header = OpenFlow_Header
55

6-
module Message : Platform.Message
6+
module Message : Platform.Message
77
with type t = (Header.t * Cstruct.t) = struct
88

99
type t = (Header.t * Cstruct.t) sexp_opaque with sexp
@@ -73,7 +73,7 @@ module Controller = struct
7373
let ivar = ref None in
7474
if not (xid = 0l) then
7575
XidTbl.change t.txns xid (function
76-
| None -> let ivar = ref (Some(Ivar.create ())) in !ivar
76+
| None -> ivar := Some (Ivar.create ()); !ivar
7777
| Some(_) -> None);
7878
match !ivar with
7979
| Some(ivar) -> ivar
@@ -252,7 +252,7 @@ module Controller = struct
252252
| `Sent x -> Handler.activity t c_id; `Sent x
253253
| `Drop x -> `Drop x
254254

255-
let send_txn t c_id m =
255+
let send_txn t c_id (m : Message.t) =
256256
let conn = Client_id.Table.find_exn t.clients c_id in
257257
let ivar = Conn.add_txn conn m in
258258
send t c_id m

0 commit comments

Comments
 (0)