Skip to content

Commit

Permalink
input: handle_buf: emit an event if the connection was dropped from t…
Browse files Browse the repository at this point in the history
…he table

this happens e.g. on active open (state = Syn_sent) when a reset is received
and the connection attempt is discarded
  • Loading branch information
hannesm committed Nov 28, 2023
1 parent 66dc4a7 commit 67fc494
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/input.ml
Expand Up @@ -1104,24 +1104,26 @@ let handle_buf t now ~src ~dst data =
(Cstruct.length seg.payload)
(Base64.encode_string (Cstruct.to_string data)));
(* deliver_in_3a deliver_in_4 are done now! *)
let was_established =
let was_established, was_present =
match CM.find_opt id t.connections with
| None -> false
| Some s -> s.tcp_state = Established
| None -> false, false
| Some s -> s.tcp_state = Established, true
in
let t', outs = handle_segment t now id seg in
let is_established, received =
let is_established, is_present, received =
match CM.find_opt id t'.connections with
| None -> false, false
| None -> false, false, false
| Some s ->
s.tcp_state = Established,
true,
Cstruct.lenv s.rcvq > 0
in
let ev =
match was_established, is_established, received with
| false, true, _ -> Some (`Established id)
| true, false, _ -> Some (`Drop (id, received))
| _, _, true -> Some (`Received id)
match was_established, is_established, received, was_present, is_present with
| false, true, _, _, _ -> Some (`Established id)
| true, false, _, _, _
| _, _, _, true, false -> Some (`Drop (id, received))
| _, _, true, _, _ -> Some (`Received id)
| _ -> None
in
List.iter (fun (src', dst', _) ->
Expand Down

0 comments on commit 67fc494

Please sign in to comment.