Change in vdsm[ovirt-3.5]: net: source route: don't attempt to configure invalid values

ibarkan at redhat.com ibarkan at redhat.com
Thu Oct 23 10:10:58 UTC 2014


Ido Barkan has uploaded a new change for review.

Change subject: net: source route: don't attempt to configure invalid values
......................................................................

net: source route: don't attempt to configure invalid values

If a DHCP server provides Vdsm with invalid ip/netmask/gateway supervdsm
logs a not-very-useful

    "ipaddr, mask or gateway not received"

Instead, this patch logs dhclient's faulty information before passing it
to the source route configurator, which hopefully would provide the
local admin more clues regarding the failure.

Change-Id: I0c4719629bfdc632bbc35171489670062c6c14cb
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/network/configurators/__init__.py
M vdsm/network/sourceroute.py
M vdsm/network/sourceroutethread.py
3 files changed, 17 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/34392/1

diff --git a/vdsm/network/configurators/__init__.py b/vdsm/network/configurators/__init__.py
index 2923290..4eaa509 100644
--- a/vdsm/network/configurators/__init__.py
+++ b/vdsm/network/configurators/__init__.py
@@ -118,10 +118,18 @@
         ip = netEnt.ipConfig
         # bootproto is None for both static and no bootproto
         if ip.bootproto != 'dhcp' and netEnt.master is None:
-            logging.debug("Adding source route %s, %s, %s, %s" %
-                          (netEnt.name, ip.ipaddr, ip.netmask, ip.gateway))
-            StaticSourceRoute(netEnt.name, self).\
-                configure(ip.ipaddr, ip.netmask, ip.gateway)
+            logging.debug("Adding source route: name=%s, addr=%s, netmask=%s, "
+                          "gateway=%s" % (netEnt.name, ip.ipaddr, ip.netmask,
+                                          ip.gateway))
+            if (ip.gateway in (None, '0.0.0.0')
+               or not ip.ipaddr or not ip.netmask):
+                    logging.error('invalid input for source routing: name=%s, '
+                                  'addr=%s, netmask=%s, gateway=%s',
+                                  netEnt.name, ip.ipaddr, ip.netmask,
+                                  ip.gateway)
+            else:
+                StaticSourceRoute(netEnt.name, self).\
+                    configure(ip.ipaddr, ip.netmask, ip.gateway)
 
     def _removeSourceRoute(self, netEnt, sourceRouteClass):
         if netEnt.ipConfig.bootproto != 'dhcp' and netEnt.master is None:
diff --git a/vdsm/network/sourceroute.py b/vdsm/network/sourceroute.py
index e1c03f0..a3c3d6e 100644
--- a/vdsm/network/sourceroute.py
+++ b/vdsm/network/sourceroute.py
@@ -65,10 +65,6 @@
                      srcDevice=self.device)]
 
     def configure(self, ipaddr, mask, gateway):
-        if gateway in (None, '0.0.0.0') or not ipaddr or not mask:
-            logging.error("ipaddr, mask or gateway not received")
-            return
-
         self.ipaddr = ipaddr
         self.mask = mask
         self.gateway = gateway
diff --git a/vdsm/network/sourceroutethread.py b/vdsm/network/sourceroutethread.py
index c2f14e6..fa87af9 100644
--- a/vdsm/network/sourceroutethread.py
+++ b/vdsm/network/sourceroutethread.py
@@ -48,7 +48,11 @@
                     ip = sourceRouteContents[1]
                     mask = sourceRouteContents[2]
                     gateway = sourceRouteContents[3]
-                    sourceRoute.configure(ip, mask, gateway)
+                    if gateway in (None, '0.0.0.0') or not ip or not mask:
+                        logging.error('invalid DHCP response %s',
+                                      sourceRouteContents)
+                    else:
+                        sourceRoute.configure(ip, mask, gateway)
                 else:
                     sourceRoute.remove()
             else:


-- 
To view, visit http://gerrit.ovirt.org/34392
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c4719629bfdc632bbc35171489670062c6c14cb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>


More information about the vdsm-patches mailing list