Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pesky unhandled exception in Async scheduler #566

Open
reservoirman opened this issue Jul 15, 2017 · 3 comments
Open

pesky unhandled exception in Async scheduler #566

reservoirman opened this issue Jul 15, 2017 · 3 comments

Comments

@reservoirman
Copy link

hello so I'm basically trying to update the policy whenever certain events occur. After the event occurs, the program crashes with the following exception:

(((pid 24589) (thread_id 0))
 ((human_readable 2017-07-15T02:21:10-0400)
  (int63_ns_since_epoch 1500099670959842000))
 "unhandled exception in Async scheduler"
 ("unhandled exception"
  ((src/monitor.ml.Error_
    ((exn Not_found)
     (backtrace
      ("Raised at file \"src/core_hashtbl.ml\", line 296, characters 29-38"
       "Called from file \"lib/Frenetic_Vlr.ml\", line 181, characters 24-31"
       "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 356, characters 38-49"
       "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 363, characters 18-56"
       "Called from file \"async/Frenetic_OpenFlow0x01_Plugin.ml\", line 364, characters 16-76"
       "Called from file \"src/deferred_list.ml\", line 14, characters 22-29"
       "Called from file \"src/deferred0.ml\", line 57, characters 2-10"
       "Called from file \"src/deferred0.ml\", line 64, characters 64-69"
       "Called from file \"src/job_queue.ml\", line 160, characters 6-47" ""))
     (monitor
      (((name main) (here ()) (id 1) (has_seen_error true)
        (is_detached false))))))
   ((pid 24589) (thread_id 0)))))

any idea why this is the case?

@jnfoster
Copy link
Member

jnfoster commented Jul 17, 2017 via email

@reservoirman
Copy link
Author

Hi Nate, sorry for the delay. Here is the code that triggers it. I'm also running the following tree topology in mininet and attempting a pingall command:

sudo mn --controller=remote --topo=tree,2,2 --mac --arp

I've narrowed down the culprit to the call to the Controller.update (takeCareOfSentCounters srcMac); The problem goes away if I bind the return value of takeCareOfSentCounters to a variable and pass that into Controller.update, however I'd still like to know what's the difference. I'm also a beginner in OCaml so it could be something inherent in the language. Thanks for your help in advance!

`open Frenetic_NetKAT
module StdMap = Map
open Core.Std
open Async.Std
open Frenetic_OpenFlow
open Frenetic_OpenFlow0x01
module Log = Frenetic_Log

module PacketTable = StdMap.Make(Int64)

let counter = ref 0
let cs1 = ref 0
let cs2 = ref 0
let cs3 = ref 0
let cs4 = ref 0

let cr1 = ref 0
let cr2 = ref 0
let cr3 = ref 0
let cr4 = ref 0

let h1forwarded = ref 0
let h2forwarded = ref 0
let h3forwarded = ref 0
let h4forwarded = ref 0

let sendToController : policy = Mod(Location(Pipe("sendToController")))

let%nk monitor = {| if true then $sendToController else drop |}

(* this is based on the tutorial http://frenetic-lang.github.io/tutorials/NetKATRouting/ *)
let%nk routing =
{| if switch = 1 then
if port = 1 then port := 2
else if port = 2 then port := 1
else drop
else if switch = 2 then
if ethDst = 1 then port := 1
else if ethDst = 2 then port := 2
else port := 3
else if switch = 3 then
if ethDst = 3 then port := 1
else if ethDst = 4 then port := 2
else port := 3
else drop
|}

let%nk routingMonitoring = {| $routing + $monitor |}

(this is an attempt at the extra credit portion)
let sendToPacketLogger counter forwarded srcMac : policy =
if (counter > 10 && !forwarded <= 0) then
(
printf "Hey forwarding packets to the logger! From Host %Ld\n" srcMac;
forwarded := 1;
let%nk routingMonitoring = {|$routingMonitoring + (if ethSrc = $srcMac then ethDst := 4 else id)|} in routingMonitoring
)
else routingMonitoring

let takeCareOfReceivedCounters dstMac =
match dstMac with
1L -> cr1 := !cr1 + 1; printf "%d packets received on Host %Ld!\n" !cr1 dstMac;
|2L -> cr2 := !cr2 + 1; printf "%d packets received on Host %Ld!\n" !cr2 dstMac;
|3L -> cr3 := !cr3 + 1; printf "%d packets received on Host %Ld!\n" !cr3 dstMac;
|4L -> cr4 := !cr4 + 1; printf "%d packets received on Host %Ld!\n" !cr4 dstMac;
|_ -> printf "Holla unknown dest Mac %Ld\n" dstMac

let takeCareOfSentCounters srcMac: policy =
match srcMac with
1L -> cs1 := !cs1 + 1; printf "%d packets sent on Host %Ld!\n" !cs1 srcMac; sendToPacketLogger !cs1 h1forwarded srcMac;
|2L -> cs2 := !cs2 + 1; printf "%d packets sent on Host %Ld!\n" !cs2 srcMac; sendToPacketLogger !cs2 h1forwarded srcMac;
|3L -> cs3 := !cs3 + 1; printf "%d packets sent on Host %Ld!\n" !cs3 srcMac; sendToPacketLogger !cs3 h1forwarded srcMac;
|4L -> cs4 := !cs4 + 1; printf "%d packets sent on Host %Ld!\n" !cs4 srcMac; sendToPacketLogger !cs4 h1forwarded srcMac;
|_ -> printf "Holla unknown source Mac %Ld\n" srcMac; routingMonitoring

let rec handle_events (module Controller : Frenetic_NetKAT_Controller.CONTROLLER) =
let open Controller in
event () >>=
fun evt ->
match evt with
PacketIn(a,b,port,Buffered(_, cstruct),d,e)
| PacketIn(a,b,port,NotBuffered(cstruct),d,e) ->
let dstMac = (Frenetic_Packet.parse cstruct).dlDst in
let srcMac = (Frenetic_Packet.parse cstruct).dlSrc in
(* increment counters for packets sent/received per host. *)
takeCareOfReceivedCounters dstMac;
Controller.update (takeCareOfSentCounters srcMac);
handle_events (module Controller)
| _ -> handle_events (module Controller)

let _ =
let module Controller = Frenetic_NetKAT_Controller.Make (Frenetic_OpenFlow0x01_Plugin) in
Controller.start 6633;
Controller.update routingMonitoring;
Deferred.don't_wait_for(handle_events (module Controller));
(* Controller.update is equivalent to the OpenFlow Flow Mod call*)
never_returns (Scheduler.go ());`

@jnfoster
Copy link
Member

jnfoster commented Jul 26, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants