summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2017-12-15 21:46:46 -0800
committerPhil Dibowitz <phil@ipom.com>2017-12-19 18:13:44 -0800
commit0a2f0b47ee534d688d3ddcbb8f18c5820429f514 (patch)
tree5c5822a34c17ff8a89e0ef95b59be4d6aafcd6b2
parent6ff808c13e954f6a4ae2737d617a88f23c2a83ba (diff)
downloadohai-0a2f0b47ee534d688d3ddcbb8f18c5820429f514.tar.gz
[linux/network] [ohai 8] Tunnel information
This is a backport of #1104 to Ohai 8. Signed-off-by: Phil Dibowitz <phil@ipom.com>
-rw-r--r--lib/ohai/plugins/linux/network.rb25
-rw-r--r--spec/unit/plugins/linux/network_spec.rb37
2 files changed, 61 insertions, 1 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 8c41f81c..229ec4bc 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -215,6 +215,31 @@ Ohai.plugin(:Network) do
net_counters[tmp_int] = Mash.new unless net_counters[tmp_int]
end
+ if line =~ /^\s+(ip6tnl|ipip)/
+ iface[tmp_int][:tunnel_info] = {}
+ words = line.split
+ words.each_with_index do |word, index|
+ case word
+ when "external"
+ iface[tmp_int][:tunnel_info][word] = true
+ when "any", "ipip6", "ip6ip6"
+ iface[tmp_int][:tunnel_info][:proto] = word
+ when "remote",
+ "local",
+ "encaplimit",
+ "hoplimit",
+ "tclass",
+ "flowlabel",
+ "addrgenmode",
+ "numtxqueues",
+ "numrxqueues",
+ "gso_max_size",
+ "gso_max_segs"
+ iface[tmp_int][:tunnel_info][word] = words[index + 1]
+ end
+ end
+ end
+
if line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
int = on_rx ? :rx : :tx
net_counters[tmp_int][int] = Mash.new unless net_counters[tmp_int][int]
diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb
index 4b88ebe2..0885eb51 100644
--- a/spec/unit/plugins/linux/network_spec.rb
+++ b/spec/unit/plugins/linux/network_spec.rb
@@ -240,6 +240,10 @@ EOM
valid_lft forever preferred_lft forever
13: fwdintf: <MULTICAST,NOARP,UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 00:00:00:00:00:0a brd ff:ff:ff:ff:ff:ff
+14: ip6tnl0@NONE: <NOARP,UP,LOWER_UP> mtu 1452 qdisc noqueue state UNKNOWN group default qlen 1
+ link/tunnel6 :: brd ::
+ inet6 fe80::f47a:2aff:fef0:c6ef/64 scope link
+ valid_lft forever preferred_lft forever
EOM
end
@@ -300,6 +304,13 @@ EOM
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
140 2 0 1 0 0
+14: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1
+ link/tunnel6 :: brd :: promiscuity 0
+ ip6tnl ip6ip6 remote :: local :: encaplimit 0 hoplimit 0 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
+ RX: bytes packets errors dropped overrun mcast
+ 0 0 0 0 0 0
+ TX: bytes packets errors dropped carrier collsns
+ 0 0 0 0 0 0
EOM
end
@@ -572,7 +583,11 @@ EOM
end
it "detects the interfaces" do
- expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "fwdintf", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
+ if network_method == "iproute2"
+ expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "fwdintf", "ip6tnl0", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
+ else
+ expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "fwdintf", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
+ end
end
it "detects the layer one details of an ethernet interface" do
@@ -676,6 +691,26 @@ EOM
expect(plugin["network"]["interfaces"]["eth0"]["arp"]["10.116.201.1"]).to eq("fe:ff:ff:ff:ff:ff")
end
+ if network_method == "iproute2"
+ it "detects the tunnel information" do
+ expect(plugin["network"]["interfaces"]["ip6tnl0"]["tunnel_info"]).to eq(
+ {
+ "proto" => "ip6ip6",
+ "remote" => "::",
+ "local" => "::",
+ "encaplimit" => "0",
+ "hoplimit" => "0",
+ "tclass" => "0x00",
+ "flowlabel" => "0x00000",
+ "addrgenmode" => "eui64",
+ "numtxqueues" => "1",
+ "numrxqueues" => "1",
+ "gso_max_size" => "65536",
+ "gso_max_segs" => "65535",
+ }
+ )
+ end
+ end
end
describe "gathering interface counters via #{network_method}" do