Skip to content

Commit

Permalink
bug fix: using next to skip the route eval block, not return
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Leff authored and adamleff committed Feb 18, 2016
1 parent 64c2b24 commit 53620d4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/ohai/plugins/linux/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,21 @@ def route_is_valid_default_route?(route, default_route)
def favored_default_route(routes, iface, default_route, family)
routes.select do |r|
if family[:name] == "inet"
# the route must have a source field
return false unless defined?(r[:src])
# the route must have a source address
next if r[:src].nil? || r[:src].empty?

# the interface specified in the route must exist
route_interface = iface[r[:dev]]
next if route_interface.nil? # the interface specified in the route must exist

# the interface specified in the route must exist
return false unless defined?(route_interface) # the interface specified in the route must exist
# the interface must have no addresses, or if it has the source address, the address must not
# be a link-level address
next unless interface_valid_for_route?(route_interface, r[:src], "inet")

# the route must either be a default route, or it must have a gateway which is accessible via the route
next unless route_is_valid_default_route?(r, default_route)

interface_valid_for_route?(route_interface, r[:src], "inet") && route_is_valid_default_route?(r, default_route)
true
elsif family[:name] == "inet6"
iface[r[:dev]] &&
iface[r[:dev]][:state] == "up" &&
Expand Down

0 comments on commit 53620d4

Please sign in to comment.