diff --git a/examples/learning_switch/lib/learning_switch/ofctl.ex b/examples/learning_switch/lib/learning_switch/ofctl.ex index 19c6121..21b123f 100644 --- a/examples/learning_switch/lib/learning_switch/ofctl.ex +++ b/examples/learning_switch/lib/learning_switch/ofctl.ex @@ -18,7 +18,6 @@ defmodule LearningSwitch.Ofctl do defmodule State do defstruct [ datapath_id: nil, - conn_ref: nil, fdb_pid: nil ] end @@ -27,14 +26,12 @@ defmodule LearningSwitch.Ofctl do GenServer.start_link(__MODULE__, [datapath_id, args]) end - def init([datapath_id, _args]) do + def init([{datapath_id, _aux_id}, _args]) do :ok = debug("Switch Ready: datapath_id: #{inspect(datapath_id)}") - conn_ref = SwitchRegistry.monitor(datapath_id) {:ok, pid} = FDB.start_link init_datapath(datapath_id) state = %State{ datapath_id: datapath_id, - conn_ref: conn_ref, fdb_pid: pid } {:ok, state} @@ -48,8 +45,8 @@ defmodule LearningSwitch.Ofctl do :ok = debug("PacketIn: eth_src: #{eth_src} datapath_id: #{inspect(state.datapath_id)}") {:noreply, state} end - def handle_info({:'DOWN', ref, :process, _pid, _reason}, %State{conn_ref: ref} = state) do - :ok = debug("Switch Disconnected: datapath_id: #{inspect(state.datapath_id)}") + def handle_info({:switch_disconnected, reason}, state) do + :ok = warn("[#{__MODULE__}] Switch Disconnected: datapath_id: #{state.datapath_id} by #{reason}") {:stop, :normal, state} end def handle_info(info, state) do diff --git a/examples/learning_switch/mix.lock b/examples/learning_switch/mix.lock index 9380bbc..cbc80d1 100644 --- a/examples/learning_switch/mix.lock +++ b/examples/learning_switch/mix.lock @@ -1,2 +1,7 @@ -%{"binpp": {:git, "https://github.com/jtendo/binpp.git", "64bd68d215d1a6cd35871e7c134d7fe2e46214ea", [branch: "master"]}, - "ranch": {:hex, :ranch, "1.4.0", "10272f95da79340fa7e8774ba7930b901713d272905d0012b06ca6d994f8826b", [], [], "hexpm"}} +%{ + "binpp": {:git, "https://github.com/jtendo/binpp.git", "64bd68d215d1a6cd35871e7c134d7fe2e46214ea", [branch: "master"]}, + "eovsdb": {:git, "https://github.com/shun159/eovsdb.git", "1ff1572708d72fd25631c681f2102407903252a3", [branch: "master"]}, + "jsone": {:git, "https://github.com/sile/jsone.git", "eecc9666c7165e1870b78a7a762549ae8d1c391b", [tag: "1.2.1"]}, + "ranch": {:hex, :ranch, "1.4.0", "10272f95da79340fa7e8774ba7930b901713d272905d0012b06ca6d994f8826b", [], [], "hexpm"}, + "uuid": {:git, "https://github.com/avtobiff/erlang-uuid.git", "585c2474afb4a597ae8c8bf6d21e5a9c73f18e0b", [tag: "v0.5.0"]}, +}