summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Leff <adamleff@chef.io>2016-02-13 11:56:55 -0500
committerAdam Leff <adam@leff.co>2016-02-18 13:57:41 -0500
commit1f1ef35fc5b20234ca7a40e55011870e170ae22c (patch)
treeb82442f2ea772953d873fa08e913519da92a841c
parent00aeaadf2ef138e61b3c35da9dc1eead949c9f4a (diff)
downloadohai-1f1ef35fc5b20234ca7a40e55011870e170ae22c.tar.gz
bug fix: using next to skip the route eval block, not return
-rw-r--r--lib/ohai/plugins/linux/network.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 74343231..d22b4959 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -365,15 +365,21 @@ Ohai.plugin(:Network) do
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" &&