Skip to content

Commit 3484d0f

Browse files
Adjusting IPROUTE_INT_REGEX to match interfaces with a semicolon (#1893)
This would now match the following: 100: ;someinterface;: .... Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as Indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Justin Steele <[email protected]> Co-authored-by: Sean <[email protected]>
1 parent d197e83 commit 3484d0f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/ohai/plugins/linux/network.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ def favored_default_route_linux(routes, iface, default_route, family)
702702
# Match the lead line for an interface from iproute2
703703
# 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
704704
# The '@eth0:' portion doesn't exist on primary interfaces and thus is optional in the regex
705-
IPROUTE_INT_REGEX ||= /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z\-_]+|):\s/.freeze
705+
IPROUTE_INT_REGEX ||= /^(\d+): ([0-9a-zA-Z@:;\.\-_]*?)(@[0-9a-zA-Z\-_]+|):\s/.freeze
706706

707707
if which("ip")
708708
# families to get default routes from

spec/unit/plugins/linux/network_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@
251251
link/tunnel6 :: brd ::
252252
inet6 fe80::f47a:2aff:fef0:c6ef/64 scope link
253253
valid_lft forever preferred_lft forever
254+
15: ;dummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
255+
link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff
254256
EOM
255257
end
256258

@@ -678,7 +680,7 @@
678680

679681
it "detects the interfaces" do
680682
if network_method == "iproute2"
681-
expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth13", "eth3", "foo:veth0@eth0", "fwdintf", "ip6tnl0", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
683+
expect(plugin["network"]["interfaces"].keys.sort).to eq([";dummy;", "eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth13", "eth3", "foo:veth0@eth0", "fwdintf", "ip6tnl0", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
682684
else
683685
expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth13", "eth3", "foo:veth0@eth0", "fwdintf", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
684686
end

0 commit comments

Comments
 (0)