ohai 16.17.0 → 16.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85428f5d6833cf43857b50380c5c4987462ef9af9176844387bfef5e6ebb2c6f
4
- data.tar.gz: dead65d1c8914398e76e32db45b510f2f614ff6e24b21f7bd311811890fc778c
3
+ metadata.gz: 13d2f3369090412d4b03cbe4ec7cae19c4d10276d10abeb44036a98792128a5a
4
+ data.tar.gz: 7f22588951efbb2f0e0585a8ed958529cb55623cefb1ab214866b1878b6d1432
5
5
  SHA512:
6
- metadata.gz: ebdae2428922df53dab47f38786a70d81a196fa9f773ace33a624257f3af8b6ae49c6f6aa56112a363c4fe9f716b757c4491af7cd45f9dc9b73320f5130a8ab6
7
- data.tar.gz: 164e7f850b0040fe46176ead6387f580d6ed881671a3c842a5f4b4d518363ed7335747c555f39ab704c684b9d63b4336ca77d3e90ddbc4928a35ae99600667a9
6
+ metadata.gz: 857f8cfd699d5c0fb424c34c935dab790202922dc1d76556aaf50ed7cb1d25286d8c28eb1c25f258b798a13beb6fd738da69a90f65e5fa06422e3ae71e9602ce
7
+ data.tar.gz: 7b7a2d48a1ce3a4298fe145e088609935b99adb032f414ddc1fdac968d2111ca96e1366ede4d7e3c568d166bbe6030e9181b925cc37fcf64722409a20bd9945c
@@ -80,9 +80,22 @@ Ohai.plugin(:Network) do
80
80
  line.strip!
81
81
  logger.trace("Plugin Network: Parsing #{line}")
82
82
  if /\\/.match?(line)
83
- parts = line.split('\\')
84
- route_dest = parts.shift.strip
85
- route_endings = parts
83
+ # If we have multipath routing, then the first part will be a normal
84
+ # looking route:
85
+ # default proto ra metric 1024 <other options>
86
+ # Each successive part after that is a hop without those options.
87
+ # So the first thing we do is grab that first part, and split it into
88
+ # the route destination ("default"), and the route options.
89
+ parts = line.split("\\")
90
+ route_dest, dest_opts = parts.first.split(nil, 2)
91
+ # Then all the route endings, generally just nexthops.
92
+ route_endings = parts[1..-1]
93
+ if dest_opts && !dest_opts.empty?
94
+ # Route options like proto, metric, etc. only appear once for each
95
+ # multipath configuration. Prepend this information to the route
96
+ # endings so the code below will assign the fields properly.
97
+ route_endings.map! { |e| e.include?("nexthop") ? "#{dest_opts} #{e}" : e }
98
+ end
86
99
  elsif line =~ /^([^\s]+)\s(.*)$/
87
100
  route_dest = $1
88
101
  route_endings = [$2]
@@ -90,9 +103,24 @@ Ohai.plugin(:Network) do
90
103
  next
91
104
  end
92
105
  route_endings.each do |route_ending|
106
+ route_entry = Mash.new(destination: route_dest,
107
+ family: family[:name])
108
+ route_int = nil
93
109
  if route_ending =~ /\bdev\s+([^\s]+)\b/
94
110
  route_int = $1
95
- else
111
+ end
112
+ # does any known interface own the src address?
113
+ # we try to infer the interface/device from its address if it isn't specified
114
+ # we want to override the interface set via nexthop but only if possible
115
+ if line =~ /\bsrc\s+([^\s]+)\b/ && (!route_int || line.include?("nexthop"))
116
+ # only clobber previously set route_int if we find a match
117
+ if (match = iface.select { |name, intf| intf.fetch("addresses", {}).any? { |addr, _| addr == $1 } }.keys.first)
118
+ route_int = match
119
+ route_entry[:inferred] = true
120
+ end
121
+ end
122
+
123
+ unless route_int
96
124
  logger.trace("Plugin Network: Skipping route entry without a device: '#{line}'")
97
125
  next
98
126
  end
@@ -103,8 +131,6 @@ Ohai.plugin(:Network) do
103
131
  next
104
132
  end
105
133
 
106
- route_entry = Mash.new(destination: route_dest,
107
- family: family[:name])
108
134
  %w{via scope metric proto src}.each do |k|
109
135
  # http://rubular.com/r/pwTNp65VFf
110
136
  route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)/
@@ -273,6 +299,30 @@ Ohai.plugin(:Network) do
273
299
  iface
274
300
  end
275
301
 
302
+ # determine offload features for the interface using ethtool
303
+ def ethernet_offload_parameters(iface)
304
+ return iface unless ethtool_binary_path
305
+
306
+ iface.each_key do |tmp_int|
307
+ next unless iface[tmp_int][:encapsulation] == "Ethernet"
308
+
309
+ so = shell_out("#{ethtool_binary_path} -k #{tmp_int}")
310
+ Ohai::Log.debug("Plugin Network: Parsing ethtool output: #{so.stdout}")
311
+ iface[tmp_int]["offload_params"] = {}
312
+ so.stdout.lines.each do |line|
313
+ next if line.start_with?("Features for")
314
+ next if line.strip.nil?
315
+
316
+ key, val = line.split(/:\s+/)
317
+ if val
318
+ offload_key = key.downcase.strip.tr(" ", "_").to_s
319
+ iface[tmp_int]["offload_params"][offload_key] = val.downcase.gsub(/\[.*\]/, "").strip.to_s
320
+ end
321
+ end
322
+ end
323
+ iface
324
+ end
325
+
276
326
  # determine pause parameters for the interface using ethtool
277
327
  def ethernet_pause_parameters(iface)
278
328
  return iface unless ethtool_binary_path
@@ -326,6 +376,7 @@ Ohai.plugin(:Network) do
326
376
  so = shell_out("ip -d -s link")
327
377
  tmp_int = nil
328
378
  on_rx = true
379
+ xdp_mode = nil
329
380
  so.stdout.lines do |line|
330
381
  if line =~ IPROUTE_INT_REGEX
331
382
  tmp_int = $2
@@ -401,6 +452,30 @@ Ohai.plugin(:Network) do
401
452
  if line =~ /\sstate (\w+)/
402
453
  iface[tmp_int]["state"] = $1.downcase
403
454
  end
455
+
456
+ if line.include?("xdp")
457
+ mode = line.scan(/\s(xdp|xdpgeneric|xdpoffload|xdpmulti)\s/).flatten[0]
458
+ # Fetches and sets the mode from the first line.
459
+ unless mode.nil?
460
+ iface[tmp_int][:xdp] = {}
461
+ if mode.eql?("xdp")
462
+ # In case of xdpdrv, mode is xdp,
463
+ # to keep it consistent, keeping mode as xdpdrv.
464
+ mode = "xdpdrv"
465
+ end
466
+ xdp_mode = mode
467
+ iface[tmp_int][:xdp][:attached] = []
468
+ end
469
+
470
+ if line =~ %r{prog/(\w+) id (\d+) tag (\w+)}
471
+ mode = $1.eql?("xdp") ? xdp_mode : $1
472
+ iface[tmp_int][:xdp][:attached] << {
473
+ mode: mode,
474
+ id: $2,
475
+ tag: $3,
476
+ }
477
+ end
478
+ end
404
479
  end
405
480
  iface
406
481
  end
@@ -583,10 +658,12 @@ Ohai.plugin(:Network) do
583
658
  # sorting the selected routes:
584
659
  # - getting default routes first
585
660
  # - then sort by metric
661
+ # - then sort by if the device was inferred or not (preferring explicit to inferred)
586
662
  # - then by prefixlen
587
663
  [
588
664
  r[:destination] == "default" ? 0 : 1,
589
665
  r[:metric].nil? ? 0 : r[:metric].to_i,
666
+ r[:inferred] ? 1 : 0,
590
667
  # for some reason IPAddress doesn't accept "::/0", it doesn't like prefix==0
591
668
  # just a quick workaround: use 0 if IPAddress fails
592
669
  begin
@@ -793,9 +870,10 @@ Ohai.plugin(:Network) do
793
870
  iface = ethernet_ring_parameters(iface)
794
871
  iface = ethernet_channel_parameters(iface)
795
872
  iface = ethernet_coalesce_parameters(iface)
873
+ iface = ethernet_offload_parameters(iface)
796
874
  iface = ethernet_driver_info(iface)
797
875
  iface = ethernet_pause_parameters(iface)
798
876
  counters[:network][:interfaces] = net_counters
799
877
  network["interfaces"] = iface
800
878
  end
801
- end
879
+ end
@@ -136,7 +136,7 @@ Ohai.plugin(:Packages) do
136
136
  collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
137
137
  # on 64 bit systems, 32 bit programs are stored here moved before HKEY_CURRENT_USER otherwise it is not collected (impacts both ohai 16 & 17)
138
138
  collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
139
- collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
139
+ collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall') rescue nil
140
140
  # on 64 bit systems, 32 bit programs are stored here
141
141
  end
142
142
 
data/lib/ohai/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ohai
21
21
  OHAI_ROOT = File.expand_path(__dir__)
22
- VERSION = "16.17.0"
22
+ VERSION = "16.17.2"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.17.0
4
+ version: 16.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2023-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config