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

bug fix #6

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ def out_port
path.last
end

def length
path.length / 2
end

private

def flows
path[1..-2].each_slice(2).to_a
end

def flow_mod_add_to_each_switch
return if path.length == 1
path.each_slice(2) do |in_port, out_port|
send_flow_mod_add(out_port.dpid,
hard_timeout: 60,
Expand All @@ -53,6 +58,7 @@ def flow_mod_add_to_each_switch
end

def flow_mod_delete_to_each_switch
return if path.length == 1
path.each_slice(2) do |in_port, out_port|
send_flow_mod_delete(out_port.dpid,
match: exact_match(in_port.number),
Expand All @@ -65,6 +71,6 @@ def exact_match(in_port)
end

def path
@full_path[1..-2]
@full_path.length > 1 ? @full_path[1..-2] : @full_path
end
end
8 changes: 7 additions & 1 deletion lib/path_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ def start
# This method smells of :reek:FeatureEnvy but ignores them
def packet_in(_dpid, message)
path = maybe_create_shortest_path(message)
ports = path ? [path.out_port] : external_ports

unless path.nil?
ports = path.length >= 1 ? [path.out_port] : @graph[path.out_port]
else
ports = external_ports
end

ports.each do |each|
send_packet_out(each.dpid,
raw_data: message.raw_data,
Expand Down