Update Learning Switch

This commit is contained in:
Eishun Kondoh 2018-01-31 03:23:31 +09:00
parent 4c517a8147
commit 0df6336f5e
2 changed files with 10 additions and 8 deletions

View file

@ -18,7 +18,6 @@ defmodule LearningSwitch.Ofctl do
defmodule State do defmodule State do
defstruct [ defstruct [
datapath_id: nil, datapath_id: nil,
conn_ref: nil,
fdb_pid: nil fdb_pid: nil
] ]
end end
@ -27,14 +26,12 @@ defmodule LearningSwitch.Ofctl do
GenServer.start_link(__MODULE__, [datapath_id, args]) GenServer.start_link(__MODULE__, [datapath_id, args])
end end
def init([datapath_id, _args]) do def init([{datapath_id, _aux_id}, _args]) do
:ok = debug("Switch Ready: datapath_id: #{inspect(datapath_id)}") :ok = debug("Switch Ready: datapath_id: #{inspect(datapath_id)}")
conn_ref = SwitchRegistry.monitor(datapath_id)
{:ok, pid} = FDB.start_link {:ok, pid} = FDB.start_link
init_datapath(datapath_id) init_datapath(datapath_id)
state = %State{ state = %State{
datapath_id: datapath_id, datapath_id: datapath_id,
conn_ref: conn_ref,
fdb_pid: pid fdb_pid: pid
} }
{:ok, state} {:ok, state}
@ -48,8 +45,8 @@ defmodule LearningSwitch.Ofctl do
:ok = debug("PacketIn: eth_src: #{eth_src} datapath_id: #{inspect(state.datapath_id)}") :ok = debug("PacketIn: eth_src: #{eth_src} datapath_id: #{inspect(state.datapath_id)}")
{:noreply, state} {:noreply, state}
end end
def handle_info({:'DOWN', ref, :process, _pid, _reason}, %State{conn_ref: ref} = state) do def handle_info({:switch_disconnected, reason}, state) do
:ok = debug("Switch Disconnected: datapath_id: #{inspect(state.datapath_id)}") :ok = warn("[#{__MODULE__}] Switch Disconnected: datapath_id: #{state.datapath_id} by #{reason}")
{:stop, :normal, state} {:stop, :normal, state}
end end
def handle_info(info, state) do def handle_info(info, state) do

View file

@ -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"]},
}