Re: [PATCH] network.dracutSetupString(): handle hosts outside the subnet (#577193)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 03/31/2010 04:54 PM, David Cantrell wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 30 Mar 2010, Hans de Goede wrote:

Out "ip route" output parsing did not handle the "ip route" output
properly in the case we were trying to find out which interface is
used to get to a host when that host lives outside our subnet.

This patch fixes this. Note this only fixes part of #577193, but as
the other part is really unrelated I'm splitting the fix into 2
patches.
---
network.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/network.py b/network.py
index a3fb8ee..f992d18 100644
--- a/network.py
+++ b/network.py
@@ -786,12 +786,13 @@ class Network:
return ""

routeInfo = route.split()
- if routeInfo[0] != host or len(routeInfo) < 5:
+ if routeInfo[0] != host or len(routeInfo) < 5 or \
+ "dev" not in routeInfo or routeInfo.index("dev") > 3:

Sure we want: "dev" not in routeInfo

In this test?


Yes, the entire test block reads:

            if routeInfo[0] != host or len(routeInfo) < 5 or \
               "dev" not in routeInfo or routeInfo.index("dev") > 3:
                log.error('Unexpected "ip route get to %s" reply: %s' %
                          (host, routeInfo))
                return ""

We are doing sanity checking on the output here, and if the output
does *not* contain "dev" it is not sane

log.error('Unexpected "ip route get to %s" reply: %s' %
(host, routeInfo))
return ""

- nic = routeInfo[2]
+ nic = routeInfo[routeInfo.index("dev") + 1]

Is this ok given the test above? If "dev" not in routeInfo would mean this
would become:

nic = routeInfo[-1 + 1]
nic = routeInfo[0]


If "dev" is not in the routeInfo, the above test will cause us to return ""
(and log an error).

I don't know what the possible /sbin/ip output could look like. On my
system,
I get this:

dcantrel@mitre ~$ ip route get to 172.31.1.11
172.31.1.11 dev eth0 src 172.31.1.13
cache mtu 1500 advmss 1460 hoplimit 64


Yes, which works correct with both the old and the new code, but when the
host is outside the current subnet the output looks something like this:

dcantrel@mitre ~$ ip route get to 111.222.111.222
111.222.111.222 via 172.31.1.1 dev eth0 src 172.31.1.13
cache mtu 1500 advmss 1460 hoplimit 64

Note that eth0 is now in a different position, but still after "dev", this
is what this patch tries to handle (and unless I'm mistaken it should handle).

Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux